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 (GetParamAsInt(param, def) != 0);
396 return GetParamAsBool(param, def);
406 auto it = params.find(param);
407 if (it == params.end() || it->second.empty()) {
419 auto it = params.find(param);
420 if (it == params.end()) {
433 auto it = params.find(param);
434 if (it == params.end()) {
440 std::vector<std::string> GetParamAsStrings(
const char *param, std::vector<std::string> def)
const {
441 std::string vals = GetParamAsString(param,
"");
442 std::vector<std::string> result;
443 std::istringstream stream(vals);
447 while (getline(stream, str,
',')) {
449 result.push_back(str);
451 THROW_IE_EXCEPTION <<
"Cannot parse parameter " << param <<
" from IR for layer " << name <<
".";
460 std::map<std::string, std::string>
params;
465 std::map<std::string, Blob::Ptr>
blobs;
502 #define DEFINE_PROP(prop_name) \
503 PropertyVector<unsigned int> prop_name;\
504 unsigned int &prop_name##_x = prop_name.at(X_AXIS);\
505 unsigned int &prop_name##_y = prop_name.at(Y_AXIS);\
535 unsigned int _out_depth = 0u;
539 unsigned int _group = 1u;
549 _kernel(2, 0u), _padding(2, 0u), _stride(2, 1u), _dilation(2, 1u) {}
555 WeightableLayer::operator=(that);
588 using ConvolutionLayer::operator=;
633 bool _exclude_pad =
false;
643 _kernel(2, 0u), _padding(2, 0u), _stride(2, 0u) {}
650 CNNLayer::operator=(that);
699 unsigned int _in_depth = 0u;
704 float _pad_value = -1.0f;
729 unsigned int _out_depth = 0u;
733 unsigned int _group = 1u;
743 _kernel(2, 0u), _padding(2, 0u), _stride(2, 1u), _dilation(2, 1u) {}
749 WeightableLayer::operator=(that);
789 unsigned int _out_num = 0;
806 unsigned int _axis = 1;
824 unsigned int _axis = 1;
840 unsigned int _size = 0;
856 bool _isAcrossMaps =
false;
928 float negative_slope = 0.0f;
945 float min_value = 0.0f;
950 float max_value = 1.0f;
968 using ClampLayer::ClampLayer;
982 Sum = 0, Prod, Max, Sub, Min, Div, Squared_diff, Floor_mod, Pow,
983 Equal, Not_equal, Less, Less_equal, Greater, Greater_equal,
984 Logical_AND, Logical_OR, Logical_XOR
1080 unsigned int _broadcast = 0;
1107 std::vector<DataPtr> inputs;
1108 std::vector<DataPtr> outputs;
1111 std::vector<PortMap> input_port_map;
1112 std::vector<PortMap> output_port_map;
1113 std::vector<PortMap> back_edges;
1146 int hidden_size = 0;
1309 using RNNCellBase::RNNCellBase;
1316 unsigned int axis = 1;
1382 float epsilon = 1e-3f;
1407 bool transpose_a =
false;
1411 bool transpose_b =
false;
1429 Constant = 0, Edge, Reflect, Symmetric
1447 float pad_value = 0.0f;
1521 unsigned int group = 1;
1539 unsigned int block_size = 1;
1557 unsigned int block_size = 1;
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
BinaryConvolutionLayer(const LayerParams &p)
Creates a new BinaryConvolutionLayer instance.
Definition: ie_layers.h:742
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:502
PoolingLayer(const PoolingLayer &that)
copy constructor
Definition: ie_layers.h:668
std::vector< int > axis
A vector of dimensions for cropping.
Definition: ie_layers.h:1011
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:1334
std::string type
Layer type.
Definition: ie_layers.h:54
unsigned int _group
Number of groups.
Definition: ie_layers.h:539
PoolType _type
A pooling type.
Definition: ie_layers.h:628
This class represents a standard Strided Slice layer Strided Slice picks from input tensor according ...
Definition: ie_layers.h:1474
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:617
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:1006
std::vector< float > activation_beta
Beta parameters of activations.
Definition: ie_layers.h:1173
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:834
PReLULayer(const LayerParams &prms)
A default constructor. Creates a new PReLULayer instance and initializes layer parameters with the gi...
Definition: ie_layers.h:1346
This class represents a standard Power Layer Formula is: output = (offset + scale * input) ^ power...
Definition: ie_layers.h:1353
std::string begin_mask
The begin_mask is a bitmask where bit i being 0 means to ignore the begin value and instead use the d...
Definition: ie_layers.h:1480
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:1035
Definition: ie_argmax_layer.hpp:11
Definition: ie_layers.h:1322
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:1339
PropertyVector< unsigned int > _dilation
A convolution dilations array [X, Y, Z, ...].
Definition: ie_layers.h:527
This class represents a standard Space To Depth layer Depth To Space picks from input tensor accordin...
Definition: ie_layers.h:1552
eBinaryConvolutionMode _mode
Mode of binary convolution operation.
Definition: ie_layers.h:694
Definition: ie_layers.h:1135
Base class for recurrent cell layers.
Definition: ie_layers.h:1123
PropertyVector< unsigned int > pads_begin
Size of padding in the beginning of each axis.
Definition: ie_layers.h:1435
PropertyVector< unsigned int > _dilation
A convolution dilations array [X, Y, Z, ...].
Definition: ie_layers.h:721
This class represents a layer with Weights and/or Biases (e.g. Convolution/Fully Connected, etc.)
Definition: ie_layers.h:476
Blob::Ptr _weights
A pointer to a weights blob.
Definition: ie_layers.h:487
PropertyVector< unsigned int > _stride
A convolution strides array [X, Y, Z, ...].
Definition: ie_layers.h:527
This class represents a standard Fill layer RFill modifies input tensor according parameters...
Definition: ie_layers.h:1632
WeightableLayer(const LayerParams &prms)
A default constructor. Constructs a WeightableLayer instance and initiates layer parameters with the ...
Definition: ie_layers.h:482
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:543
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:585
std::string shrink_axis_mask
The shrink_axis_mask is a bitmask where bit i being 1 means the i-th position shrinks the dimensional...
Definition: ie_layers.h:1499
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
Direction
Direction of iteration through sequence dimension.
Definition: ie_layers.h:1321
int to
Definition: ie_layers.h:1096
std::vector< int > offset
A vector of offsets for each dimension.
Definition: ie_layers.h:1019
This class represents standard MVN Layer.
Definition: ie_layers.h:901
PropertyVector< unsigned int > _kernel
A convolution kernel array [X, Y, Z, ...].
Definition: ie_layers.h:515
int stride
Definition: ie_layers.h:1100
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:573
PropertyVector< unsigned int > _pads_end
Pooling paddings end array [X, Y, Z, ...].
Definition: ie_layers.h:603
std::vector< std::string > activations
Activations used inside recurrent cell.
Definition: ie_layers.h:1159
std::string name
Layer name.
Definition: ie_layers.h:30
class CNNLayer GenericLayer
Alias for CNNLayer object.
Definition: ie_layers.h:471
std::string type
Layer type.
Definition: ie_layers.h:32
This class represents a standard Reverse Sequence layer Reverse Sequence modifies input tensor accord...
Definition: ie_layers.h:1570
This class represents a Clamp activation layer Clamps all tensor elements into the range [min_value...
Definition: ie_layers.h:940
int part_size
Definition: ie_layers.h:1103
This class represents a layer that evenly splits the input into the supplied outputs.
Definition: ie_layers.h:819
Definition: ie_layers.h:1323
Definition: ie_layers.h:1133
eOperation
Defines possible operations that can be used.
Definition: ie_layers.h:981
bool _exclude_pad
A flag that indicates if padding is excluded or not.
Definition: ie_layers.h:633
This class represents an element wise operation layer.
Definition: ie_layers.h:975
PropertyVector< unsigned int > pads_end
Size of padding in the end of each axis.
Definition: ie_layers.h:1439
This class represents standard GRN Layer.
Definition: ie_layers.h:883
This class represents a standard Shuffle Channels layer Shuffle Channels picks from input tensor acco...
Definition: ie_layers.h:1511
This class represents a standard reshape layer.
Definition: ie_layers.h:1030
UserValue userValue
Convenience user values to store in this object as extra data.
Definition: ie_layers.h:74
Sequence of recurrent cells.
Definition: ie_layers.h:1307
PropertyVector< unsigned int > _pads_end
A convolution paddings end array [X, Y, Z, ...].
Definition: ie_layers.h:713
BinaryConvolutionLayer(const BinaryConvolutionLayer &that)
copy constructor
Definition: ie_layers.h:770
GRNLayer(const LayerParams &prms)
A default constructor. Creates a new GRNLayer instance and initializes layer parameters with the give...
Definition: ie_layers.h:889
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:784
ePadMode
Defines possible modes of pad operation.
Definition: ie_layers.h:1428
std::map< std::string, std::string > params
Map of pairs: (parameter name, parameter value)
Definition: ie_layers.h:460
Definition: ie_layers.h:1132
PoolingLayer(const LayerParams &p)
Creates a new PoolingLayer instance.
Definition: ie_layers.h:642
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:995
bool GetParamsAsBool(const char *param, bool def) const
Definition: ie_layers.h:395
std::string end_mask
Analogous to begin_mask.
Definition: ie_layers.h:1484
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
std::vector< float > activation_alpha
Alpha parameters of activations.
Definition: ie_layers.h:1166
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 ReLU6 activation layer Clamps all tensor elements into the range [0...
Definition: ie_layers.h:962
This class represents a Batch Normalization Layer.
Definition: ie_layers.h:1377
unsigned int _group
Number of groups.
Definition: ie_layers.h:733
PropertyVector< unsigned int > _stride
Pooling strides array [X, Y, Z, ...].
Definition: ie_layers.h:611
This class represents a Layer which performs Scale and Shift.
Definition: ie_layers.h:1075
This class represents standard softmax Layer.
Definition: ie_layers.h:867
unsigned int _out_depth
A number of output feature maps (size) generating the 3'rd output dimension.
Definition: ie_layers.h:535
PropertyVector< unsigned int > _kernel
A convolution kernel array [X, Y, Z, ...].
Definition: ie_layers.h:709
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:1102
bool GetParamAsBool(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< int > GetParamAsInts(const char *param) const
Returns a vector of int values for the given parameter.
Definition: ie_layers.h:258
float _pad_value
A pad value which is used to fill pad area.
Definition: ie_layers.h:704
std::string ellipsis_mask
The ellipsis_mask is a bitmask where bit i being 1 means the i-th is actually an ellipsis.
Definition: ie_layers.h:1489
unsigned int _in_depth
A number of input feature maps (size) generating the 3'rd input dimension.
Definition: ie_layers.h:699
PropertyVector< unsigned int > _kernel
Pooling kernel array [X, Y, Z, ...].
Definition: ie_layers.h:599
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:599
Definition: ie_layers.h:1106
int GetParamAsInt(const char *param) const
Returns an integer value for the given parameter.
Definition: ie_layers.h:218
PropertyVector< unsigned int > _padding
A convolution paddings begin array [X, Y, Z, ...].
Definition: ie_layers.h:709
int across_channels
Indicate that mean value is calculated across channels.
Definition: ie_layers.h:912
Precision precision
Layer base operating precision.
Definition: ie_layers.h:58
This class represents a quantization operation layer Element-wise linear quantization of floating poi...
Definition: ie_layers.h:1657
unsigned int _out_depth
A number of output feature maps (size) generating the 3'rd output dimension.
Definition: ie_layers.h:729
MVNLayer(const LayerParams &prms)
A default constructor. Creates a new MVNLayer instance and initializes layer parameters with the give...
Definition: ie_layers.h:907
This class represents a Rectified Linear activation layer.
Definition: ie_layers.h:923
This class represents a standard 3D Convolution Layer.
Definition: ie_layers.h:510
CellType
Direct type of recurrent cell (including subtypes) Description of particular cell semantics is in LST...
Definition: ie_layers.h:1131
std::string _auto_pad
Auto padding type.
Definition: ie_layers.h:637
std::string _auto_pad
Auto padding type.
Definition: ie_layers.h:737
This class represents a standard Pad layer Adds paddings to input tensor.
Definition: ie_layers.h:1422
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:1054
This class represents a standard binary convolution layer.
Definition: ie_layers.h:681
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:519
This class represents a standard Squeeze layer Squeeze modifies input tensor dimensions according par...
Definition: ie_layers.h:1593
Blob::Ptr _biases
A pointer to a biases blob.
Definition: ie_layers.h:491
This class represents a Linear Response Normalization (LRN) Layer.
Definition: ie_layers.h:835
This class represents TensorIterator layer.
Definition: ie_layers.h:1091
This class represents concatenation layer Takes as input several data elements and merges them to one...
Definition: ie_layers.h:801
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 class represents a standard Expand layer Expand modifies input tensor dimensions according param...
Definition: ie_layers.h:1645
This class represents a standard RangeLayer layer RangeLayer modifies input tensor dimensions accordi...
Definition: ie_layers.h:1619
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:1101
std::string affinity
Layer affinity set by user.
Definition: ie_layers.h:78
This class represents a standard pooling layer.
Definition: ie_layers.h:594
PropertyVector< unsigned int > _stride
A convolution strides array [X, Y, Z, ...].
Definition: ie_layers.h:721
Definition: ie_layers.h:1093
This class represents a standard Gather layer Gather slices from Dictionary according to Indexes...
Definition: ie_layers.h:1458
Definition: ie_layers.h:1134
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:432
This class represents a standard Unsqueeze layer Unsqueeze modifies input tensor dimensions according...
Definition: ie_layers.h:1606
std::string new_axis_mask
The new_axis_mask_ is a bitmask where bit i being 1 means the i-th position creates a new 1 dimension...
Definition: ie_layers.h:1494
PropertyVector< unsigned int > _padding
A convolution paddings begin array [X, Y, Z, ...].
Definition: ie_layers.h:515
std::map< std::string, Blob::Ptr > blobs
Map of pairs: (name, weights/biases blob)
Definition: ie_layers.h:465
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:405
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
eBinaryConvolutionMode
Defines possible modes of binary convolution operation.
Definition: ie_layers.h:687
int from
Definition: ie_layers.h:1095
bool CheckParamPresence(const char *param) const
Checks the param presence in the layer.
Definition: ie_layers.h:418
This class represents a standard Depth To Space layer Depth To Space picks from input tensor accordin...
Definition: ie_layers.h:1534
This class represents a general matrix multiplication operation layer Formula is: dst := alpha*src1*s...
Definition: ie_layers.h:1394
int axis
Definition: ie_layers.h:1099
std::vector< int > dim
A vector of dimensions to be preserved.
Definition: ie_layers.h:1015
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:548
This class holds precision value and provides precision related operations.
Definition: ie_precision.hpp:19