cast<T extends SizedNativeType> function
Casts a variable to a new type.
Args:
- x: A variable. Must be one of the following types: Halide_Type_Int or Halide_Type_Float, Halide_Type_Int64, Halide_Type_Uint8
- dtype: The destination type. The list of supported dtypes is the same as x.
Returns:
- A variable with same shape as x and same type as dtype.
Implementation
VARP cast<T extends ffi.SizedNativeType>(VARP x, {HalideType? dtype}) {
MnnAssert(
T != ffi.SizedNativeType || dtype != null,
"You must specify the generic type T or dtype. e.g., mnn.float32",
);
dtype ??= HalideType.of<T>();
return x.dtype == dtype ? x : VARP.fromPointer(C.mnn_expr_Cast(x.ptr, dtype.native.ref));
}