This function copies elements from the input tensor to the output with data conversion according to the output tensor type parameters.
For example, the function can:
- convert data according to new element type:
- change data according to new data parameter: increase/decrease the number of fractional bits while keeping the same element type for FX data
Conversion is performed using:
- rounding when the number of significant bits increases
- saturation when the number of significant bits decreases
This operation does not change tensor shape. It copies it from input to output.
This kernel performs in-place computation, but only for conversions
without increasing data size, so that that it does not lead to
undefined behavior. Therefore, output and input might point to exactly the
same memory (but without shift) except during
In-place computation might affect performance for some platforms.
mli_status mli_hlp_convert_tensor( mli_tensor *in, mli_tensor *out );
Conditions for Applying the Function¶
- Input must be a valid tensor (see mli_tensor Structure).
- Before processing, the output tensor must contain a valid pointer to a buffer with sufficient capacity for storing the result (that is, the total amount of elements in input tensor).
- The output tensor also must contain valid element type and its
- Before processing, the output tensor does not have to contain valid shape and rank - they are copied from input tensor.