1 /*******************************************************************************
2 * Copyright 2017-2018 Intel Corporation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 *******************************************************************************/
17 #ifndef CPU_JIT_UNI_I8I8_POOLING_HPP
18 #define CPU_JIT_UNI_I8I8_POOLING_HPP
20 #include "c_types_map.hpp"
21 #include "cpu_isa_traits.hpp"
22 #include "cpu_pooling_pd.hpp"
23 #include "cpu_engine.hpp"
25 #include "jit_primitive_conf.hpp"
31 template <cpu_isa_t isa>
32 struct jit_uni_i8i8_pooling_fwd_ker_t;
34 template <cpu_isa_t isa>
35 struct jit_uni_i8i8_pooling_fwd_t : public cpu_primitive_t {
36 struct pd_t : public cpu_pooling_fwd_pd_t {
37 pd_t(engine_t *engine, const pooling_desc_t *adesc,
38 const primitive_attr_t *attr,
39 const pooling_fwd_pd_t *hint_fwd_pd)
40 : cpu_pooling_fwd_pd_t(engine, adesc, attr, hint_fwd_pd) {}
43 JIT_IMPL_NAME_HELPER("jit:", isa, ""),
44 jit_uni_i8i8_pooling_fwd_t<isa>);
46 virtual status_t init() override {
47 assert(this->engine()->kind() == engine_kind::cpu);
50 && desc()->src_desc.ndims == 4
51 && set_default_params() == status::success
52 && desc()->prop_kind == prop_kind::forward_inference
53 && utils::one_of(desc()->alg_kind, alg_kind::pooling_max,
54 alg_kind::pooling_avg_include_padding,
55 alg_kind::pooling_avg_exclude_padding)
56 && utils::one_of(src_pd()->desc()->data_type, data_type::s32,
57 data_type::s8, data_type::u8)
58 && src_pd()->desc()->data_type == dst_pd()->desc()->data_type
59 && utils::everyone_is(memory_format::nhwc,
60 src_pd()->desc()->format, dst_pd()->desc()->format)
61 && attr()->has_default_values();
62 if (!ok) return status::unimplemented;
72 virtual status_t set_default_params() override {
73 using namespace memory_format;
74 if (dst_pd_.desc()->format == any)
75 CHECK(dst_pd_.set_format(nhwc));
76 return status::success;
80 jit_uni_i8i8_pooling_fwd_t(const pd_t *apd,
81 const input_vector &inputs, const output_vector &outputs);
82 ~jit_uni_i8i8_pooling_fwd_t();
84 virtual void execute(event_t *e) const {
86 e->set_state(event_t::ready);
90 void execute_forward() const;
91 const pd_t *pd() const { return (const pd_t *)primitive_t::pd(); }
93 jit_uni_i8i8_pooling_fwd_ker_t<isa> *ker_;