Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::ITensor Class Referenceabstractexport

Abstract interface providing essential tensor information and data access. More...

Inheritance diagram for Mila::Dnn::ITensor:

Public Member Functions

virtual ~ITensor ()=default
virtual size_t elementSize () const =0
 Get the size in bytes of a single tensor element.
virtual TensorDataType getDataType () const =0
 Get tensor element data type identifier.
virtual std::string getDataTypeName () const =0
 Get human-readable name of the tensor's data type.
virtual Compute::DeviceId getDeviceId () const =0
virtual Compute::DeviceType getDeviceType () const =0
 Get the device type from the memory resource.
virtual Compute::MemoryResourcegetMemoryResource () const =0
 Get the memory resource managing this tensor's storage.
virtual std::string getName () const =0
 Returns the tensor's optional user-assigned name.
virtual size_t getStorageSize () const =0
 Get the total storage size in bytes backing the tensor's buffer.
virtual std::string getUId () const =0
 Returns the tensor's unique identifier.
virtual bool isScalar () const noexcept=0
 Check if the tensor is a scalar (rank 0).
template<typename T>
bool isType () const
 Type-safe check for tensor element type.
virtual bool isView () const =0
 Check if this tensor is a view of another tensor's data.
virtual const void * rawData () const =0
 Get raw pointer to tensor data (const version).
virtual void * rawData ()=0
 Get raw pointer to tensor data.
virtual const shape_tshape () const =0
 Get the tensor dimensional structure.
virtual size_t size () const =0
 Get total number of elements in the tensor.

Detailed Description

Abstract interface providing essential tensor information and data access.

ITensor serves as a type-erased interface for accessing tensor data regardless of the specific element type or memory resource implementation. This interface enables polymorphic access to tensor properties and data, making it possible to write generic code that works with different tensor implementations.

Memory access levels:

  • Public Tensor::data() : Type-safe, host-accessible tensors only.
  • Protected rawData() : Type-erased void pointer for TensorOps implementations.
  • Device kernels : Raw pointers passed as kernel parameters (not through this interface).
See also
Tensor
Examples
/__w/Mila/Mila/Mila/Src/Dnn/Components/Normalization/Softmax.ixx.

Constructor & Destructor Documentation

◆ ~ITensor()

virtual Mila::Dnn::ITensor::~ITensor ( )
virtualdefault

Member Function Documentation

◆ elementSize()

◆ getDataType()

◆ getDataTypeName()

◆ getDeviceId()

◆ getDeviceType()

◆ getMemoryResource()

◆ getName()

◆ getStorageSize()

◆ getUId()

◆ isScalar()

◆ isType()

template<typename T>
bool Mila::Dnn::ITensor::isType ( ) const
inline

Type-safe check for tensor element type.

Template Parameters
TThe element type to check against.
Returns
true if the tensor's elements are of type T.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isView()

◆ rawData() [1/2]

◆ rawData() [2/2]

◆ shape()

◆ size()


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