Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
TensorHostTypeMap.ixx File Reference

Device-agnostic host type mapping for abstract TensorDataType enumeration. More...

#include <cstdint>
#include <type_traits>
import Dnn.TensorDataType;

Classes

struct  Mila::Dnn::TensorHostTypeMap< TDataType >
 Maps abstract TensorDataType to host-compatible C++ type and TensorDataType. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::BF16 >
 Host type for 16-bit brain floating point. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::FP16 >
 Host type for 16-bit half precision floating point. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::FP32 >
 Host type for 32-bit IEEE 754 floating point. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::FP8_E4M3 >
 Host type for 8-bit floating point with E4M3 format. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::FP8_E5M2 >
 Host type for 8-bit floating point with E5M2 format. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::INT16 >
 Host type for 16-bit signed integer. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::INT32 >
 Host type for 32-bit signed integer. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::INT8 >
 Host type for 8-bit signed integer. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::UINT16 >
 Host type for 16-bit unsigned integer. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::UINT32 >
 Host type for 32-bit unsigned integer. More...
struct  Mila::Dnn::TensorHostTypeMap< TensorDataType::UINT8 >
 Host type for 8-bit unsigned integer. More...

Namespaces

namespace  Mila
 Mila main API namespace.
namespace  Mila::Dnn

Typedefs

template<TensorDataType TDataType>
using Mila::Dnn::host_type_t = typename TensorHostTypeMap<TDataType>::host_type
 Convenience alias for accessing host type mapping.

Variables

template<TensorDataType TDataType>
constexpr bool Mila::Dnn::is_host_float_type = std::is_floating_point_v<host_type_t<TDataType>>
 Checks if a TensorDataType maps to a floating-point host type.
template<TensorDataType TDataType>
constexpr bool Mila::Dnn::is_host_integer_type = std::is_integral_v<host_type_t<TDataType>>
 Checks if a TensorDataType maps to an integer host type.

Detailed Description

Device-agnostic host type mapping for abstract TensorDataType enumeration.

This module provides centralized mapping from abstract tensor data types to appropriate host-compatible C++ types for conversion and host-side processing. These mappings are device-agnostic and define the standard host representation for each abstract tensor data type across all compute backends.

Key architectural principles:

  • Device-agnostic: Host types are consistent across all compute devices
  • Conversion-oriented: Optimized for host-device data transfers
  • Direct type mappings: Preserves precision and signedness where possible
  • Single source of truth: Eliminates duplication across device-specific files

Usage patterns:

  • Host-device data transfers and conversions
  • Fill operations using host-provided values
  • Debugging and inspection of tensor values
  • External API integration requiring standard C++ types

Design rationale:

  • Direct mappings preserve type characteristics (precision, signedness)
  • Floating-point types use appropriate host representations
  • Integer types maintain their original bit width and signedness
  • Maps are closed via explicit specializations with clear error messages