22 #include "ie_layers_property.hpp"
45 using Ptr = std::shared_ptr<CNNLayer>;
85 precision(prms.precision), userValue({0}) {
106 if (insData.empty()) {
109 auto lockedFirstInsData = insData[0].lock();
110 if (!lockedFirstInsData) {
113 return lockedFirstInsData;
119 INFERENCE_ENGINE_API_CPP(
void) validateLayer();
128 std::string val = GetParamAsString(param, std::to_string(def).c_str());
130 return std::stof(val);
132 THROW_IE_EXCEPTION <<
"Cannot parse parameter " << param <<
" from IR for layer " << name
133 <<
". Value " << val <<
" cannot be casted to float.";
143 std::string val = GetParamAsString(param);
145 return std::stof(val);
147 THROW_IE_EXCEPTION <<
"Cannot parse parameter " << param <<
" from IR for layer " << name
148 <<
". Value " << val <<
" cannot be casted to float.";
159 std::string vals = GetParamAsString(param,
"");
160 std::vector<float> result;
161 std::istringstream stream(vals);
165 while (getline(stream, str,
',')) {
167 result.push_back(std::stof(str));
169 THROW_IE_EXCEPTION <<
"Cannot parse parameter " << param <<
" " << str <<
" from IR for layer " << name
170 <<
". Value " << vals <<
" cannot be casted to floats.";
182 std::string vals = GetParamAsString(param);
183 std::vector<float> result;
184 std::istringstream stream(vals);
186 while (getline(stream, str,
',')) {
188 result.push_back(std::stof(str));
190 THROW_IE_EXCEPTION <<
"Cannot parse parameter " << param <<
" " << str <<
" from IR for layer " << name
191 <<
". Value " << vals <<
" cannot be casted to floats.";
204 std::string val = GetParamAsString(param, std::to_string(def).c_str());
206 return std::stoi(val);
208 THROW_IE_EXCEPTION <<
"Cannot parse parameter " << param <<
" from IR for layer " << name
209 <<
". Value " << val <<
" cannot be casted to int.";
219 std::string val = GetParamAsString(param);
221 return std::stoi(val);
223 THROW_IE_EXCEPTION <<
"Cannot parse parameter " << param <<
" from IR for layer " << name
224 <<
". Value " << val <<
" cannot be casted to int.";
236 std::string vals = GetParamAsString(param,
"");
237 std::vector<int> result;
238 std::istringstream stream(vals);
242 while (getline(stream, str,
',')) {
244 result.push_back(std::stoi(str));
246 THROW_IE_EXCEPTION <<
"Cannot parse parameter " << param <<
" " << str <<
" from IR for layer " << name
247 <<
". Value " << vals <<
" cannot be casted to int.";
259 std::string vals = GetParamAsString(param);
260 std::vector<int> result;
261 std::istringstream stream(vals);
263 while (getline(stream, str,
',')) {
265 result.push_back(std::stoi(str));
267 THROW_IE_EXCEPTION <<
"Cannot parse parameter " << param <<
" " << str <<
" from IR for layer " << name
268 <<
". Value " << vals <<
" cannot be casted to int.";
280 std::string val = GetParamAsString(param, std::to_string(def).c_str());
281 std::string message =
"Cannot parse parameter " + std::string(param) +
" from IR for layer " + name
282 +
". Value " + val +
" cannot be casted to int.";
284 int value = std::stoi(val);
288 return static_cast<unsigned int>(value);
300 std::string val = GetParamAsString(param);
301 std::string message =
"Cannot parse parameter " + std::string(param) +
" from IR for layer " + name
302 +
". Value " + val +
" cannot be casted to int.";
304 int value = std::stoi(val);
308 return static_cast<unsigned int>(value);
321 std::vector<unsigned int>
GetParamAsUInts(
const char *param, std::vector<unsigned int> def)
const {
322 std::string vals = GetParamAsString(param,
"");
323 std::vector<unsigned int> result;
324 std::istringstream stream(vals);
326 std::string message =
"Cannot parse parameter " + std::string(param) +
" " + str +
" from IR for layer " + name
327 +
". Value " + vals +
" cannot be casted to int.";
330 while (getline(stream, str,
',')) {
332 int value = std::stoi(str);
336 result.push_back(static_cast<unsigned int>(value));
350 std::string vals = GetParamAsString(param);
351 std::vector<unsigned int> result;
352 std::istringstream stream(vals);
354 std::string message =
"Cannot parse parameter " + std::string(param) +
" " + str +
" from IR for layer " + name
355 +
". Value " + vals +
" cannot be casted to int.";
356 while (getline(stream, str,
',')) {
358 int value = std::stoi(str);
362 result.push_back(static_cast<unsigned int>(value));
377 std::string val = GetParamAsString(param, std::to_string(def).c_str());
378 std::string loweredCaseValue;
379 std::transform(val.begin(), val.end(), std::back_inserter(loweredCaseValue), [](
char value) {
380 return std::tolower(value);
385 if (!(std::istringstream(loweredCaseValue) >> std::boolalpha >> result)) {
387 return static_cast<bool>(GetParamAsInt(param, def));
400 auto it = params.find(param);
401 if (it == params.end()) {
414 auto it = params.find(param);
415 if (it == params.end()) {
424 std::map<std::string, std::string>
params;
428 std::map<std::string, Blob::Ptr>
blobs;
465 #define DEFINE_PROP(prop_name) \
466 PropertyVector<unsigned int> prop_name;\
467 unsigned int &prop_name##_x = prop_name.at(X_AXIS);\
468 unsigned int &prop_name##_y = prop_name.at(Y_AXIS);\
498 unsigned int _out_depth = 0u;
502 unsigned int _group = 1u;
512 _kernel(2, 0u), _padding(2, 0u), _stride(2, 1u), _dilation(2, 1u) {}
518 WeightableLayer::operator=(that);
551 using ConvolutionLayer::operator=;
596 bool _exclude_pad =
false;
606 _kernel(2, 0u), _padding(2, 0u), _stride(2, 0u) {}
613 CNNLayer::operator=(that);
651 unsigned int _out_num = 0;
668 unsigned int _axis = 1;
686 unsigned int _axis = 1;
702 unsigned int _size = 0;
718 bool _isAcrossMaps =
false;
790 float negative_slope = 0.0f;
807 float min_value = 0.0f;
812 float max_value = 1.0f;
925 unsigned int _broadcast = 0;
952 std::vector<DataPtr> inputs;
953 std::vector<DataPtr> outputs;
956 std::vector<PortMap> input_port_map;
957 std::vector<PortMap> output_port_map;
958 std::vector<PortMap> back_edges;
1017 float epsilon = 1e-3f;
1042 bool transpose_a =
false;
1046 bool transpose_b =
false;
1064 Constant = 0, Edge, Reflect, Symmetric
1082 float pad_value = 0.0f;
int GetParamAsInt(const char *param, int def) const
Returns an integer value for the given parameter or returns the default value.
Definition: ie_layers.h:203
std::shared_ptr< CNNLayer > Ptr
A shared pointer to CNNLayer.
Definition: ie_layers.h:45
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:22
#define DEFINE_PROP(prop_name)
convinenent way to declare property with backward compatibility to 2D members
Definition: ie_layers.h:465
PoolingLayer(const PoolingLayer &that)
copy constructor
Definition: ie_layers.h:631
std::vector< int > axis
A vector of dimensions for cropping.
Definition: ie_layers.h:856
virtual const DataPtr input() const
Returns the first element of the input data for this layer.
Definition: ie_layers.h:105
This class represents a Layer which performs Scale and Shift.
Definition: ie_layers.h:969
std::string type
Layer type.
Definition: ie_layers.h:54
unsigned int _group
Number of groups.
Definition: ie_layers.h:502
PoolType _type
A pooling type.
Definition: ie_layers.h:591
unsigned int GetParamAsUInt(const char *param, unsigned int def) const
Returns an unsigned integer value for the given parameter or returns the default value.
Definition: ie_layers.h:279
PoolType
Defines available pooling types.
Definition: ie_layers.h:580
float GetParamAsFloat(const char *param, float def) const
Gets float value for the given parameter.
Definition: ie_layers.h:127
This class represents a standard crop layer.
Definition: ie_layers.h:851
The method holds the user values to enable binding of data per graph node.
Definition: ie_common.h:66
This structure describes ROI data.
Definition: ie_blob.h:784
PReLULayer(const LayerParams &prms)
A default constructor. Creates a new PReLULayer instance and initializes layer parameters with the gi...
Definition: ie_layers.h:981
This class represents a standard Power Layer Formula is: output = (offset + scale * input) ^ power...
Definition: ie_layers.h:988
std::vector< int > GetParamAsInts(const char *param, std::vector< int > def) const
Returns a vector of int values for the given parameter or returns the default value.
Definition: ie_layers.h:235
std::vector< int > shape
A vector of sizes of the shape.
Definition: ie_layers.h:880
Definition: ie_argmax_layer.hpp:11
This is an internal common Layer parameter parsing arguments.
Definition: ie_layers.h:28
bool _channel_shared
A flag that indicates if the same negative_slope value is used for all the features. If false, the value is used pixel wise.
Definition: ie_layers.h:974
PropertyVector< unsigned int > _dilation
A convolution dilations array [X, Y, Z, ...].
Definition: ie_layers.h:490
PropertyVector< unsigned int > pads_begin
Size of padding in the beginning of each axis.
Definition: ie_layers.h:1070
This class represents a layer with Weights and/or Biases (e.g. Convolution/Fully Connected, etc.)
Definition: ie_layers.h:439
Blob::Ptr _weights
A pointer to a weights blob.
Definition: ie_layers.h:450
PropertyVector< unsigned int > _stride
A convolution strides array [X, Y, Z, ...].
Definition: ie_layers.h:490
WeightableLayer(const LayerParams &prms)
A default constructor. Constructs a WeightableLayer instance and initiates layer parameters with the ...
Definition: ie_layers.h:445
std::vector< DataWeakPtr > insData
A vector of weak pointers to the input data elements of this layer in the di-graph (order matters) ...
Definition: ie_layers.h:66
std::string _auto_pad
Auto padding type.
Definition: ie_layers.h:506
void fuse(Ptr &layer)
Sets a layer to be fused with.
Definition: ie_layers.h:97
A header file for Blob and generic TBlob<>
This class represents a standard deconvolution layer.
Definition: ie_layers.h:548
std::vector< unsigned int > GetParamAsUInts(const char *param) const
Returns a vector of unsigned int values for the given parameter.
Definition: ie_layers.h:349
int to
Definition: ie_layers.h:941
std::vector< int > offset
A vector of offsets for each dimension.
Definition: ie_layers.h:864
This class represents standard MVN Layer.
Definition: ie_layers.h:763
PropertyVector< unsigned int > _kernel
A convolution kernel array [X, Y, Z, ...].
Definition: ie_layers.h:478
int stride
Definition: ie_layers.h:945
Ptr _fusedWith
If suggested to fuse - a pointer to the layer which needs to be fused with this layer.
Definition: ie_layers.h:70
ConvolutionLayer(const ConvolutionLayer &that)
copy constructor
Definition: ie_layers.h:536
PropertyVector< unsigned int > _pads_end
Pooling paddings end array [X, Y, Z, ...].
Definition: ie_layers.h:566
std::string name
Layer name.
Definition: ie_layers.h:30
class CNNLayer GenericLayer
Alias for CNNLayer object.
Definition: ie_layers.h:434
std::string type
Layer type.
Definition: ie_layers.h:32
This class represents a Clamp activation layer Clamps all tensor elements into the range [min_value...
Definition: ie_layers.h:802
int part_size
Definition: ie_layers.h:948
This class represents a layer that evenly splits the input into the supplied outputs.
Definition: ie_layers.h:681
eOperation
Defines possible operations that can be used.
Definition: ie_layers.h:828
bool _exclude_pad
A flag that indicates if padding is excluded or not.
Definition: ie_layers.h:596
This class represents an element wise operation layer.
Definition: ie_layers.h:822
PropertyVector< unsigned int > pads_end
Size of padding in the end of each axis.
Definition: ie_layers.h:1074
This class represents standard GRN Layer.
Definition: ie_layers.h:745
This class represents a standard reshape layer.
Definition: ie_layers.h:875
UserValue userValue
Convenience user values to store in this object as extra data.
Definition: ie_layers.h:74
GRNLayer(const LayerParams &prms)
A default constructor. Creates a new GRNLayer instance and initializes layer parameters with the give...
Definition: ie_layers.h:751
CNNLayer(const LayerParams &prms)
A constructor. Creates a new CNNLayer instance and initializes layer parameters with the given values...
Definition: ie_layers.h:84
This class represents a fully connected layer.
Definition: ie_layers.h:646
ePadMode
Defines possible modes of pad operation.
Definition: ie_layers.h:1063
std::map< std::string, std::string > params
Map of pairs: (parameter name, parameter value)
Definition: ie_layers.h:424
PoolingLayer(const LayerParams &p)
Creates a new PoolingLayer instance.
Definition: ie_layers.h:605
std::shared_ptr< Blob > Ptr
A smart pointer containing Blob object.
Definition: ie_blob.h:38
std::vector< float > coeff
A vector of coefficients to scale the operands.
Definition: ie_layers.h:840
bool GetParamsAsBool(const char *param, bool def) const
Returns an boolean value for the given parameter. The valid values are (true, false, 1, 0).
Definition: ie_layers.h:376
std::vector< unsigned int > GetParamAsUInts(const char *param, std::vector< unsigned int > def) const
Returns a vector of unsigned int values for the given parameter or returns the default value...
Definition: ie_layers.h:321
unsigned int GetParamAsUInt(const char *param) const
Returns an unsigned integer value for the given parameter.
Definition: ie_layers.h:299
This class represents a Batch Normalization Layer.
Definition: ie_layers.h:1012
PropertyVector< unsigned int > _stride
Pooling strides array [X, Y, Z, ...].
Definition: ie_layers.h:574
This class represents a Layer which performs Scale and Shift.
Definition: ie_layers.h:920
This class represents standard softmax Layer.
Definition: ie_layers.h:729
unsigned int _out_depth
A number of output feature maps (size) generating the 3'rd output dimension.
Definition: ie_layers.h:498
std::vector< float > GetParamAsFloats(const char *param) const
Returns a vector of float values for the given parameter.
Definition: ie_layers.h:181
This header file defines the main Data representation node.
int end
Definition: ie_layers.h:947
std::vector< int > GetParamAsInts(const char *param) const
Returns a vector of int values for the given parameter.
Definition: ie_layers.h:258
PropertyVector< unsigned int > _kernel
Pooling kernel array [X, Y, Z, ...].
Definition: ie_layers.h:562
float GetParamAsFloat(const char *param) const
Returns a float value for the given layer parameter.
Definition: ie_layers.h:142
PropertyVector< unsigned int > _padding
Pooling paddings begin array [X, Y, Z, ...].
Definition: ie_layers.h:562
Definition: ie_layers.h:951
int GetParamAsInt(const char *param) const
Returns an integer value for the given parameter.
Definition: ie_layers.h:218
int across_channels
Indicate that mean value is calculated across channels.
Definition: ie_layers.h:774
Precision precision
Layer base operating precision.
Definition: ie_layers.h:58
MVNLayer(const LayerParams &prms)
A default constructor. Creates a new MVNLayer instance and initializes layer parameters with the give...
Definition: ie_layers.h:769
This class represents a Rectified Linear activation layer.
Definition: ie_layers.h:785
This class represents a standard 3D Convolution Layer.
Definition: ie_layers.h:473
std::string _auto_pad
Auto padding type.
Definition: ie_layers.h:600
This class represents a standard Pad layer Adds paddings to input tensor.
Definition: ie_layers.h:1057
This header file contains aspects of working on different devices like CPU, GEN, FPGA, etc.
This class represents a standard Tile Layer.
Definition: ie_layers.h:899
Precision precision
Layer precision.
Definition: ie_layers.h:34
PropertyVector< unsigned int > _pads_end
A convolution paddings end array [X, Y, Z, ...].
Definition: ie_layers.h:482
Blob::Ptr _biases
A pointer to a biases blob.
Definition: ie_layers.h:454
This class represents a Linear Response Normalization (LRN) Layer.
Definition: ie_layers.h:697
This class represents TensorIterator layer.
Definition: ie_layers.h:936
This class represents concatenation layer Takes as input several data elements and merges them to one...
Definition: ie_layers.h:663
std::vector< float > GetParamAsFloats(const char *param, std::vector< float > def) const
Returns a vector of float values for the given parameter or returns the default value.
Definition: ie_layers.h:158
This is a base abstraction Layer - all DNN Layers inherit from this class.
Definition: ie_layers.h:40
std::shared_ptr< Data > DataPtr
Smart pointer to Data.
Definition: ie_common.h:50
int start
Definition: ie_layers.h:946
std::string affinity
Layer affinity set by user.
Definition: ie_layers.h:78
This class represents a standard pooling layer.
Definition: ie_layers.h:557
Definition: ie_layers.h:938
This class represents a standard Gather layer Gather slices from Dictionary according to Indexes...
Definition: ie_layers.h:1093
std::string GetParamAsString(const char *param) const
Returns a string value for the given parameter. Throws exception if parameter was not found...
Definition: ie_layers.h:413
PropertyVector< unsigned int > _padding
A convolution paddings begin array [X, Y, Z, ...].
Definition: ie_layers.h:478
std::map< std::string, Blob::Ptr > blobs
Map of pairs: (name, weights/biases blob)
Definition: ie_layers.h:428
std::string GetParamAsString(const char *param, const char *def) const
Returns a string value for the given parameter or returns the default one.
Definition: ie_layers.h:399
std::vector< DataPtr > outData
A vector of pointers to the output data elements of this layer in the di-graph (order matters) ...
Definition: ie_layers.h:62
int from
Definition: ie_layers.h:940
This class represents a general matrix multiplication operation layer Formula is: dst := alpha*src1*s...
Definition: ie_layers.h:1029
int axis
Definition: ie_layers.h:944
std::vector< int > dim
A vector of dimensions to be preserved.
Definition: ie_layers.h:860
std::string name
Layer name.
Definition: ie_layers.h:50
This is a header file with common inference engine definitions.
ConvolutionLayer(const LayerParams &p)
Creates a new ConvolutionLayer instance.
Definition: ie_layers.h:511
This class holds precision value and provides precision related operations.
Definition: ie_precision.hpp:19