IOLink 1.16.1
Loading...
Searching...
No Matches
iolink::TensorView Class Referenceabstract

A model of a tensor. More...

#include <iolink/view/tensor/TensorView.h>

Inheritance diagram for iolink::TensorView:
iolink::View

Public Member Functions

virtual ~TensorView ()=default
 Virtual destructor to support polymorphism.
 
virtual TensorCapabilitySet capabilities () const =0
 Get the capabilities of the tensor.
 
bool support (TensorCapabilitySet capabilities) const
 Shortcut to check if capabilities are supported by the tensor.
 
virtual const VectorXu64shape () const =0
 Get the shape of the tensor.
 
size_t dimensionCount () const
 Shortcut to get the number of dimensions of the tensor.
 
virtual DataType dtype () const =0
 Get the data type of the tensor.
 
std::string toString () const
 Return a string representation.
 
virtual void read (const RegionXu64 &region, void *dst) const
 Read data from a given region into a destination buffer.
 
template<typename T >
at (const VectorXu64 &index) const
 Get data from a specific index in the tensor.
 
virtual void write (const RegionXu64 &region, const void *src)
 Write data from a source buffer into a given region of the tensor.
 
template<typename T >
void setAt (const VectorXu64 &index, T value)
 Set a value at a specific index in the tensor.
 
virtual void reshape (const VectorXu64 &shape, DataType dtype)
 
virtual const Indexerindexer () const
 Get the indexer for the tensor underlying buffer.
 
virtual size_t bufferSize () const
 Get the size in bytes of the underlying buffer.
 
virtual void * buffer ()
 Get a mutable pointer to the underlying memory buffer.
 
virtual const void * buffer () const
 Get an immutable pointer to the underlying memory buffer.
 

Detailed Description

A model of a tensor.

Tensors are simple multidimensional arrays that can be used to represent data in a structured way. They can be used to represent images, audio, text, or any other type of data that can be represented as a multidimensional array.

Member Function Documentation

◆ at()

template<typename T >
T iolink::TensorView::at ( const VectorXu64 index) const
inline

Get data from a specific index in the tensor.

Template Parameters
TThe type of the data to read from the tensor.
Parameters
indexThe index of the tensor element to read.
Returns
The value at the specified index
Warning
No verification is made to check if the template type suits the tensor's data type, so use this method only when you're absolutely sure that the type matches the tensor's data type.

◆ buffer() [1/2]

virtual void * iolink::TensorView::buffer ( )
virtual

Get a mutable pointer to the underlying memory buffer.

Returns
A pointer to the tensor's underlying memory buffer, allowing direct access to the data.

◆ buffer() [2/2]

virtual const void * iolink::TensorView::buffer ( ) const
virtual

Get an immutable pointer to the underlying memory buffer.

Returns
A pointer to the tensor's underlying memory buffer, allowing read-only access.

◆ bufferSize()

virtual size_t iolink::TensorView::bufferSize ( ) const
virtual

Get the size in bytes of the underlying buffer.

Returns
The size in bytes of the tensor's underlying memory buffer.

◆ capabilities()

virtual TensorCapabilitySet iolink::TensorView::capabilities ( ) const
pure virtual

Get the capabilities of the tensor.

Returns
A set of capabilities that the tensor supports.
See also
TensorCapability
TensorCapabilitySet

◆ dimensionCount()

size_t iolink::TensorView::dimensionCount ( ) const
inline

Shortcut to get the number of dimensions of the tensor.

Returns
The number of dimensions of the tensor, which is equal to the size of the shape vector.

◆ dtype()

virtual DataType iolink::TensorView::dtype ( ) const
pure virtual

Get the data type of the tensor.

Returns
The data type of the tensor, which describes the type of elements stored in the tensor.

◆ indexer()

virtual const Indexer & iolink::TensorView::indexer ( ) const
virtual

Get the indexer for the tensor underlying buffer.

Returns
An Indexer that describes the memory layout of the tensor's data.

◆ read()

virtual void iolink::TensorView::read ( const RegionXu64 region,
void *  dst 
) const
virtual

Read data from a given region into a destination buffer.

Parameters
regionThe region of the tensor to read from.
dstThe destination buffer where the read data will be copied.
Exceptions
NotImplementedIf the implementation does not support reading.
InvalidArgumentIf the region is not compatible with the tensor's shape.

◆ setAt()

template<typename T >
void iolink::TensorView::setAt ( const VectorXu64 index,
value 
)
inline

Set a value at a specific index in the tensor.

Template Parameters
TThe type of the value to set in the tensor.
Parameters
indexThe index of the tensor element to set.
valueThe value to set at the specified index.
Warning
No verification is made to check if the template type suits the tensor's data type, so use this method only when you're absolutely sure that the type matches the tensor's data type.

◆ shape()

virtual const VectorXu64 & iolink::TensorView::shape ( ) const
pure virtual

Get the shape of the tensor.

Returns
A vector representing the shape of the tensor, where each element corresponds to the size of the tensor along that dimension.

◆ support()

bool iolink::TensorView::support ( TensorCapabilitySet  capabilities) const
inline

Shortcut to check if capabilities are supported by the tensor.

Parameters
capabilitiesThe set of capabilities to check.
Returns
true if the tensor supports the given capabilities, false otherwise.

◆ write()

virtual void iolink::TensorView::write ( const RegionXu64 region,
const void *  src 
)
virtual

Write data from a source buffer into a given region of the tensor.

Parameters
regionThe region of the tensor to write to.
srcThe source buffer containing the data that will be written.
Exceptions
NotImplementedIf the implementation does not support writing.
InvalidArgumentIf the region is not compatible with the tensor's shape.

The documentation for this class was generated from the following file: