A model of a tensor.
More...
#include <iolink/view/tensor/TensorView.h>
|
|
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 VectorXu64 & | shape () 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 ®ion, void *dst) const |
| | Read data from a given region into a destination buffer.
|
| |
| template<typename T > |
| T | at (const VectorXu64 &index) const |
| | Get data from a specific index in the tensor.
|
| |
| virtual void | write (const RegionXu64 ®ion, 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 Indexer & | indexer () 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.
|
| |
| virtual std::shared_ptr< Extension > | extension (size_t id) |
| | Get an extension of the view, corresponding to the given identifier.
|
| |
| template<typename T > |
| std::shared_ptr< T > | extension () |
| | Get an extension of the view, corresponding to the given type.
|
| |
|
std::shared_ptr< ViewOriginExtension > | viewOrigin () |
| | Shortcut to access to ViewOrigin extension.
|
| |
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.
◆ at()
template<typename T >
| T iolink::TensorView::at |
( |
const VectorXu64 & |
index | ) |
const |
|
inline |
Get data from a specific index in the tensor.
- Template Parameters
-
| T | The type of the data to read from the tensor. |
- Parameters
-
| index | The 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()
◆ 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
-
| region | The region of the tensor to read from. |
| dst | The destination buffer where the read data will be copied. |
- Exceptions
-
◆ setAt()
template<typename T >
| void iolink::TensorView::setAt |
( |
const VectorXu64 & |
index, |
|
|
T |
value |
|
) |
| |
|
inline |
Set a value at a specific index in the tensor.
- Template Parameters
-
| T | The type of the value to set in the tensor. |
- Parameters
-
| index | The index of the tensor element to set. |
| value | The 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()
Shortcut to check if capabilities are supported by the tensor.
- Parameters
-
| capabilities | The 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
-
| region | The region of the tensor to write to. |
| src | The source buffer containing the data that will be written. |
- Exceptions
-
The documentation for this class was generated from the following file: