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_AVX512_CORE_I8I8_POOLING_HPP
18 #define CPU_JIT_AVX512_CORE_I8I8_POOLING_HPP
20 #include "c_types_map.hpp"
21 #include "cpu_pooling_pd.hpp"
22 #include "cpu_engine.hpp"
24 #include "jit_primitive_conf.hpp"
30 struct jit_avx512_core_i8i8_pool_fwd_ker_t;
32 struct jit_avx512_core_i8i8_pooling_fwd_t : public cpu_primitive_t {
33 struct pd_t : public cpu_pooling_fwd_pd_t {
34 pd_t(engine_t *engine, const pooling_desc_t *adesc,
35 const primitive_attr_t *attr,
36 const pooling_fwd_pd_t *hint_fwd_pd)
37 : cpu_pooling_fwd_pd_t(engine, adesc, attr, hint_fwd_pd) {}
40 JIT_IMPL_NAME_HELPER("jit:", avx512_core, ""),
41 jit_avx512_core_i8i8_pooling_fwd_t);
43 virtual status_t init() override {
44 assert(this->engine()->kind() == engine_kind::cpu);
46 && desc()->src_desc.ndims == 4
47 && set_default_params() == status::success
48 && desc()->prop_kind == prop_kind::forward_inference
49 && utils::one_of(desc()->alg_kind, alg_kind::pooling_max,
50 alg_kind::pooling_avg_include_padding,
51 alg_kind::pooling_avg_exclude_padding)
52 && utils::one_of(src_pd()->desc()->data_type, data_type::s32,
53 data_type::s8, data_type::u8)
54 && src_pd()->desc()->data_type == dst_pd()->desc()->data_type
55 && utils::everyone_is(memory_format::nhwc,
56 src_pd()->desc()->format, dst_pd()->desc()->format)
57 && attr()->has_default_values();
58 if (!ok) return status::unimplemented;
68 virtual status_t set_default_params() override {
69 using namespace memory_format;
70 if (dst_pd_.desc()->format == any)
71 CHECK(dst_pd_.set_format(nhwc));
72 return status::success;
76 jit_avx512_core_i8i8_pooling_fwd_t(const pd_t *pd,
77 const input_vector &inputs, const output_vector &outputs);
78 ~jit_avx512_core_i8i8_pooling_fwd_t();
80 virtual void execute(event_t *e) {
82 e->set_state(event_t::ready);
86 void execute_forward();
89 jit_avx512_core_i8i8_pool_fwd_ker_t *ker_;