trunc

Description

Rounds raw_tensor towards 0 element-wise. For example, –1.9 is rounded to –1, and 1.9 is rounded to 1.

Prototype

trunc(raw_tensor)

Parameters

raw_tensor: a tvm.tensor for the input tensor

Atlas training products: supports float16 and float32.

Atlas inference products: supports float16, float32, f162s8, f162u8, f162s32, and f322s32.

Atlas 200I/500 A2 inference products: supports float16 and float32.

Atlas A2 training products/Atlas A2 inference products: supports float16 and float32.

Atlas A3 training products/Atlas A3 inference products: supports float16 and float32.

Returns

res_tensor: result Tensor, tvm.tensor type

The default data type is int32. Data is output based on the specified output data type. For example, if the input data type is f162s8, the output data type is int8.

Restrictions

None

Applicable Models

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas A3 training products/Atlas A3 inference products

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.trunc(data)