|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
|
nodiscard |
Convert the elements of a tensor to another element type.
The result is a dense C-order tensor with the source's name and axes. A strided source is read through its strides.
Integer to integer conversion is exact and saturates. A float becomes an integer by rounding to nearest, ties to even, with NaN as zero and saturation at the range. A float narrows by rounding to nearest, ties to even, and overflows to infinity. Anything non-zero becomes true in a bool.
Values are real numbers when a quantization is involved: a source with quantization is read as scale * (stored - zero_point), and a requested quantization stores clamp(round(value / scale) + zero_point), with NaN stored as the zero point. A source quantization is not carried to the result unless it is requested again.
Usage:
| source | Tensor to read. |
| target | Element type of the result. |
| quantization | Quantization the result should carry, if any. |
Definition at line 443 of file TensorConvert.cpp.
References MayaFlux::Kakshya::TensorData::allocate(), MayaFlux::Kakshya::TensorSpec::byte_offset, convert_complex(), MayaFlux::Kakshya::TensorData::copy_of(), MayaFlux::Kakshya::TensorSpec::device, diagnose_conversion(), MayaFlux::Kakshya::TensorSpec::dtype, MayaFlux::Kakshya::TensorSpec::name, MayaFlux::Kakshya::TensorSpec::quantization, and MayaFlux::Kakshya::TensorSpec::strides.
Referenced by MayaFlux::Yantra::TensorConverter::operation_function(), and MayaFlux::Yantra::TensorKernels::pack_weights().