Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::VulkanTensorTraits Class Referenceexport

Vulkan-specific traits for abstract tensor data types. More...

Public Types

template<TensorDataType TDataType>
using native_type = decltype(get_native_type<TDataType>())
 Type alias for the native Vulkan type corresponding to a TensorDataType.

Static Public Member Functions

static constexpr std::string_view device_type_name ()
 Gets the Vulkan device type string for debugging.
template<TensorDataType TDataType>
static consteval bool is_device_only ()
 Checks if the specified data type requires device-only access.
template<TensorDataType TDataType, typename T>
static constexpr auto make_native_value (const T &value)
 Creates a native type value from a compatible input value.
template<TensorDataType TDataType>
static consteval std::string_view preferred_allocation_strategy ()
 Gets the preferred memory allocation strategy for the data type.
template<TensorDataType TDataType>
static consteval std::string_view required_extension ()
 Gets the required Vulkan extension name for the data type.
template<TensorDataType TDataType>
static consteval bool requires_extensions ()
 Checks if the data type requires specific Vulkan device extensions.
template<TensorDataType TDataType>
static consteval uint32_t spirv_bit_width ()
 Gets the SPIR-V OpTypeFloat/OpTypeInt bit width for the data type.
template<TensorDataType TDataType>
static consteval bool supports ()
 Validates Vulkan support for abstract tensor data types.
template<TensorDataType TDataType>
static constexpr float to_float (const native_type< TDataType > &value)
 Converts native Vulkan type values to float for host operations.

Static Private Member Functions

template<TensorDataType TDataType>
static consteval auto get_native_type ()
 Helper function for compile-time native type deduction.

Detailed Description

Vulkan-specific traits for abstract tensor data types.

Provides device-specific characteristics and native type mappings for Vulkan-supported tensor data types, enabling type-safe value initialization and explicit graphics/compute operations with fine-grained synchronization control across different GPU architectures.

Vulkan's explicit design requires careful consideration of:

  • Memory heap selection and allocation strategy
  • Command buffer recording and submission
  • Pipeline barriers and synchronization primitives
  • Device-local vs host-visible memory trade-offs

Member Typedef Documentation

◆ native_type

template<TensorDataType TDataType>
using Mila::Dnn::VulkanTensorTraits::native_type = decltype(get_native_type<TDataType>())

Type alias for the native Vulkan type corresponding to a TensorDataType.

Provides compile-time mapping from abstract TensorDataType enumeration to concrete C++ types compatible with Vulkan's SPIR-V shader requirements and memory layout specifications.

Member Function Documentation

◆ device_type_name()

constexpr std::string_view Mila::Dnn::VulkanTensorTraits::device_type_name ( )
inlinestaticconstexpr

Gets the Vulkan device type string for debugging.

Returns
String identifier for Vulkan backend

◆ get_native_type()

template<TensorDataType TDataType>
consteval auto Mila::Dnn::VulkanTensorTraits::get_native_type ( )
inlinestaticconstevalprivate

Helper function for compile-time native type deduction.

Maps abstract tensor data types to Vulkan-compatible native types, using standard C++ types that align with SPIR-V and Vulkan shader data type requirements. Handles both available and unavailable Vulkan configurations with appropriate fallback types.

◆ is_device_only()

template<TensorDataType TDataType>
consteval bool Mila::Dnn::VulkanTensorTraits::is_device_only ( )
inlinestaticconsteval

Checks if the specified data type requires device-only access.

Determines whether a tensor data type can only be accessed from Vulkan compute shaders and cannot be directly manipulated from host code without explicit staging buffer transfers.

Template Parameters
TDataTypeAbstract tensor data type to check
Returns
true if device-only access required, false if host-accessible
Here is the caller graph for this function:

◆ make_native_value()

template<TensorDataType TDataType, typename T>
constexpr auto Mila::Dnn::VulkanTensorTraits::make_native_value ( const T & value)
inlinestaticconstexpr

Creates a native type value from a compatible input value.

Provides safe conversion from input values to the appropriate native Vulkan-compatible type, handling cross-platform type conversions and ensuring compatibility with SPIR-V data type requirements.

Template Parameters
TDataTypeTarget abstract tensor data type
TInput value type
Parameters
valueInput value to convert
Returns
Native Vulkan-compatible type value suitable for compute operations

◆ preferred_allocation_strategy()

template<TensorDataType TDataType>
consteval std::string_view Mila::Dnn::VulkanTensorTraits::preferred_allocation_strategy ( )
inlinestaticconsteval

Gets the preferred memory allocation strategy for the data type.

Returns the optimal Vulkan memory allocation strategy based on data type characteristics, device capabilities, and expected usage patterns.

Template Parameters
TDataTypeAbstract tensor data type
Returns
Recommended allocation strategy for optimal performance
Here is the call graph for this function:

◆ required_extension()

template<TensorDataType TDataType>
consteval std::string_view Mila::Dnn::VulkanTensorTraits::required_extension ( )
inlinestaticconsteval

Gets the required Vulkan extension name for the data type.

Returns the Vulkan extension string required for the specified data type, enabling proper device capability validation and extension enablement.

Template Parameters
TDataTypeAbstract tensor data type requiring extensions
Returns
String view of the required extension name

◆ requires_extensions()

template<TensorDataType TDataType>
consteval bool Mila::Dnn::VulkanTensorTraits::requires_extensions ( )
inlinestaticconsteval

Checks if the data type requires specific Vulkan device extensions.

Determines whether a tensor data type requires explicit Vulkan device extensions to be enabled, affecting device selection and capability validation.

Template Parameters
TDataTypeAbstract tensor data type to check
Returns
true if extensions required, false for core Vulkan types

◆ spirv_bit_width()

template<TensorDataType TDataType>
consteval uint32_t Mila::Dnn::VulkanTensorTraits::spirv_bit_width ( )
inlinestaticconsteval

Gets the SPIR-V OpTypeFloat/OpTypeInt bit width for the data type.

Returns the bit width used in SPIR-V instruction generation for the specified data type, essential for compute shader compilation and validation.

Template Parameters
TDataTypeAbstract tensor data type
Returns
Bit width for SPIR-V type instructions

◆ supports()

template<TensorDataType TDataType>
consteval bool Mila::Dnn::VulkanTensorTraits::supports ( )
inlinestaticconsteval

Validates Vulkan support for abstract tensor data types.

Determines whether Vulkan devices and memory resources support the specified abstract tensor data type, considering Vulkan's explicit memory model and compute pipeline requirements across different GPU vendors and architectures.

Template Parameters
TDataTypeAbstract tensor data type to validate
Returns
true if Vulkan supports the data type, false otherwise

◆ to_float()

template<TensorDataType TDataType>
constexpr float Mila::Dnn::VulkanTensorTraits::to_float ( const native_type< TDataType > & value)
inlinestaticconstexpr

Converts native Vulkan type values to float for host operations.

Provides conversion from Vulkan native types back to float values for host-side processing, validation, and cross-platform compatibility. Handles special cases like half-precision and 64-bit types that require explicit device extension support.

Template Parameters
TDataTypeSource abstract tensor data type
Parameters
valueNative Vulkan type value to convert
Returns
Float representation of the value

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