struct dlstreamer::TensorInfo#

Overview#

Structure contaning tensor information - data type, shape, stride. More…

#include <tensor_info.h>

struct TensorInfo {
    // fields

    std::vector<size_t> shape;
    std::vector<size_t> stride;
    DataType dtype;

    // construction

    TensorInfo();

    TensorInfo(
        std::vector<size_t> _shape,
        DataType _dtype = DataType::UInt8,
        std::vector<size_t> _stride = {}
    );

    // methods

    size_t size() const;
    size_t itemsize() const;
    size_t nbytes() const;
    bool is_contiguous() const;
    bool operator < (const TensorInfo& r) const;
    bool operator == (const TensorInfo& r) const;
    bool operator != (const TensorInfo& r) const;
};

Detailed Documentation#

Structure contaning tensor information - data type, shape, stride.

Construction#

TensorInfo(
    std::vector<size_t> _shape,
    DataType _dtype = DataType::UInt8,
    std::vector<size_t> _stride = {}
)

If stride array is empty in constructor parameter, stride will be created automatically assuming contiguous memory layout without padding.

Methods#

size_t size() const

Return number elements in tensor - multiplication of all dimensions in tensor shape.

size_t itemsize() const

Returns number bytes consumed by one element.

size_t nbytes() const

Return number bytes required to store tensor data in memory buffer.

bool is_contiguous() const

Return true if strides set to contiguous memory layout without padding.