Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Compute::Cpu::TransferOps Struct Referenceexport

CPU specialization of TensorOps for transfer operations. More...

Inheritance diagram for Mila::Dnn::Compute::Cpu::TransferOps:

Static Public Member Functions

template<TensorDataType TSrcDataType, typename TSrcMemoryResource, TensorDataType TDstDataType, typename TDstMemoryResource>
requires isValidTensor<TSrcDataType, TSrcMemoryResource>&& isValidTensor<TDstDataType, TDstMemoryResource>
static void copy (const Tensor< TSrcDataType, TSrcMemoryResource > &src, Tensor< TDstDataType, TDstMemoryResource > &dst, IExecutionContext *exec_context=nullptr)
 Copy tensor data between pre-allocated tensors.
template<TensorDataType TDstDataType, typename TDstMemoryResource>
requires isValidTensor<TDstDataType, TDstMemoryResource>
static void copyFromBlob (const Serialization::ITensorBlob &blob, Tensor< TDstDataType, TDstMemoryResource > &dst, IExecutionContext *exec_context=nullptr)

Static Private Member Functions

template<TensorDataType TSrcDataType, TensorDataType TDstDataType>
static void hostConvertImpl (const void *src_data, void *dst_data, size_t count)
 Private wrapper forwarding to Detail::copyHostToHostWithConversionImpl.
template<TensorDataType TDataType>
static void hostCopyImpl (const void *src_data, void *dst_data, size_t count)
 Private wrapper forwarding to Detail::copyHostToHostImpl.

Detailed Description

CPU specialization of TensorOps for transfer operations.

This specialization provides CPU-specific implementations of tensor transfer operations for the DeviceType::Cpu device type. Handles both same-type and type-conversion transfers with host memory optimization.

Key features:

  • Direct memcpy for same-type transfers (optimal performance)
  • Element-wise conversion for different-type transfers
  • Accepts ExecutionContext for API consistency (unused on CPU)
  • All operations are synchronous (no stream management)

Member Function Documentation

◆ copy()

template<TensorDataType TSrcDataType, typename TSrcMemoryResource, TensorDataType TDstDataType, typename TDstMemoryResource>
requires isValidTensor<TSrcDataType, TSrcMemoryResource>&& isValidTensor<TDstDataType, TDstMemoryResource>
void Mila::Dnn::Compute::Cpu::TransferOps::copy ( const Tensor< TSrcDataType, TSrcMemoryResource > & src,
Tensor< TDstDataType, TDstMemoryResource > & dst,
IExecutionContext * exec_context = nullptr )
inlinestatic

Copy tensor data between pre-allocated tensors.

Validates that src and dst have identical shapes, ensures non-zero element count, and dispatches to the appropriate same-type or conversion copy implementation.

Template Parameters
TSrcDataTypeAbstract source tensor data type
TSrcMemoryResourceSource memory resource type (must be host-accessible)
TDstDataTypeAbstract destination tensor data type
TDstMemoryResourceDestination memory resource type (must be host-accessible)
Parameters
srcSource tensor (pre-allocated)
dstDestination tensor (pre-allocated)
exec_contextOptional execution context pointer (ignored for CPU)
Exceptions
std::invalid_argumentIf tensor shapes do not match
std::runtime_errorIf underlying data pointers are invalid
Note
This function is synchronous and does not use the execution context.
Here is the call graph for this function:

◆ copyFromBlob()

template<TensorDataType TDstDataType, typename TDstMemoryResource>
requires isValidTensor<TDstDataType, TDstMemoryResource>
void Mila::Dnn::Compute::Cpu::TransferOps::copyFromBlob ( const Serialization::ITensorBlob & blob,
Tensor< TDstDataType, TDstMemoryResource > & dst,
IExecutionContext * exec_context = nullptr )
inlinestatic
Here is the call graph for this function:

◆ hostConvertImpl()

template<TensorDataType TSrcDataType, TensorDataType TDstDataType>
void Mila::Dnn::Compute::Cpu::TransferOps::hostConvertImpl ( const void * src_data,
void * dst_data,
size_t count )
inlinestaticprivate

Private wrapper forwarding to Detail::copyHostToHostWithConversionImpl.

Thin forwarding wrapper used to encapsulate the internal conversion implementation.

Template Parameters
TSrcDataTypeAbstract source tensor data type
TDstDataTypeAbstract destination tensor data type
Parameters
src_dataPointer to source memory
dst_dataPointer to destination memory
countNumber of logical elements to convert and copy
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hostCopyImpl()

template<TensorDataType TDataType>
void Mila::Dnn::Compute::Cpu::TransferOps::hostCopyImpl ( const void * src_data,
void * dst_data,
size_t count )
inlinestaticprivate

Private wrapper forwarding to Detail::copyHostToHostImpl.

Thin forwarding wrapper used to encapsulate the internal implementation.

Template Parameters
TDataTypeAbstract tensor data type
Parameters
src_dataPointer to source memory
dst_dataPointer to destination memory
countNumber of logical elements to copy
Here is the call graph for this function:
Here is the caller graph for this function:

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