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 JIT_AVX512_COMMON_1x1_CONV_KERNEL_HPP
18 #define JIT_AVX512_COMMON_1x1_CONV_KERNEL_HPP
20 #include "c_types_map.hpp"
21 #include "jit_generator.hpp"
22 #include "jit_primitive_conf.hpp"
23 #include "jit_uni_eltwise.hpp"
29 struct jit_avx512_common_1x1_conv_kernel : public jit_generator {
30 jit_avx512_common_1x1_conv_kernel(jit_1x1_conv_conf_t ajcp,
31 const primitive_attr_t &attr) : jcp(ajcp), attr_(attr)
34 jit_ker = (void (*)(jit_1x1_conv_call_s *)) this->getCode();
37 DECLARE_CPU_JIT_AUX_FUNCTIONS(jit_avx512_common_1x1_conv_kernel)
39 static bool post_ops_ok(jit_1x1_conv_conf_t &jcp,
40 const primitive_attr_t &attr);
42 static status_t init_conf(jit_1x1_conv_conf_t &jcp,
43 const convolution_desc_t &cd,
44 const memory_desc_wrapper &src_d,
45 const memory_desc_wrapper &weights_d,
46 const memory_desc_wrapper &dst_d,
47 const primitive_attr_t &attr,
48 bool with_relu, float relu_negative_slope,
49 int nthreads, bool reduce_src);
51 static status_t init_conf(jit_1x1_conv_conf_t &jcp,
52 const convolution_desc_t &cd,
53 const memory_desc_wrapper &src_d,
54 const memory_desc_wrapper &weights_d,
55 const memory_desc_wrapper &dst_d,
56 const primitive_attr_t &attr,
57 int nthreads, bool reduce_src)
59 return init_conf(jcp, cd, src_d, weights_d, dst_d, attr, false, 0.0,
60 nthreads, reduce_src);
63 jit_1x1_conv_conf_t jcp;
64 const primitive_attr_t &attr_;
65 void (*jit_ker)(jit_1x1_conv_call_s *);
68 using reg64_t = const Xbyak::Reg64;
69 using zmm_t = const Xbyak::Zmm;
70 using mask_t = const Xbyak::Opmask;
72 reg64_t reg_bcast_data = r8;
73 reg64_t reg_load_data = r10;
74 reg64_t reg_output_data = r9;
75 reg64_t aux_reg_bcast_data = r14;
76 reg64_t aux1_reg_bcast_data = rbx;
77 reg64_t aux_reg_load_data = r15;
78 reg64_t imm_addr64 = aux_reg_load_data;
79 reg64_t aux_reg_output_data = abi_not_param1;
80 reg64_t reg_load_loop_work = rsi;
81 reg64_t reg_reduce_loop_work = r11;
82 reg64_t bcast_loop_iter = rdx;
83 reg64_t reduce_loop_iter = abi_param1;
84 reg64_t reg_reduce_pos_flag = rax;
85 reg64_t reg_output_stride = r13;
86 reg64_t reg_bias_data = r12;
87 reg64_t reg_relu_ns = r13;
88 reg64_t reg_bcast_loop_work = aux1_reg_bcast_data;
91 Xbyak::Zmm vreg_bcast = Xbyak::Zmm(31);
93 int bcast_loop_work_offt = 0;
94 int stack_space_needed = 16;
96 void bcast_loop(int load_loop_blk);
97 void reduce_loop(int load_loop_blk, int ur, int substep, bool wraparound);
100 static void balance(jit_1x1_conv_conf_t &jcp, int nthreads);
102 Xbyak::Label l_table;
103 jit_uni_eltwise_vector_f32<avx512_common> eltwise_generator;