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

Abstract tensor data type enumeration and traits system for device-agnostic tensor operations. More...

#include <string>
#include <stdexcept>

Namespaces

namespace  Mila
 Mila main API namespace.

Typedefs

using Mila::Dnn::dtype_t = TensorDataType
 Alias for TensorDataType enumeration.

Enumerations

enum class  Mila::Dnn::TensorDataType {
  FP32 , FP16 , BF16 , FP8_E4M3 ,
  FP8_E5M2 , FP4_E2M1 , FP4_E3M0 , INT8 ,
  INT16 , INT32 , UINT8 , UINT16 ,
  UINT32
}
 Enumeration of supported abstract tensor data types. More...

Functions

TensorDataType Mila::Dnn::parseTensorDataType (const std::string &type_str)
std::string Mila::Dnn::tensorDataTypeToString (TensorDataType type)
 Converts TensorDataType enumeration to human-readable string.

Detailed Description

Abstract tensor data type enumeration and traits system for device-agnostic tensor operations.

This module provides a comprehensive type abstraction layer that enables tensor operations across different compute devices (CPU, CUDA, Metal, OpenCL) without exposing device-specific concrete types to host compilation. The system supports standard floating-point and integer types as well as advanced precision formats including FP8, FP4, and packed sub-byte types.

Typedef Documentation

◆ dtype_t

using Mila::Dnn::dtype_t = TensorDataType
export

Alias for TensorDataType enumeration.

Provides a concise alias for the TensorDataType enumeration to improve code readability in tensor-related contexts.

Enumeration Type Documentation

◆ TensorDataType

enum class Mila::Dnn::TensorDataType
exportstrong

Enumeration of supported abstract tensor data types.

Defines device-agnostic tensor data types that can be mapped to concrete implementations on different compute devices. This abstraction prevents host compilation issues with device-specific types while enabling compile-time dispatch and optimization.

Supported categories:

  • Standard floating-point: FP32
  • Reduced precision floating-point: FP16, BF16, FP8_E4M3, FP8_E5M2
  • Integer types: Various widths from 8-bit to 32-bit, signed and unsigned
Note
Device-only types (FP16, BF16, FP8) require device-accessible memory
Packed sub-byte types (FP4, INT4, UINT4) are planned for future implementation
Enumerator
FP32 

32-bit IEEE 754 floating point, host-compatible

FP16 

16-bit half precision floating point, device-only

BF16 

16-bit brain floating point, device-only

FP8_E4M3 

8-bit floating point with 4-bit exponent and 3-bit mantissa, device-only

FP8_E5M2 

8-bit floating point with 5-bit exponent and 2-bit mantissa, device-only

FP4_E2M1 

4-bit floating point with 2-bit exponent and 1-bit mantissa, packed, device-only

FP4_E3M0 

4-bit floating point with 3-bit exponent and 0-bit mantissa, packed, device-only

INT8 

8-bit signed integer

INT16 

16-bit signed integer, host-compatible

INT32 

32-bit signed integer, host-compatible

UINT8 

8-bit unsigned integer

UINT16 

16-bit unsigned integer, host-compatible

UINT32 

32-bit unsigned integer, host-compatible