C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 2

layer_forward_container_base.h
1 /* file: layer_forward_container_base.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Base container of neural network forward layer.
45 //--
46 */
47 
48 #ifndef __LAYER_FORWARD_CONTAINER_BASE_H__
49 #define __LAYER_FORWARD_CONTAINER_BASE_H__
50 
51 #include "algorithms/algorithm.h"
52 #include "data_management/data/tensor.h"
53 #include "services/daal_defines.h"
54 #include "algorithms/neural_networks/layers/layer_forward_types.h"
55 
56 namespace daal
57 {
58 namespace algorithms
59 {
63 namespace neural_networks
64 {
68 namespace layers
69 {
73 namespace forward
74 {
75 namespace interface1
76 {
86 class DAAL_EXPORT LayerContainerIfaceImpl : public AnalysisContainerIface<batch>
87 {
88 public:
89  LayerContainerIfaceImpl(daal::services::Environment::env *daalEnv = 0) : AnalysisContainerIface<batch>(daalEnv) {}
90 
94  virtual services::Status setupCompute()
95  {
96  return services::Status();
97  }
98 
99  virtual services::Status resetCompute()
100  {
101  return services::Status();
102  }
103 
107  virtual services::Status allocateInput();
108 
112  virtual services::Status initializeInput();
113 
114 protected:
115  virtual services::Status completeInput();
116 };
117 
132 template<ComputeMode mode,
133  typename sse2Container
134  DAAL_KERNEL_SSSE3_ONLY(typename ssse3Container)
135  DAAL_KERNEL_SSE42_ONLY(typename sse42Container)
136  DAAL_KERNEL_AVX_ONLY(typename avxContainer)
137  DAAL_KERNEL_AVX2_ONLY(typename avx2Container)
138  DAAL_KERNEL_AVX512_mic_ONLY(typename avx512_micContainer)
139  DAAL_KERNEL_AVX512_ONLY(typename avx512Container)
140  >
141 class DAAL_EXPORT AlgorithmDispatchLayerContainer : public LayerContainerIfaceImpl
142 {
143 public:
145  AlgorithmDispatchLayerContainer(daal::services::Environment::env *daalEnv);
146  virtual ~AlgorithmDispatchLayerContainer() { delete _cntr; }
147 
148  virtual services::Status compute() DAAL_C11_OVERRIDE
149  {
150  _cntr->setArguments(this->_in, this->_res, this->_par);
151  return _cntr->compute();
152  }
153 
154  virtual services::Status setupCompute() DAAL_C11_OVERRIDE
155  {
156  _cntr->setArguments(this->_in, this->_res, this->_par);
157  return _cntr->setupCompute();
158  }
159 
160  virtual services::Status resetCompute() DAAL_C11_OVERRIDE
161  {
162  return _cntr->resetCompute();
163  }
164 
165  virtual services::Status allocateInput() DAAL_C11_OVERRIDE
166  {
167  _cntr->setArguments(this->_in, this->_res, this->_par);
168  return _cntr->allocateInput();
169  }
170 
171  virtual services::Status initializeInput() DAAL_C11_OVERRIDE
172  {
173  _cntr->setArguments(this->_in, this->_res, this->_par);
174  return _cntr->initializeInput();
175  }
176 protected:
177  LayerContainerIfaceImpl *_cntr;
178 };
179 
180 #define __DAAL_ALGORITHM_LAYER_CONTAINER(ContainerTemplate, ...) \
181  layers::forward::AlgorithmDispatchLayerContainer<batch, \
182  ContainerTemplate<__VA_ARGS__, sse2> \
183  DAAL_KERNEL_SSSE3_CONTAINER(ContainerTemplate, __VA_ARGS__) \
184  DAAL_KERNEL_SSE42_CONTAINER(ContainerTemplate, __VA_ARGS__) \
185  DAAL_KERNEL_AVX_CONTAINER(ContainerTemplate, __VA_ARGS__) \
186  DAAL_KERNEL_AVX2_CONTAINER(ContainerTemplate, __VA_ARGS__) \
187  DAAL_KERNEL_AVX512_mic_CONTAINER(ContainerTemplate, __VA_ARGS__) \
188  DAAL_KERNEL_AVX512_CONTAINER(ContainerTemplate, __VA_ARGS__)>
189 
192 } // namespace interface1
193 
194 using interface1::AlgorithmDispatchLayerContainer;
195 using interface1::LayerContainerIfaceImpl;
196 
197 } // namespace forward
198 } // namespace layers
199 } // namespace neural_networks
200 } // namespace algorithms
201 } // namespace daal
202 #endif
daal::algorithms::neural_networks::layers::forward::interface1::AlgorithmDispatchLayerContainer::resetCompute
virtual services::Status resetCompute() DAAL_C11_OVERRIDE
Definition: layer_forward_container_base.h:160
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:79
daal_defines.h
daal::algorithms::neural_networks::layers::forward::interface1::AlgorithmDispatchLayerContainer::allocateInput
virtual services::Status allocateInput() DAAL_C11_OVERRIDE
Definition: layer_forward_container_base.h:165
daal::algorithms::neural_networks::layers::forward::interface1::LayerContainerIfaceImpl::resetCompute
virtual services::Status resetCompute()
Definition: layer_forward_container_base.h:99
daal::algorithms::neural_networks::layers::forward::interface1::AlgorithmDispatchLayerContainer::setupCompute
virtual services::Status setupCompute() DAAL_C11_OVERRIDE
Definition: layer_forward_container_base.h:154
daal::algorithms::neural_networks::layers::forward::interface1::AlgorithmDispatchLayerContainer
Implements a container to dispatch forward layers to cpu-specific implementations.
Definition: layer_forward_container_base.h:141
daal::algorithms::neural_networks::layers::forward::interface1::LayerContainerIfaceImpl::setupCompute
virtual services::Status setupCompute()
Definition: layer_forward_container_base.h:94
daal::algorithms::neural_networks::layers::forward::interface1::AlgorithmDispatchLayerContainer::initializeInput
virtual services::Status initializeInput() DAAL_C11_OVERRIDE
Definition: layer_forward_container_base.h:171
daal::algorithms::neural_networks::layers::forward::interface1::LayerContainerIfaceImpl
Provides methods of base container for forward layers. This class is associated with the daal::algori...
Definition: layer_forward_container_base.h:86
daal::algorithms::neural_networks::layers::forward::interface1::AlgorithmDispatchLayerContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
Definition: layer_forward_container_base.h:148
daal::ComputeMode
ComputeMode
Definition: daal_defines.h:130

For more complete information about compiler optimizations, see our Optimization Notice.