Updated on 2022-03-13 GMT+08:00

Usage Example

The following example shows how to concatenate the preceding APIs. It implements a simple operator that supports the float16 type to obtain an absolute value.

import te.lang.cce 
from te import tvm 
import topi
shape = (28,28)
dtype = "float16"
# Define input.
data = tvm.placeholder(shape, name="data", dtype=dtype)

# Describe the computation process of the operator.
res = te.lang.cce.vabs(data)

with tvm.target.cce():
    # Generate the schedule object.
      sch = topi.generic.auto_schedule(res)

# Define build parameters.
config = {"print_ir" : True,
          "need_build" : True,
          "name" : "abs_28_28_float16",
          "tensor_list" : [data,res]}
# Build an operator.
te.lang.cce.cce_build_code(sch, config)