Type Traits#

MatX type traits help advanced developers to make compile-time decisions about types. Most of these are used extensively inside of MatX, and are not needed in most user applications.

MatX now uses C++20 concepts for type traits. Legacy variable templates (ending in _v) and functions (ending in _t()) are maintained for backward compatibility.

Type Manipulation#

template<typename T>
using matx::promote_half_t = typename cuda::std::conditional_t<is_half_v<T> || is_matx_half_v<T>, float, T>#

Promote half precision floating point value to fp32, or leave untouched if not half.

Template Parameters:

T – Type to convert

template<class T>
struct remove_cvref#

Removes cv and reference qualifiers on a type.

Template Parameters:

T – Type to remove qualifiers

Concepts (C++20)#

template<class T>
concept is_tensor#
#include <type_utils_both.h>

Determine if a type is a MatX tensor.

tparam T:

Type to test

template<typename T>
concept is_matx_op_c#
#include <type_utils_both.h>

Determine if a type is a MatX operator.

tparam T:

Type to test

template<typename T>
concept is_executor#
#include <type_utils.h>

Determine if a type is a MatX executor.

tparam T:

Type to test

template<typename T>
concept is_matx_reduction#
#include <type_utils_both.h>

Determine if a type is a MatX reduction.

tparam T:

Type to test

template<typename T>
concept is_matx_index_reduction#
#include <type_utils_both.h>

Determine if a type is a MatX index reduction type.

tparam T:

Type to test

template<class T>
concept is_cuda_complex#
#include <type_utils_both.h>

Determine if a type is a cuda::std::complex variant.

tparam T:

Type to test

template<class T>
concept is_complex#
#include <type_utils_both.h>

Determine if a type is a complex type (any type supported)

tparam T:

Type to test

template<class T>
concept is_complex_half#
#include <type_utils_both.h>

Determine if a type is a complex half precision type.

tparam T:

Type to test

template<class T>
concept is_half#
#include <type_utils_both.h>

Determine if a type is half precision (either __half or __nv_bfloat16)

tparam T:

Type to test

template<class T>
concept is_matx_half#
#include <type_utils_both.h>

Determine if a type is a MatX half precision wrapper (either matxFp16 or matxBf16)

tparam T:

Type to test

template<class T>
concept is_matx_type#
#include <type_utils_both.h>

Determine if a type is a MatX custom type (half precision wrappers)

tparam T:

Type to test

template<typename T>
concept is_matx_shape#
#include <type_utils_both.h>

Determine if a type is a MatX shape type.

tparam T:

Type to test

template<typename T>
concept is_matx_storage#
#include <type_utils.h>

Determine if a type is a MatX storage type.

tparam T:

Type to test

template<typename T>
concept is_matx_storage_container#
#include <type_utils.h>

Determine if a type is a MatX storage container.

tparam T:

Type to test

template<typename T>
concept is_matx_descriptor#
#include <type_utils_both.h>

Determine if a type is a MatX descriptor.

tparam T:

Type to test

Legacy Compatibility#

Legacy functions and variables for backward compatibility:

template<typename T>
__MATX_HOST__ __MATX_DEVICE__ bool matx::is_matx_op()#
template<typename T>
bool matx::is_executor_t()#
template<typename T>
__MATX_HOST__ __MATX_DEVICE__ inline bool matx::IsHalfType()#

Tests if a type is a half precision floating point.

Template Parameters:

T – Type to test

Returns:

True if half precision floating point

Note: Legacy variable templates (is_tensor_v, is_matx_reduction_v, etc.) are available for backward compatibility but are not documented here. Use the concepts above instead for new code.