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.
19 #include "weight_bias_kernel_base.h"
20 #include "convolution_params.h"
22 namespace kernel_selector
24 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25 // ConvolutionKernelBase
26 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27 class ConvolutionKernelBase : public WeightBiasKernelBase
30 using WeightBiasKernelBase::WeightBiasKernelBase;
31 virtual ~ConvolutionKernelBase() {}
33 struct DispatchData : public CommonDispatchData
37 size_t blockWidth, blockHeight; // used for kernels processing blocks
39 size_t inputBlockArraySize; // Number of elements in array of UNIT_TYPE that must be specified in kernel to store/cache input block.
40 size_t inputBlockWidth; // Number of elements in X dimension stored/cached in input block.
48 size_t globalWorkSizeDX;
49 size_t globalWorkSizeDY;
50 size_t globalWorkSizeDZ;
55 CLDNNStyle cldnnStyle;
60 std::string GetAutoTuneOptions(int autoTuneIndex) const;
61 std::vector<std::string> autoTuneOptions = { DEFAULT, NO_PRERA_SCH, AGE_BASED };
62 virtual KernelsData GetKernelsDataForAutoTune(const Params& params, const optional_params& options) const override;
63 virtual KernelsData GetTunedKernelsDataByIndex(const Params& params, const optional_params& options, int autoTuneIndex = -1) const override;
66 virtual std::vector<WeightsLayout> GetSupportedWeightLayouts(const convolution_params&) const = 0;
67 virtual std::string GetKernelName(const convolution_params&) const { return kernelName; }
68 virtual bool NeedPaddedInput() const { return false; }
69 virtual bool Validate(const Params& p, const optional_params& o) const override;
70 virtual JitConstants GetJitConstants(const convolution_params& params, const DispatchData& kd) const;
71 virtual DispatchData SetDefault(const convolution_params& params, int autoTuneIndex = -1) const;
72 static bool CheckWorkGroups(const DispatchData&);
73 static bool CheckPitchForSplitOnly(const convolution_params& params);
74 KernelsData GetCommonKernelsData(const Params& params, const optional_params& options, const std::string exeMode = DEFAULT, int autoTuneIndex = -1) const;
77 bool CovolutionCheckInput(const Params& p, const optional_params& o);
78 bool CheckConvolutionPaddedInputDesc(const convolution_params& params, const DataTensor& reqDesc);
79 bool CovolutionUpdateInputParams(convolution_params& params);