Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Tensor< TDataType, TMemoryResource > Class Template Referenceexport
module Dnn.Tensor

Device-aware N-dimensional tensor. More...

Inheritance diagram for Mila::Dnn::Tensor< TDataType, TMemoryResource >:
Collaboration diagram for Mila::Dnn::Tensor< TDataType, TMemoryResource >:

Public Types

using DataType = TensorDataType
 Abstract data type enumeration.
using DataTypeTraits = TensorDataTypeTraits<TDataType>
 Compile-time data type characteristics.
using host_value_t = std::conditional_t<TensorDataTypeTraits<TDataType>::is_integer_type, int32_t, float>
 Host value type for scalars.
using MemoryResource = TMemoryResource
 Memory resource type for this tensor.

Public Member Functions

 Tensor (Compute::DeviceId device_id, const shape_t &shape, std::string name={})
 Creates a tensor bound to the specified device id and shape.
 Tensor (const Tensor &other)=delete
 Copy constructor - explicitly deleted for performance safety.
 Tensor (Tensor &&other) noexcept
 Efficiently transfers ownership from another tensor.
 ~Tensor ()=default
 Destructor with automatic resource cleanup via RAII.
constexpr const auto * data () const noexcept
 Returns type-safe immutable pointer to tensor data with concrete host type.
constexpr auto * data () noexcept
 Returns type-safe pointer to tensor data with concrete host type.
size_t elementSize () const override
 Returns the size in bytes of a single tensor element.
bool empty () const
 Checks if the tensor contains no elements.
Tensor< TDataType, TMemoryResource > & flatten ()
 Flattens tensor to 2D shape in-place.
TensorDataType getDataType () const override
 Returns the tensor's abstract data type identifier.
std::string getDataTypeName () const override
 Returns human-readable name of the tensor's data type.
Compute::DeviceId getDeviceId () const override
Compute::DeviceType getDeviceType () const override
 Returns the device type of this tensor's memory resource.
Compute::MemoryResourcegetMemoryResource () const override
 Returns pointer to the memory resource managing this tensor's storage.
std::string getName () const override
 Returns the tensor's optional user-assigned name.
size_t getStorageSize () const override
 Returns the total storage size in bytes backing the tensor's buffer.
std::string getUId () const override
 Returns the tensor's unique identifier.
bool isScalar () const noexcept override
 Checks if tensor is a scalar (0-dimensional).
bool isValid () const noexcept
 Check if tensor is in a valid state (not moved-from).
bool isView () const override
 Check if this tensor is a view of another tensor's data.
auto & item ()
 Gets the scalar value for 0-dimensional tensors.
const auto & item () const
 Gets the scalar value for 0-dimensional tensors (const version).
Tensoroperator= (const Tensor &other)=delete
 Copy assignment operator - explicitly deleted.
Tensoroperator= (Tensor &&other) noexcept
 Efficiently moves resources from another tensor.
auto & operator[] (const index_t &indices)
 Accesses tensor element using multi-dimensional indices.
const auto & operator[] (const index_t &indices) const
 Accesses tensor element using multi-dimensional indices (const version).
