Skip to content
fn

dtype_size

→std::size_t
int dtype_size(Dtype dt)

Returns the size in bytes of a single element of the given dtype.

Parameters

dtDtype
Dtype to query.

Returns

std::size_t

Element size in bytes. 1 for Bool / I8, 2 for I16 / F16, 4 for I32 / F32, 8 for I64 / F64 / C64.

Raises

:logic_error
The enum was extended without updating this switch.

Notes

constexpr so that nbytes = numel * dtype_size(dt) folds away at compile time in kernel templates instantiated against a known dtype.