Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / actual_kernels / fully_connected / fully_connected_kernel_base.h
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
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
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
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 */
16
17 #pragma once
18
19 #include "weight_bias_kernel_base.h"
20 #include "fully_connected_params.h"
21
22 namespace kernel_selector 
23 {
24     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25     // FullyConnectedKernelBase
26     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27     class FullyConnectedKernelBase : public WeightBiasKernelBase
28     {
29     public:
30         using WeightBiasKernelBase::WeightBiasKernelBase;
31         virtual ~FullyConnectedKernelBase() {}
32
33         struct DispatchData : public CommonDispatchData
34         {
35             uint32_t    unit_byte_size;
36             const char* chunk_type;
37             uint32_t    chunk_byte_size;
38             uint32_t    units_per_chunk;
39             uint32_t    bytes_per_sg_read;
40             uint32_t    units_per_sg_read;
41             uint32_t    responses_per_sg_exec;
42             uint32_t    in_chunk_prefetch_size;
43             uint32_t    filter_chunk_prefetch_size;
44
45             uint32_t    last_rg_size;
46             uint32_t    rg_count;
47         };
48     
49         std::string GetAutoTuneOptions(int autoTuneIndex) const;
50         std::vector<std::string> autoTuneOptions = { DEFAULT, NO_PRERA_SCH, AGE_BASED };
51         virtual KernelsData GetTunedKernelsDataByIndex(const Params& params, const optional_params& options, DataLayout dl, std::vector<WeightsLayout> wl, float estimated_time = DONT_USE_IF_HAVE_SOMETHING_ELSE, int autoTuneIndex = -1) const ;
52
53     protected:
54         virtual JitConstants GetJitConstants(const fully_connected_params& params, const DispatchData& kd) const;
55         virtual DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1) const;
56         KernelsData GetCommonKernelsData(const Params& params, const optional_params& optParams, DataLayout dl, std::vector<WeightsLayout> wl, float estimated_time = DONT_USE_IF_HAVE_SOMETHING_ELSE, const std::string exeMode = DEFAULT, int autoTuneIndex = -1) const;
57
58         bool Validate(const Params& p, const optional_params&) const override
59         {
60             if (p.GetType() != KernelType::FULLY_CONNECTED)
61             {
62                 return false;
63             }
64
65             return true;
66         }
67     };
68 }