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_bfyx_direct_10_12_16.h"
19 namespace kernel_selector {
21 ParamsKey ConvolutionKernel_bfyx_Direct_10_10_12::GetSupportedKey() const
24 k.EnableInputDataType(Datatype::F16);
25 k.EnableOutputDataType(Datatype::F16);
26 k.EnableInputWeightsType(WeightsType::F16);
27 k.EnableInputWeightsType(WeightsType::F32);
28 k.EnableInputLayout(DataLayout::bfyx);
29 k.EnableOutputLayout(DataLayout::bfyx);
30 k.EnableTensorOffset();
31 k.EnableTensorPitches();
33 k.EnableSubGroupShort();
34 k.EnableBiasPerFeature();
35 k.EnableBiasPerOutput();
36 k.EnableNonBiasTerm();
38 k.EnableSplitSupport();
42 JitConstants ConvolutionKernel_bfyx_Direct_10_10_12::GetJitConstants(const convolution_params& cp, const DispatchData& runInfo) const
44 JitConstants jit = Parent::GetJitConstants(cp, runInfo);
47 MakeJitConstant("ALIGNED_OFM", RoundUp(cp.output.Feature().v, runInfo.gemmStyle.subBlockDimN)),
48 MakeJitConstant("DX", runInfo.gemmStyle.globalWorkSizeDX),
49 MakeJitConstant("DY", runInfo.gemmStyle.globalWorkSizeDY),
50 MakeJitConstant("KERNEL_SLICE_DIV2", (cp.filterSize.x * cp.filterSize.y) / 2),
51 MakeJitConstant("RIGHT_PARTIAL_TILE_K", cp.output.X().v % runInfo.gemmStyle.globalWorkSizeDX),
52 MakeJitConstant("INPUT_BUFFER_WIDTH_PADDED", ""), // TODO: enable non padding path again
53 MakeJitConstant("INPUT_BUFFER_HEIGHT_PADDED", ""),
59 ConvolutionKernel_bfyx_Direct_10_10_12::Parent::DispatchData ConvolutionKernel_bfyx_Direct_10_10_12::SetDefault(const convolution_params& arg, int) const
61 Parent::DispatchData runInfo = Parent::SetDefault(arg);
63 constexpr uint32_t TILE_N = 16;
65 if (arg.filterSize.x == 5)
67 runInfo.gemmStyle = { 1, 1, TILE_N, /*GWS DX*/ 4, /*GWS DY*/ 4, 1 };
71 runInfo.gemmStyle = { 1, 1, TILE_N, /*GWS DX*/ 4, /*GWS DY*/ 3, 1 };
74 runInfo.gws0 = RoundUp(arg.output.X().v, runInfo.gemmStyle.globalWorkSizeDX) / runInfo.gemmStyle.globalWorkSizeDX;
75 runInfo.gws1 = RoundUp(arg.output.Y().v, runInfo.gemmStyle.globalWorkSizeDY) / runInfo.gemmStyle.globalWorkSizeDY;
76 runInfo.gws2 = RoundUp(arg.output.Feature().v, TILE_N) * arg.output.Batch().v;
80 runInfo.lws2 = TILE_N;
82 runInfo.effiency = FORCE_PRIORITY_4;
87 bool ConvolutionKernel_bfyx_Direct_10_10_12::Validate(const Params& p, const optional_params& o) const
89 if (!Parent::Validate(p, o) ||
90 !CovolutionCheckInput(p, o))
95 const convolution_params& cp = static_cast<const convolution_params&>(p);
97 const bool bStrideOK = (cp.stride.x == 1 && cp.stride.y == 1);
98 const bool bFilter3x3 = (cp.filterSize.x == 3 && cp.filterSize.y == 3);
99 const bool bFilter5x5 = (cp.filterSize.x == 5 && cp.filterSize.y == 5);
100 const bool bFilterOK = bFilter3x3 || bFilter5x5;
102 if (!bFilterOK || !bStrideOK)
110 KernelsData ConvolutionKernel_bfyx_Direct_10_10_12::GetKernelsData(const Params& params, const optional_params& options) const
112 return GetTunedKernelsDataByIndex(params, options);