class InferenceEngine::CNNLayer

Overview

This is a base abstraction Layer - all DNN Layers inherit from this class. More…

#include <ie_layers.h>

class CNNLayer
{
public:
    // typedefs

    typedef std::shared_ptr<CNNLayer> Ptr;

    // fields

    std::string name;
    std::string type;
    Precision precision;
    std::vector<DataPtr> outData;
    std::vector<DataWeakPtr> insData;
    Ptr _fusedWith;
    UserValue userValue;
    std::string affinity;
    std::map<std::string, std::string> params;
    std::map<std::string, Blob::Ptr> blobs;

    // construction

    CNNLayer(const LayerParams& prms);
    CNNLayer(const CNNLayer& other);

    // methods

    std::shared_ptr<ngraph::Node> getNode() const;
    void fuse(Ptr& layer);
    virtual const DataPtr input() const;
    void parseParams();
    float GetParamAsFloat(const char \* param, float def) const;
    float GetParamAsFloat(const char \* param) const;
    std::vector<float> GetParamAsFloats(const char \* param, std::vector<float> def) const;
    std::vector<float> GetParamAsFloats(const char \* param) const;
    int GetParamAsInt(const char \* param, int def) const;
    int GetParamAsInt(const char \* param) const;
    std::vector<int> GetParamAsInts(const char \* param, std::vector<int> def) const;
    std::vector<int> GetParamAsInts(const char \* param) const;
    unsigned int GetParamAsUInt(const char \* param, unsigned int def) const;
    unsigned int GetParamAsUInt(const char \* param) const;
    size_t GetParamAsSizeT(const char \* param, size_t def) const;
    size_t GetParamAsSizeT(const char \* param) const;

    std::vector<unsigned int> GetParamAsUInts(
        const char \* param,
        std::vector<unsigned int> def
        ) const;

    std::vector<unsigned int> GetParamAsUInts(const char \* param) const;
    bool GetParamAsBool(const char \* param, bool def) const;
    bool GetParamAsBool(const char \* param) const;
    std::string GetParamAsString(const char \* param, const char \* def) const;
    bool CheckParamPresence(const char \* param) const;
    std::string GetParamAsString(const char \* param) const;
    std::string getBoolStrParamAsIntStr(const char \* param) const;

    std::vector<std::string> GetParamAsStrings(
        const char \* param,
        std::vector<std::string> def
        ) const;

    static float ie_parse_float(const std::string& str);
    static std::string ie_serialize_float(float value);
};

// direct descendants

class BatchToSpaceLayer;
class BroadcastLayer;
class BucketizeLayer;
class ClampLayer;
class ConcatLayer;
class CropLayer;
class DepthToSpaceLayer;
class EltwiseLayer;
class ExperimentalDetectronGenerateProposalsSingleImageLayer;
class ExperimentalDetectronPriorGridGeneratorLayer;
class ExperimentalDetectronTopKROIs;
class ExperimentalSparseWeightedReduceLayer;
class FillLayer;
class GRNLayer;
class GatherLayer;
class GemmLayer;
class MVNLayer;
class MathLayer;
class NonMaxSuppressionLayer;
class NormLayer;
class OneHotLayer;
class PadLayer;
class PoolingLayer;
class PowerLayer;
class QuantizeLayer;
class RangeLayer;
class ReLULayer;
class ReduceLayer;
class ReshapeLayer;
class ReverseSequenceLayer;
class ScatterElementsUpdateLayer;
class ScatterUpdateLayer;
class SelectLayer;
class ShuffleChannelsLayer;
class SoftMaxLayer;
class SpaceToBatchLayer;
class SpaceToDepthLayer;
class SparseFillEmptyRowsLayer;
class SparseSegmentReduceLayer;
class SparseToDenseLayer;
class SplitLayer;
class StridedSliceLayer;
class TensorIterator;
class TileLayer;
class TopKLayer;
class UniqueLayer;
class WeightableLayer;

Detailed Documentation

This is a base abstraction Layer - all DNN Layers inherit from this class.

Deprecated Migrate to IR v10 and work with ngraph::Function directly. The method will be removed in 2021.1

Typedefs

typedef std::shared_ptr<CNNLayer> Ptr

A shared pointer to CNNLayer.

Fields

std::string name

Layer name.

std::string type

Layer type.

Precision precision

Layer base operating precision.

std::vector<DataPtr> outData

A vector of pointers to the output data elements of this layer in the di-graph (order matters)

std::vector<DataWeakPtr> insData

A vector of weak pointers to the input data elements of this layer in the di-graph (order matters)

Ptr _fusedWith

If suggested to fuse - a pointer to the layer which needs to be fused with this layer.

UserValue userValue

Convenience user values to store in this object as extra data.

std::string affinity

Layer affinity set by user.

std::map<std::string, std::string> params

Map of pairs: (parameter name, parameter value)

std::map<std::string, Blob::Ptr> blobs

Map of pairs: (name, weights/biases blob)

Construction

CNNLayer(const LayerParams& prms)