template<typename... Indices>
requires TMemoryResource::is_host_accessible
auto & operator[] (Indices... indices) &&(std
 Variadic index access (non-const).
template<typename... Indices>
requires TMemoryResource::is_host_accessible
const auto & operator[] (Indices... indices) const &&(std
 Variadic index access (const).
size_t rank () const
 Returns the number of dimensions in the tensor.
const void * rawData () const override
 Returns raw pointer to tensor data (const version).
void * rawData () override
 Returns raw pointer to tensor data (implements ITensor protected API).
void reshape (const shape_t &new_shape)
 Modifies tensor shape while preserving total element count.
void setName (const std::string &value)
 Assigns a descriptive name to the tensor.
const shape_tshape () const override
 Returns the tensor's dimensional shape vector.
size_t size () const override
 Returns the total number of logical elements in the tensor.
const stride_tstrides () const
 Returns the tensor's memory stride information.
std::string toString (bool showBuffer=false) const
 Generates string representation of the tensor.
Tensor view (const shape_t &new_shape, size_t offset=0) const
Public Member Functions inherited from Mila::Dnn::ITensor
virtual ~ITensor ()=default
template<typename T>
bool isType () const
 Type-safe check for tensor element type.

Static Public Member Functions

static constexpr bool is_device_accessible ()
 Checks if tensor data is accessible from device (GPU) code.
static constexpr bool is_host_accessible ()
 Checks if tensor data is accessible from host (CPU) code.

Private Member Functions

 Tensor (const Tensor &parent, const shape_t &shape, size_t offset)
void allocateBuffer ()
 Allocates and initializes the tensor's data buffer.
int64_t computeFlatIndex (const index_t &indices) const
 Computes flat memory index from multi-dimensional indices.
int64_t computeSize (const shape_t &shape) const
 Computes total element count from shape vector.
stride_t computeStrides (const shape_t &shape)
 Computes row-major memory strides from shape.
std::string getBufferString () const
 Gets formatted buffer content for string representation.
std::string outputBuffer (size_t index, size_t depth) const
std::string outputLayout () const
 Generates formatted layout information string.
std::string setUId ()
 Generates unique identifier for new tensor instance.
void validateIndices (const index_t &indices, const char *fn) const
 Validates multi-dimensional indices against tensor shape.

Static Private Member Functions

static Compute::DeviceId validateDeviceId (Compute::DeviceId device_id)
 Validates device id against the memory resource requirement.

Private Attributes

std::shared_ptr< TensorBuffer< TDataType, TMemoryResource > > buffer_ { nullptr }
 Managed buffer containing tensor data.
Compute::DeviceId device_id_
 DeviceId for proper device binding and resource management.
bool is_view_ { false }
std::string name_
 Optional user-assigned name for debugging.
shape_t shape_ {}
 Dimensional sizes for each tensor dimension.
size_t size_ { 0 }
 Total number of logical elements in the tensor.
stride_t strides_ {}
 Memory stride values for multi-dimensional indexing.
std::string uid_
 Unique identifier for this tensor instance.
size_t view_offset_ { 0 }

Detailed Description

template<TensorDataType TDataType, typename TMemoryResource>
requires isValidTensor<TDataType, TMemoryResource>
class Mila::Dnn::Tensor< TDataType, TMemoryResource >

Device-aware N-dimensional tensor.

Move-only tensor parameterized by an abstract TensorDataType and a MemoryResource. Scalars are represented by an empty shape ({}), which yields size() == 1.

Template Parameters
TDataTypeAbstract tensor data type from TensorDataType enumeration
TMemoryResourceMemory resource type defining storage location and access patterns
Examples
/__w/Mila/Mila/Mila/Src/Dnn/Components/Activations/Gelu/Gelu.ixx, and /__w/Mila/Mila/Mila/Src/Dnn/Components/Normalization/Softmax.ixx.

Member Typedef Documentation

◆ DataType

template<TensorDataType TDataType, typename TMemoryResource>
using Mila::Dnn::Tensor< TDataType, TMemoryResource >::DataType = TensorDataType

Abstract data type enumeration.

◆ DataTypeTraits

template<TensorDataType TDataType, typename TMemoryResource>
using Mila::Dnn::Tensor< TDataType, TMemoryResource >::DataTypeTraits = TensorDataTypeTraits<TDataType>

Compile-time data type characteristics.

◆ host_value_t

template<TensorDataType TDataType, typename TMemoryResource>
using Mila::Dnn::Tensor< TDataType, TMemoryResource >::host_value_t = std::conditional_t<TensorDataTypeTraits<TDataType>::is_integer_type, int32_t, float>

Host value type for scalars.

◆ MemoryResource

template<TensorDataType TDataType, typename TMemoryResource>
using Mila::Dnn::Tensor< TDataType, TMemoryResource >::MemoryResource = TMemoryResource

Memory resource type for this tensor.

Constructor & Destructor Documentation

◆ Tensor() [1/4]

template<TensorDataType TDataType, typename TMemoryResource>
Mila::Dnn::Tensor< TDataType, TMemoryResource >::Tensor ( Compute::DeviceId device_id,
const shape_t & shape,
std::string name = {} )
inlineexplicit

Creates a tensor bound to the specified device id and shape.

Constructs a tensor using a DeviceId. Empty shape {} creates a scalar (0D tensor) with size 1. Shape containing a zero produces an empty tensor.

Parameters
device_idDevice identifier (type + index)
shapeVector defining the size of each dimension in row-major order
Exceptions
std::invalid_argumentIf device id is invalid (checked by validateDeviceId)
std::runtime_errorIf device type doesn't match memory resource
std::bad_allocIf memory allocation fails
Here is the caller graph for this function:

◆ Tensor() [2/4]

template<TensorDataType TDataType, typename TMemoryResource>
Mila::Dnn::Tensor< TDataType, TMemoryResource >::Tensor ( const Tensor< TDataType, TMemoryResource > & other)
delete

Copy constructor - explicitly deleted for performance safety.

Use clone() for deep copies or std::move() for ownership transfer.

◆ Tensor() [3/4]

template<TensorDataType TDataType, typename TMemoryResource>
Mila::Dnn::Tensor< TDataType, TMemoryResource >::Tensor ( Tensor< TDataType, TMemoryResource > && other)
inlinenoexcept

Efficiently transfers ownership from another tensor.

Moves resources from the source tensor, leaving it in a moved-from state.

◆ ~Tensor()

template<TensorDataType TDataType, typename TMemoryResource>
Mila::Dnn::Tensor< TDataType, TMemoryResource >::~Tensor ( )
default

Destructor with automatic resource cleanup via RAII.

◆ Tensor() [4/4]

template<TensorDataType TDataType, typename TMemoryResource>
Mila::Dnn::Tensor< TDataType, TMemoryResource >::Tensor ( const Tensor< TDataType, TMemoryResource > & parent,
const shape_t & shape,
size_t offset )
inlineprivate

Member Function Documentation

◆ allocateBuffer()

template<TensorDataType TDataType, typename TMemoryResource>
void Mila::Dnn::Tensor< TDataType, TMemoryResource >::allocateBuffer ( )
inlineprivate

Allocates and initializes the tensor's data buffer.

Scalars allocate normally (size==1); truly empty tensors allocate nothing.

Here is the caller graph for this function:

◆ computeFlatIndex()

template<TensorDataType TDataType, typename TMemoryResource>
int64_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::computeFlatIndex ( const index_t & indices) const
inlineprivate

Computes flat memory index from multi-dimensional indices.

Here is the caller graph for this function:

◆ computeSize()

template<TensorDataType TDataType, typename TMemoryResource>
int64_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::computeSize ( const shape_t & shape) const
inlineprivate

Computes total element count from shape vector.

Here is the caller graph for this function:

◆ computeStrides()

template<TensorDataType TDataType, typename TMemoryResource>
stride_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::computeStrides ( const shape_t & shape)
inlineprivate

Computes row-major memory strides from shape.

Here is the caller graph for this function:

◆ data() [1/2]

template<TensorDataType TDataType, typename TMemoryResource>
const auto * Mila::Dnn::Tensor< TDataType, TMemoryResource >::data ( ) const
inlinenodiscardconstexprnoexcept

Returns type-safe immutable pointer to tensor data with concrete host type.

◆ data() [2/2]

template<TensorDataType TDataType, typename TMemoryResource>
auto * Mila::Dnn::Tensor< TDataType, TMemoryResource >::data ( )
inlinenodiscardconstexprnoexcept

Returns type-safe pointer to tensor data with concrete host type.

Only available for host-accessible memory resources.

Here is the caller graph for this function:

◆ elementSize()

template<TensorDataType TDataType, typename TMemoryResource>
size_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::elementSize ( ) const
inlineoverridevirtual

Returns the size in bytes of a single tensor element.

Implements Mila::Dnn::ITensor.

Here is the caller graph for this function:

◆ empty()

template<TensorDataType TDataType, typename TMemoryResource>
bool Mila::Dnn::Tensor< TDataType, TMemoryResource >::empty ( ) const
inline

Checks if the tensor contains no elements.

Scalars are NOT empty (size == 1). Empty tensors have size == 0.

Here is the caller graph for this function:

◆ flatten()

template<TensorDataType TDataType, typename TMemoryResource>
Tensor< TDataType, TMemoryResource > & Mila::Dnn::Tensor< TDataType, TMemoryResource >::flatten ( )
inline

Flattens tensor to 2D shape in-place.

No-op for scalars and vectors.

◆ getBufferString()

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::getBufferString ( ) const
inlineprivate

Gets formatted buffer content for string representation.

Here is the caller graph for this function:

◆ getDataType()

template<TensorDataType TDataType, typename TMemoryResource>
TensorDataType Mila::Dnn::Tensor< TDataType, TMemoryResource >::getDataType ( ) const
inlineoverridevirtual

Returns the tensor's abstract data type identifier.

Implements Mila::Dnn::ITensor.

◆ getDataTypeName()

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::getDataTypeName ( ) const
inlineoverridevirtual

Returns human-readable name of the tensor's data type.

Implements Mila::Dnn::ITensor.

◆ getDeviceId()

template<TensorDataType TDataType, typename TMemoryResource>
Compute::DeviceId Mila::Dnn::Tensor< TDataType, TMemoryResource >::getDeviceId ( ) const
inlineoverridevirtual

Implements Mila::Dnn::ITensor.

Here is the caller graph for this function:

◆ getDeviceType()

template<TensorDataType TDataType, typename TMemoryResource>
Compute::DeviceType Mila::Dnn::Tensor< TDataType, TMemoryResource >::getDeviceType ( ) const
inlineoverridevirtual

Returns the device type of this tensor's memory resource.

Equivalent to TMemoryResource::device_type.

Implements Mila::Dnn::ITensor.

◆ getMemoryResource()

template<TensorDataType TDataType, typename TMemoryResource>
Compute::MemoryResource * Mila::Dnn::Tensor< TDataType, TMemoryResource >::getMemoryResource ( ) const
inlineoverridevirtual

Returns pointer to the memory resource managing this tensor's storage.

Implements Mila::Dnn::ITensor.

◆ getName()

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::getName ( ) const
inlineoverridevirtual

Returns the tensor's optional user-assigned name.

Implements Mila::Dnn::ITensor.

◆ getStorageSize()

template<TensorDataType TDataType, typename TMemoryResource>
size_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::getStorageSize ( ) const
inlineoverridevirtual

Returns the total storage size in bytes backing the tensor's buffer.

Forwards to the authoritative TensorBuffer::storageBytes() value and returns 0 when no buffer is allocated.

Implements Mila::Dnn::ITensor.

Here is the caller graph for this function:

◆ getUId()

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::getUId ( ) const
inlineoverridevirtual

Returns the tensor's unique identifier.

Implements Mila::Dnn::ITensor.

◆ is_device_accessible()

template<TensorDataType TDataType, typename TMemoryResource>
constexpr bool Mila::Dnn::Tensor< TDataType, TMemoryResource >::is_device_accessible ( )
inlinestaticconstexpr

Checks if tensor data is accessible from device (GPU) code.

◆ is_host_accessible()

template<TensorDataType TDataType, typename TMemoryResource>
constexpr bool Mila::Dnn::Tensor< TDataType, TMemoryResource >::is_host_accessible ( )
inlinestaticconstexpr

Checks if tensor data is accessible from host (CPU) code.

Here is the caller graph for this function:

◆ isScalar()

template<TensorDataType TDataType, typename TMemoryResource>
bool Mila::Dnn::Tensor< TDataType, TMemoryResource >::isScalar ( ) const
inlineoverridevirtualnoexcept

Checks if tensor is a scalar (0-dimensional).

Scalars: shape {} and size() == 1.

Implements Mila::Dnn::ITensor.

Here is the caller graph for this function:

◆ isValid()

template<TensorDataType TDataType, typename TMemoryResource>
bool Mila::Dnn::Tensor< TDataType, TMemoryResource >::isValid ( ) const
inlinenoexcept

Check if tensor is in a valid state (not moved-from).

◆ isView()

template<TensorDataType TDataType, typename TMemoryResource>
bool Mila::Dnn::Tensor< TDataType, TMemoryResource >::isView ( ) const
inlineoverridevirtual

Check if this tensor is a view of another tensor's data.

Returns
true if this is a view, false if it owns its buffer.

Implements Mila::Dnn::ITensor.

◆ item() [1/2]

template<TensorDataType TDataType, typename TMemoryResource>
auto & Mila::Dnn::Tensor< TDataType, TMemoryResource >::item ( )
inline

Gets the scalar value for 0-dimensional tensors.

Only available for host-accessible memory resources.

Exceptions
std::runtime_errorIf tensor is not a scalar (rank != 0)

◆ item() [2/2]

template<TensorDataType TDataType, typename TMemoryResource>
const auto & Mila::Dnn::Tensor< TDataType, TMemoryResource >::item ( ) const
inline

Gets the scalar value for 0-dimensional tensors (const version).

Only available for host-accessible memory resources.

Exceptions
std::runtime_errorIf tensor is not a scalar (rank != 0)

◆ operator=() [1/2]

template<TensorDataType TDataType, typename TMemoryResource>
Tensor & Mila::Dnn::Tensor< TDataType, TMemoryResource >::operator= ( const Tensor< TDataType, TMemoryResource > & other)
delete

Copy assignment operator - explicitly deleted.

Use clone() for deep copies or std::move() for transfers.

◆ operator=() [2/2]

template<TensorDataType TDataType, typename TMemoryResource>
Tensor & Mila::Dnn::Tensor< TDataType, TMemoryResource >::operator= ( Tensor< TDataType, TMemoryResource > && other)
inlinenoexcept

Efficiently moves resources from another tensor.

Self-assignment safe implementation.

◆ operator[]() [1/4]

template<TensorDataType TDataType, typename TMemoryResource>
auto & Mila::Dnn::Tensor< TDataType, TMemoryResource >::operator[] ( const index_t & indices)
inline

Accesses tensor element using multi-dimensional indices.

Only available for host-accessible memory resources.

Here is the caller graph for this function:

◆ operator[]() [2/4]

template<TensorDataType TDataType, typename TMemoryResource>
const auto & Mila::Dnn::Tensor< TDataType, TMemoryResource >::operator[] ( const index_t & indices) const
inline

Accesses tensor element using multi-dimensional indices (const version).

◆ operator[]() [3/4]

template<TensorDataType TDataType, typename TMemoryResource>
template<typename... Indices>
requires TMemoryResource::is_host_accessible
auto & Mila::Dnn::Tensor< TDataType, TMemoryResource >::operator[] ( Indices... indices) &&
inline

Variadic index access (non-const).

◆ operator[]() [4/4]

template<TensorDataType TDataType, typename TMemoryResource>
template<typename... Indices>
requires TMemoryResource::is_host_accessible
const auto & Mila::Dnn::Tensor< TDataType, TMemoryResource >::operator[] ( Indices... indices) const &&
inline

Variadic index access (const).

◆ outputBuffer()

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::outputBuffer ( size_t index,
size_t depth ) const
inlineprivate
Here is the caller graph for this function:

◆ outputLayout()

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::outputLayout ( ) const
inlineprivate

Generates formatted layout information string.

Here is the caller graph for this function:

◆ rank()

template<TensorDataType TDataType, typename TMemoryResource>
size_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::rank ( ) const
inline

Returns the number of dimensions in the tensor.

Here is the caller graph for this function:

◆ rawData() [1/2]

template<TensorDataType TDataType, typename TMemoryResource>
const void * Mila::Dnn::Tensor< TDataType, TMemoryResource >::rawData ( ) const
inlineoverridevirtual

Returns raw pointer to tensor data (const version).

Implements Mila::Dnn::ITensor.

◆ rawData() [2/2]

template<TensorDataType TDataType, typename TMemoryResource>
void * Mila::Dnn::Tensor< TDataType, TMemoryResource >::rawData ( )
inlineoverridevirtual

Returns raw pointer to tensor data (implements ITensor protected API).

Implements Mila::Dnn::ITensor.

Here is the caller graph for this function:

◆ reshape()

template<TensorDataType TDataType, typename TMemoryResource>
void Mila::Dnn::Tensor< TDataType, TMemoryResource >::reshape ( const shape_t & new_shape)
inline

Modifies tensor shape while preserving total element count.

The new shape must have the same total number of elements as the current shape, unless the tensor is empty.

Here is the caller graph for this function:

◆ setName()

template<TensorDataType TDataType, typename TMemoryResource>
void Mila::Dnn::Tensor< TDataType, TMemoryResource >::setName ( const std::string & value)
inline

Assigns a descriptive name to the tensor.

Names must be non-empty strings.

Here is the caller graph for this function:

◆ setUId()

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::setUId ( )
inlineprivate

Generates unique identifier for new tensor instance.

◆ shape()

template<TensorDataType TDataType, typename TMemoryResource>
const shape_t & Mila::Dnn::Tensor< TDataType, TMemoryResource >::shape ( ) const
inlineoverridevirtual

Returns the tensor's dimensional shape vector.

Implements Mila::Dnn::ITensor.

Here is the caller graph for this function:

◆ size()

template<TensorDataType TDataType, typename TMemoryResource>
size_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::size ( ) const
inlineoverridevirtual

Returns the total number of logical elements in the tensor.

Implements Mila::Dnn::ITensor.

Here is the caller graph for this function:

◆ strides()

template<TensorDataType TDataType, typename TMemoryResource>
const stride_t & Mila::Dnn::Tensor< TDataType, TMemoryResource >::strides ( ) const
inline

Returns the tensor's memory stride information.

◆ toString()

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::toString ( bool showBuffer = false) const
inline

Generates string representation of the tensor.

Includes UID, name, shape, data type and device information.

Here is the caller graph for this function:

◆ validateDeviceId()

template<TensorDataType TDataType, typename TMemoryResource>
Compute::DeviceId Mila::Dnn::Tensor< TDataType, TMemoryResource >::validateDeviceId ( Compute::DeviceId device_id)
inlinestaticprivate

Validates device id against the memory resource requirement.

Throws if types do not match.

◆ validateIndices()

template<TensorDataType TDataType, typename TMemoryResource>
void Mila::Dnn::Tensor< TDataType, TMemoryResource >::validateIndices ( const index_t & indices,
const char * fn ) const
inlineprivate

Validates multi-dimensional indices against tensor shape.

Here is the caller graph for this function:

◆ view()

template<TensorDataType TDataType, typename TMemoryResource>
Tensor Mila::Dnn::Tensor< TDataType, TMemoryResource >::view ( const shape_t & new_shape,
size_t offset = 0 ) const
inlinenodiscard
Here is the caller graph for this function:

Member Data Documentation

◆ buffer_

template<TensorDataType TDataType, typename TMemoryResource>
std::shared_ptr<TensorBuffer<TDataType, TMemoryResource> > Mila::Dnn::Tensor< TDataType, TMemoryResource >::buffer_ { nullptr }
private

Managed buffer containing tensor data.

◆ device_id_

template<TensorDataType TDataType, typename TMemoryResource>
Compute::DeviceId Mila::Dnn::Tensor< TDataType, TMemoryResource >::device_id_
private

DeviceId for proper device binding and resource management.

◆ is_view_

template<TensorDataType TDataType, typename TMemoryResource>
bool Mila::Dnn::Tensor< TDataType, TMemoryResource >::is_view_ { false }
private

◆ name_

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::name_
private

Optional user-assigned name for debugging.

◆ shape_

template<TensorDataType TDataType, typename TMemoryResource>
shape_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::shape_ {}
private

Dimensional sizes for each tensor dimension.

◆ size_

template<TensorDataType TDataType, typename TMemoryResource>
size_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::size_ { 0 }
private

Total number of logical elements in the tensor.

◆ strides_

template<TensorDataType TDataType, typename TMemoryResource>
stride_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::strides_ {}
private

Memory stride values for multi-dimensional indexing.

◆ uid_

template<TensorDataType TDataType, typename TMemoryResource>
std::string Mila::Dnn::Tensor< TDataType, TMemoryResource >::uid_
private

Unique identifier for this tensor instance.

◆ view_offset_

template<TensorDataType TDataType, typename TMemoryResource>
size_t Mila::Dnn::Tensor< TDataType, TMemoryResource >::view_offset_ { 0 }
private

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