cast_to
Description
Casts a data type, specifically, from data type of data into target dtype. The supported cast types are listed as follows.
Source Data Type |
Target Data Type |
Rounding Mode |
Description |
|---|---|---|---|
float32 |
float16 |
N/A |
Supported by all SoC types |
float32 |
int8 |
Round down |
Supported by all SoC types |
float32 |
uint8 |
Round down |
Supported by all SoC types |
float16 |
float32 |
N/A |
Supported by all SoC types |
float16 |
int8 |
Round down |
Supported by all SoC types |
float16 |
uint8 |
Round down |
Supported by all SoC types |
float16 |
int32 |
Round down |
Supported by all SoC types |
int8 |
float16 |
N/A |
Supported by all SoC types |
int8 |
uint8 |
Round down |
Supported by all SoC types |
int32 |
float16 |
N/A |
Supported by all SoC types |
int32 |
int8 |
Round down |
Supported by all SoC types |
int32 |
uint8 |
Round down |
Supported by all SoC types |
int64 |
float16 |
N/A |
Supported by: |
Prototype
cast_to(data, dtype, f1628IntegerFlag=True)
Parameters
- data: a tvm.tensor for the input tensor.
- dtype: a string for the target data type.
- f1628IntegerFlag: defaults to True. If the decimal part of data is 0, set f1628IntegerFlag to True. Otherwise, set f1628IntegerFlag to False.
Returns
res_tensor: a tvm.tensor for the result tensor
Restrictions
None
Applicability
Example
from tbe import tvm from tbe import dsl shape = (1024,1024) input_dtype = "float16" data = tvm.placeholder(shape, name="data", dtype=input_dtype) res = dsl.cast_to(data,"float32")