A constructor. Creates a new CNNLayer instance and initializes layer parameters with the given values.

Parameters:

prms

Basic common parsing parameters

CNNLayer(const CNNLayer& other)

A copy constructor.

Parameters:

other

An object to copy

Methods

std::shared_ptr<ngraph::Node> getNode() const

Returns the original nGraph op.

Returns:

A smart pointer to nGraph op

void fuse(Ptr& layer)

Sets a layer to be fused with.

Parameters:

layer

Reference to the layer to be fused with

virtual const DataPtr input() const

Returns the first element of the input data for this layer.

Returns:

A smart pointer to the input data element

void parseParams()

Checks if the input data and layer data are legitimate.

float GetParamAsFloat(const char \* param, float def) const

Gets float value for the given parameter.

Parameters:

param

name of the parameter to find

def

default value of the parameter if not found

Returns:

float value

float GetParamAsFloat(const char \* param) const

Returns a float value for the given layer parameter.

Parameters:

param

Name of the layer parameter

Returns:

A float value for the specified parameter

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.

Parameters:

param

Name of the layer parameter

def

Default value of the parameter if not found

Returns:

vector of float values

std::vector<float> GetParamAsFloats(const char \* param) const

Returns a vector of float values for the given parameter.

Parameters:

param

Name of the layer parameter

Returns:

vector of float values

int GetParamAsInt(const char \* param, int def) const

Returns an integer value for the given parameter or returns the default value.

Parameters:

param

Name of the layer parameter

def

Default value of the parameter if not found

Returns:

An int value for the specified parameter

int GetParamAsInt(const char \* param) const

Returns an integer value for the given parameter.

Parameters:

param

Name of the layer parameter

Returns:

An int value for the specified parameter

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.

Parameters:

param

Name of the layer parameter

def

Default value of the parameter if not found

Returns:

vector of int values

std::vector<int> GetParamAsInts(const char \* param) const

Returns a vector of int values for the given parameter.

Parameters:

param

Name of the layer parameter

Returns:

vector of int values

unsigned int GetParamAsUInt(const char \* param, unsigned int def) const

Returns an unsigned integer value for the given parameter or returns the default value.

Parameters:

param

Name of the layer parameter

def

Default value of the parameter if not found

Returns:

An unsigned integer value for the specified parameter

unsigned int GetParamAsUInt(const char \* param) const

Returns an unsigned integer value for the given parameter.

Parameters:

param

Name of the layer parameter

Returns:

An unsigned integer value for the specified parameter

size_t GetParamAsSizeT(const char \* param, size_t def) const

Returns an size_t value for the given parameter or returns the default value.

Parameters:

param

Name of the layer parameter

def

Default value of the parameter if not found

Returns:

An size_t value for the specified parameter

size_t GetParamAsSizeT(const char \* param) const

Returns an size_t value for the given parameter.

Parameters:

param

Name of the layer parameter

Returns:

An size_t value for the specified parameter

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.

Parameters:

param

Name of the layer parameter

def

Default value of the parameter if not found

Returns:

vector of unsigned int values

std::vector<unsigned int> GetParamAsUInts(const char \* param) const

Returns a vector of unsigned int values for the given parameter.

Parameters:

param

Name of the layer parameter

Returns:

vector of unsigned int values

bool GetParamAsBool(const char \* param, bool def) const

Returns a boolean value for the given parameter.

The valid values are (true, false, 1, 0).

Parameters:

param

Name of the layer parameter

def

Default value of the parameter if not found

Returns:

A bool value for the specified parameter

bool GetParamAsBool(const char \* param) const

Returns a boolean value for the given parameter.

Parameters:

param

Name of the layer parameter

Returns:

A bool value for the specified parameter

std::string GetParamAsString(const char \* param, const char \* def) const

Returns a string value for the given parameter or returns the default one.

Parameters:

param

Name of the layer parameter

def

Default value of the parameter if not found

Returns:

A string value

bool CheckParamPresence(const char \* param) const

Checks the param presence in the layer.

Parameters:

param

Name of the layer parameter

Returns:

a bool depending param presence

std::string GetParamAsString(const char \* param) const

Returns a string value for the given parameter.

Throws exception if parameter was not found.

Parameters:

param

Name of the layer parameter

Returns:

A string value

std::string getBoolStrParamAsIntStr(const char \* param) const

Returns a string containing an integer if parameters value was “true” or “false”.

Parameters:

param

Name of the layer parameter

Returns:

A string containing an integer or the parameter as string

std::vector<std::string> GetParamAsStrings(
    const char \* param,
    std::vector<std::string> def
    ) const

Gets the parameter as a std::vector<std::string>

Parameters:

param

The parameter name

def

The default values if case of parameter is not found

Returns:

The parameter as strings.

static float ie_parse_float(const std::string& str)

Parse string with float in accordance with IE rules.

Parameters:

str

input string with float value

Exception

in case of parsing error

Returns:

float value if parsing was successful

static std::string ie_serialize_float(float value)

serialize float with c_locale formating used for default values serializing