class InferenceEngine::TensorDesc

Overview

This class defines Tensor description. More…

#include <ie_layouts.h>

class TensorDesc
{
public:
    // construction

    TensorDesc(
        const Precision& precision,
        const SizeVector& dims,
        const BlockingDesc& blockDesc
        );

    TensorDesc(const Precision& precision, const SizeVector& dims, Layout layout);
    TensorDesc(const Precision& precision, Layout layout);
    TensorDesc();

    // methods

    void reshape(const SizeVector& dims, Layout layout = Layout::ANY);
    void reshape(const SizeVector& dims, const BlockingDesc& blockDesc);
    SizeVector& getDims();
    const SizeVector& getDims() const;
    void setDims(const SizeVector& dims);
    Layout getLayout() const;
    void setLayout(Layout l);
    const Precision& getPrecision() const;
    void setPrecision(const Precision& p);
    const BlockingDesc& getBlockingDesc() const;
    bool operator == (const TensorDesc& rhs) const;
    bool operator != (const TensorDesc& rhs) const;
    size_t offset(const SizeVector& v) const;
    size_t offset(size_t l) const;
    static Layout getLayoutByDims(const SizeVector& dims);
    static Layout getLayoutByRank(size_t rank);
};

Detailed Documentation

This class defines Tensor description.

Construction

TensorDesc(
    const Precision& precision,
    const SizeVector& dims,
    const BlockingDesc& blockDesc
    )

The constructor creates the tensor descriptor using blocking descriptor.

Parameters:

precision

memory precision

dims

memory dimensions

blockDesc

blocking descriptor

TensorDesc(const Precision& precision, const SizeVector& dims, Layout layout)

The constructor creates the tensor descriptor using standard layout.

Parameters:

precision

memory precision

dims

memory dimensions

layout

memory layout

TensorDesc(const Precision& precision, Layout layout)

The constructor creates the empty tensor descriptor with precision and layout.

Parameters:

precision

memory precision

layout

memory layout

TensorDesc()

The default constructor which creates empty tensor descriptor.

Methods

void reshape(const SizeVector& dims, Layout layout = Layout::ANY)

Reshapes the tensor descriptor.

Parameters:

dims

new dimensions

layout

new layout if it is necessary

void reshape(const SizeVector& dims, const BlockingDesc& blockDesc)

Reshapes the tensor descriptor.

Parameters:

dims

new dimensions

blockDesc

new blocking descriptor

SizeVector& getDims()

Returns the vector of dimensions.

Returns:

dimensions

const SizeVector& getDims() const

Returns the constant vector of dimensions.

Returns:

dimensions

void setDims(const SizeVector& dims)

Sets dimensions.

Parameters:

dims

new dimensions

Layout getLayout() const

Returns the memory layout.

Returns:

layout

void setLayout(Layout l)

Sets the layout.

Parameters:

l

memory layout

const Precision& getPrecision() const

Returns the memory precision.

Returns:

precision

void setPrecision(const Precision& p)

Sets the memory precision.

Parameters:

p

precision

const BlockingDesc& getBlockingDesc() const

Returns the blocking descriptor.

Returns:

blocking descriptor

bool operator == (const TensorDesc& rhs) const

The comparison operator for the TensorDesc.

Parameters:

rhs

object to compare

Returns:

true if objects are equal

bool operator != (const TensorDesc& rhs) const

The comparison operator for the TensorDesc.

Parameters:

rhs

object to compare

Returns:

true if objects aren’t equal

size_t offset(const SizeVector& v) const

Calculates offset for the vector of dimensions.

Parameters:

v

vector of dimensions

Returns:

offset

size_t offset(size_t l) const

Calculates offset for the local offset.

Parameters:

l

local offset

Returns:

offset

static Layout getLayoutByDims(const SizeVector& dims)

Returns the standard layout for dimensions.

Parameters:

dims

the vector of dimensions

Returns:

the standard memory layout

static Layout getLayoutByRank(size_t rank)

Returns the standard layout for the specified tensor rank.

Parameters:

rank

of the requested layout

Returns:

the standard memory layout