Help Center/ Atlas 300 Application (Model 3000)/ TE API Reference/ Compute APIs/ te.lang.cce.cast_to(data, dtype, f1628IntegerFlag=False)
Updated on 2022-03-13 GMT+08:00

te.lang.cce.cast_to(data, dtype, f1628IntegerFlag=False)

Converts a data type, specifically, converts a data type into dtype.

This API is defined in common.py.

The following data type conversions are supported:

Table 1 Supported data type conversions

Source Data Type

Destination Data Type

float32

float16

float32

int8

float32

uint8

float16

float32

float16

int8

float16

uint8

float16

int32

int8

float16

int8

uint8

int32

float16

int32

int8

int32

uint8

Parameter Description

  • data: input tensor, tvm.tensor type
  • dtype: destination data type, string type
  • f1628IntegerFlag: The default value is False. If the decimal part of the data before conversion is 0, set f1628IntegerFlag to True. If the decimal part of the data before conversion is not 0, set f1628IntegerFlag to False.

Return Value

res_tensor: data after conversion, tvm.tensor type

Calling Example

shape = (1024,1024)
input_dtype = "float16"
data = tvm.placeholder(shape, name="data", dtype=input_dtype)
res = te.lang.cce.cast_to(data,"float32")