1/*******************************************************************************
2* Copyright 2021-2022 Intel Corporation
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*******************************************************************************/
16
17#ifndef CPU_X64_UNI_REDUCTION_HPP
18#define CPU_X64_UNI_REDUCTION_HPP
19
20#include "common/c_types_map.hpp"
21#include "common/primitive.hpp"
22
23#include "cpu/cpu_reduction_pd.hpp"
24
25#include "cpu/x64/injectors/jit_uni_postops_injector.hpp"
26#include "cpu/x64/jit_primitive_conf.hpp"
27#include "cpu/x64/jit_uni_reduction_kernel.hpp"
28
29namespace dnnl {
30namespace impl {
31namespace cpu {
32namespace x64 {
33
34struct jit_uni_reduction_t : public primitive_t {
35 struct pd_t : public cpu_reduction_pd_t {
36 using cpu_reduction_pd_t::cpu_reduction_pd_t;
37
38 DECLARE_COMMON_PD_T(JIT_IMPL_NAME_HELPER("jit:", conf_.isa, ""),
39 jit_uni_reduction_t);
40
41 status_t init(engine_t *engine);
42
43 const jit_reduction_conf_t &get_conf() const { return conf_; };
44
45 private:
46 bool fill_post_ops_conf();
47
48 jit_reduction_conf_t conf_;
49 };
50
51 jit_uni_reduction_t(const pd_t *apd) : primitive_t(apd) {}
52 virtual ~jit_uni_reduction_t() = default;
53
54 status_t init(engine_t *engine) override;
55 status_t execute(const exec_ctx_t &ctx) const override;
56
57private:
58 status_t get_proper_kernel(
59 const memory_desc_t *dst_md, const jit_reduction_conf_t &conf);
60
61 const pd_t *pd() const { return (const pd_t *)primitive_t::pd().get(); }
62
63 std::unique_ptr<jit_uni_reduction_kernel_base_t> kernel_;
64};
65
66} // namespace x64
67} // namespace cpu
68} // namespace impl
69} // namespace dnnl
70
71#endif
72