class dlstreamer::BaseTensor#

Overview#

#include <tensor.h>

class BaseTensor: public dlstreamer::Tensor {
public:
    // construction

    BaseTensor(
        MemoryType memory_type,
        const TensorInfo& info,
        std::string_view primary_key = {},
        ContextPtr context = nullptr
    );

    // methods

    virtual MemoryType memory_type() const;
    virtual void* data() const;
    virtual handle_t handle(std::string_view key) const;
    virtual handle_t handle(std::string_view key, handle_t default_value) const;
    virtual const TensorInfo& info() const;
    virtual ContextPtr context() const;
    virtual TensorPtr parent() const;
    void set_parent(TensorPtr parent);
    void set_handle(const std::string& key, handle_t handle);
};

// direct descendants

class CPUTensor;
class DMATensor;
class GSTTensor;
class OpenCLTensor;
class OpenCVTensor;
class OpenCVUMatTensor;
class OpenVINOTensor;
class SYCLUSMTensor;
class USMTensor;
class VAAPITensor;

Inherited Members#

public:
    // typedefs

    typedef intptr_t handle_t;

    // methods

    Tensor& operator = (const Tensor&);
    virtual const TensorInfo& info() const = 0;
    virtual MemoryType memory_type() const = 0;
    virtual ContextPtr context() const = 0;
    virtual void* data() const = 0;
    virtual handle_t handle(std::string_view key = {}) const = 0;
    virtual handle_t handle(std::string_view key, handle_t default_value) const = 0;
    virtual TensorPtr parent() const = 0;

    template <typename T>
    T* data() const;

    template <typename T>
    T* data(
        std::vector<size_t> offset,
        bool left_offset = true
    ) const;

Detailed Documentation#

Methods#

virtual MemoryType memory_type() const

Returns tensor’s memory type.

virtual void* data() const

Returns pointer to tensor data. If underlying memory allocation relies on abstract memory handle (for example, cl_mem), this function returns nullptr.

virtual handle_t handle(std::string_view key) const

Returns a handle by key. If empty key, returns default handle. If no handle with the specified key, exception is thrown.

Parameters:

key

the key of the handle to find

virtual handle_t handle(std::string_view key, handle_t default_value) const

Returns a handle by key. If empty key, returns default handle. If no handle with the specified key, return default value specified in function parameter.

Parameters:

key

the key of the handle to find

default_value

default value

virtual const TensorInfo& info() const

Returns tensor information - data type, shape, stride.

Parameters:

key

the key of the handle to find

virtual ContextPtr context() const

Returns context used to create tensor. The context() -> memory_type() returns same type as memory_type(). Function may return nullptr if tensor created without context, for example CPU-memory tensor.

virtual TensorPtr parent() const

Returns parent tensor if this tensor was mapped (using MemoryMapper) from another tensor or contains sub-region of another tensor, otherwise returns nullptr.