更新时间:2021-03-18 GMT+08:00
使用示例
下面通过一个简单的示例,将上面的接口串起来。该示例是实现一个简单的支持float16数据类型的求绝对值的算子。
import te.lang.cce from te import tvm import topi shape = (28,28) dtype = "float16" # 定义输入 data = tvm.placeholder(shape, name="data", dtype=dtype) # 描述算子计算过程 res = te.lang.cce.vabs(data) with tvm.target.cce(): # 生成schedule对象 sch = topi.generic.auto_schedule(res) # 定义build配置参数 config = {"print_ir" : True, "need_build" : True, "name" : "abs_28_28_float16", "tensor_list" : [data,res]} # build算子 te.lang.cce.cce_build_code(sch, config)
父主题: 使用方式