TensorData Class Reference

TensorData Class Reference#

3 min read time

Applies to Linux

rocCV: roccv::TensorData Class Reference

Holds the underlying tensor data alongside metadata (shape, layout, datatype). Non-strided tensor data is not supported for use right now, use TensorDataStrided to use strided tensor data instead. More...

#include <tensor_data.hpp>

Inheritance diagram for roccv::TensorData:
roccv::TensorDataStrided

Public Member Functions

virtual void * basePtr () const
 Returns the base pointer of the tensor data in memory. More...
 
template<typename Derived >
std::optional< Derived > cast ()
 
virtual const eDeviceType device () const
 Retrieves the location where the tensor data is allocated, either on the device or the host. More...
 
virtual const DataTypedtype () const
 Retrieves the data type of the tensor's elements. More...
 
virtual int rank () const
 Returns the rank (the number of dimensions) of the tensor data. More...
 
virtual const TensorShapeshape () const &
 Returns the shape of the tensor. More...
 
virtual const int64_t shape (int d) const &
 Retrieves a specific dimension size from the tensor shape. More...
 
 TensorData ()=delete
 
virtual ~TensorData ()=default
 

Protected Member Functions

 TensorData (const TensorShape &tshape, const DataType &dtype, const TensorBufferStrided &buffer, const eDeviceType device=eDeviceType::GPU)
 

Protected Attributes

TensorBufferStrided m_buffer
 
eDeviceType m_deviceType
 
DataType m_dtype
 
TensorShape m_shape
 

Detailed Description

Holds the underlying tensor data alongside metadata (shape, layout, datatype). Non-strided tensor data is not supported for use right now, use TensorDataStrided to use strided tensor data instead.

Constructor & Destructor Documentation

◆ TensorData() [1/2]

roccv::TensorData::TensorData ( )
delete

◆ ~TensorData()

virtual roccv::TensorData::~TensorData ( )
virtualdefault

◆ TensorData() [2/2]

roccv::TensorData::TensorData ( const TensorShape tshape,
const DataType dtype,
const TensorBufferStrided buffer,
const eDeviceType  device = eDeviceType::GPU 
)
protected

Member Function Documentation

◆ basePtr()

virtual void* roccv::TensorData::basePtr ( ) const
virtual

Returns the base pointer of the tensor data in memory.

Returns
A pointer to the tensor data in memory.

◆ cast()

template<typename Derived >
std::optional<Derived> roccv::TensorData::cast ( )
inline

◆ device()

virtual const eDeviceType roccv::TensorData::device ( ) const
virtual

Retrieves the location where the tensor data is allocated, either on the device or the host.

Returns
An enum representing the data location of this tensor data.

◆ dtype()

virtual const DataType& roccv::TensorData::dtype ( ) const
virtual

Retrieves the data type of the tensor's elements.

Returns
The data type of the tensor's elements.

◆ rank()

virtual int roccv::TensorData::rank ( ) const
virtual

Returns the rank (the number of dimensions) of the tensor data.

Returns
the rank of the tensor

◆ shape() [1/2]

virtual const TensorShape& roccv::TensorData::shape ( ) const &
virtual

Returns the shape of the tensor.

Returns
const TensorShape&

◆ shape() [2/2]

virtual const int64_t roccv::TensorData::shape ( int  d) const &
virtual

Retrieves a specific dimension size from the tensor shape.

Parameters
[in]dThe index of the dimension.
Returns
The size of the specified dimension.

Member Data Documentation

◆ m_buffer

TensorBufferStrided roccv::TensorData::m_buffer
protected

◆ m_deviceType

eDeviceType roccv::TensorData::m_deviceType
protected

◆ m_dtype

DataType roccv::TensorData::m_dtype
protected

◆ m_shape

TensorShape roccv::TensorData::m_shape
protected

The documentation for this class was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/core/tensor_data.hpp