2 // Copyright (c) 2016 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.
17 #include "convolution_kernel_mmad_slm_2x14_rep4.h"
18 #include "kernel_selector_utils.h"
20 namespace kernel_selector {
22 ParamsKey ConvolutionKernel_mmad_slm_2x14_rep4::GetSupportedKey() const
25 k.EnableInputDataType(Datatype::INT8);
26 k.EnableOutputDataType(Datatype::INT8);
27 k.EnableInputWeightsType(WeightsType::INT8);
28 k.EnableInputLayout(DataLayout::fs_bs_yx_bsv4_fsv32);
29 k.EnableOutputLayout(DataLayout::fs_bs_yx_bsv4_fsv32);
30 k.EnableTensorOffset();
31 k.EnableTensorPitches();
32 k.EnableBiasPerFeature();
33 k.EnableBiasPerOutput();
34 k.EnableNonBiasTerm();
36 k.EnableInt8Quantization();
37 k.EnableOutputCalibration();
42 bool ConvolutionKernel_mmad_slm_2x14_rep4::Validate(const Params& p, const optional_params& o) const
44 if (!ConvolutionKernelBase::Validate(p, o) ||
45 !CovolutionCheckInput(p, o))
50 const convolution_params& cp = static_cast<const convolution_params&>(p);
52 if (cp.filterSize.x != 3 || cp.filterSize.y != 3)
55 if (cp.inputs[0].X().v != 56 || cp.inputs[0].Y().v != 56)
58 if (cp.stride.x != 1 || cp.stride.y != 1)
64 ConvolutionKernelBase::DispatchData ConvolutionKernel_mmad_slm_2x14_rep4::SetDefault(const convolution_params& arg, int) const
66 DispatchData runInfo = ConvolutionKernelBase::SetDefault(arg);
68 runInfo.effiency = FORCE_PRIORITY_1;
70 const size_t rep_count = 4;
71 const size_t batch_per_wi = 1;
72 const size_t out_block_width = 14;
73 const size_t out_block_height = 2;
74 runInfo.gws0 = arg.output.Feature().v * (arg.output.Batch().v / (rep_count * batch_per_wi)); // number of tiles needed to cover output width
75 runInfo.gws1 = ((arg.inputs[0].X().v / arg.stride.x) + (out_block_width - 1)) / out_block_width;
76 runInfo.gws2 = ((arg.inputs[0].Y().v / arg.stride.y) + (out_block_height - 1)) / out_block_height;
78 runInfo.lws0 = 32; // depth
79 runInfo.lws1 = 1; // width
80 runInfo.lws2 = 4; // height
85 JitConstants ConvolutionKernel_mmad_slm_2x14_rep4::GetJitConstants(const convolution_params& params, const DispatchData& runInfo) const
87 auto jit = ConvolutionKernelBase::GetJitConstants(params, runInfo);
89 jit.AddConstant(MakeJitConstant("SUB_GROUP_SIZE", 8));
91 // pitch for special block format used in this kernel
92 const size_t ifm_32_aligned = Align(params.weights.IFM().v, 32);
93 const size_t filter_ofm_block_pitch = (ifm_32_aligned / 32) * params.weights.X().v * params.weights.Y().v * 4 * 8 * 8;
94 jit.AddConstant(MakeJitConstant("FILTER_OFM_BLOCK_PITCH", filter_ofm_block_pitch));
96 const size_t in_x_pitch = 32 * 4;
97 const size_t in_y_pitch = 32 * 4 * params.inputs[0].X().LogicalDimPadded();
98 const size_t in_b_block_pitch = in_y_pitch * params.inputs[0].Y().LogicalDimPadded();
99 const size_t in_f_block_pitch = in_b_block_pitch * ((params.inputs[0].Batch().v + 3) / 4);
100 const size_t in_offset = in_x_pitch * params.inputs[0].X().pad.before + in_y_pitch * params.inputs[0].Y().pad.before;
102 jit.AddConstant(MakeJitConstant("IN_X_PITCH", in_x_pitch));
103 jit.AddConstant(MakeJitConstant("IN_Y_PITCH", in_y_pitch));
104 jit.AddConstant(MakeJitConstant("IN_B_BLOCK_PITCH", in_b_block_pitch));
105 jit.AddConstant(MakeJitConstant("IN_F_BLOCK_PITCH", in_f_block_pitch));
106 jit.AddConstant(MakeJitConstant("IN_OFFSET", in_offset));
108 jit.AddConstant(MakeJitConstant("OUT_BLOCK_WIDTH", 14));
109 jit.AddConstant(MakeJitConstant("OUT_BLOCK_HEIGHT", 2));
110 jit.AddConstant(MakeJitConstant("LOCAL_SIZE_X", runInfo.lws0));
111 jit.AddConstant(MakeJitConstant("LOCAL_SIZE_Y", runInfo.lws1));
112 jit.AddConstant(MakeJitConstant("LOCAL_SIZE_Z", runInfo.lws2));
117 KernelsData ConvolutionKernel_mmad_slm_2x14_rep4::GetKernelsData(const Params& params, const optional_params& options) const
119 return GetCommonKernelsData(params, options, " -Dcl_intel_subgroups_char");