1 /*******************************************************************************
2 * Copyright 2016-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_U8S8S32X_CONVOLUTION_HPP
18 #define CPU_JIT_AVX512_CORE_U8S8S32X_CONVOLUTION_HPP
20 #include "c_types_map.hpp"
21 #include "cpu_convolution_pd.hpp"
22 #include "cpu_engine.hpp"
23 #include "jit_transpose_src_utils.hpp"
24 #include "cpu_reducer.hpp"
25 #include "cpu_barrier.hpp"
27 #include "jit_avx512_core_u8s8s32x_conv_kernel.hpp"
33 template <bool with_relu, impl::data_type_t dst_type>
34 struct _jit_avx512_core_u8s8s32x_convolution_fwd_t : public cpu_primitive_t {
35 struct pd_t : public _cpu_convolution_fwd_pd_t<with_relu> {
36 pd_t(engine_t *engine, const typename pd_t::base_desc_t *adesc,
37 const primitive_attr_t *attr,
38 const typename pd_t::base_class *hint_fwd_pd)
39 : _cpu_convolution_fwd_pd_t<with_relu>(engine, adesc, attr,
45 JIT_IMPL_NAME_HELPER("jit:", avx512_core, ""),
46 _jit_avx512_core_u8s8s32x_convolution_fwd_t<with_relu,
49 virtual status_t init() override
51 using namespace prop_kind;
52 assert(this->engine()->kind() == engine_kind::cpu);
54 && utils::one_of(this->cdesc_().prop_kind, forward_training,
56 && this->cdesc_().alg_kind == alg_kind::convolution_direct
57 && !this->has_zero_dim_memory()
58 && this->cdesc_().dst_desc.data_type == dst_type
59 && utils::implication(this->with_bias(), utils::one_of(
60 this->cdesc_().bias_desc.data_type, data_type::f32,
61 data_type::s32, data_type::s8, data_type::u8))
62 && this->cdesc_().accum_data_type == data_type::s32;
64 return status::unimplemented;
66 return jit_avx512_core_u8s8s32x_fwd_kernel::init_conf(
67 jcp_, this->cdesc_(), this->src_pd_, this->weights_pd_,
68 this->dst_pd_,this->bias_pd_, *this->attr(),
69 with_relu, this->negative_slope());
75 _jit_avx512_core_u8s8s32x_convolution_fwd_t(const pd_t *pd,
76 const input_vector &inputs, const output_vector &outputs)
77 : cpu_primitive_t(&conf_, inputs, outputs), conf_(*pd)
79 kernel_ = new jit_avx512_core_u8s8s32x_fwd_kernel(conf_.jcp_,
83 ~_jit_avx512_core_u8s8s32x_convolution_fwd_t() {
87 typedef typename prec_traits<data_type::u8>::type src_data_t;
88 typedef typename prec_traits<data_type::s8>::type wei_data_t;
89 typedef typename prec_traits<dst_type>::type dst_data_t;
91 virtual void execute(event_t *e)
94 e->set_state(event_t::ready);
98 void execute_forward();
100 jit_avx512_core_u8s8s32x_fwd_kernel *kernel_;
103 template <impl::data_type_t dst_type>
104 using jit_avx512_core_u8s8s32x_convolution_fwd_t =
105 _jit_avx512_core_u8s8s32x_convolution_fwd_t<false, dst_type>;
107 template <impl::data_type_t dst_type>
108 using jit_avx512_core_u8s8s32x_convolution_relu_t =
109 _jit_avx512_core_u8s8s32x_convolution_fwd_t<true, dst_type>;
117 // vim: et ts=4 sw=4 cindent cino^=l0,\:0,N-s