调度与编译

如下代码所示,当定义完计算逻辑后,需要在算子接口实现函数中实现调度与编译。

通过调用auto_schedule接口,便可以自动生成相应的调度,此处通过TVM的打印机制可以看到相应计算的中间表示。配置信息包括是否需要打印IR、是否编译以及算子内核名以及输入、输出张量。

with tvm.target.cce():
    schedule = dsl.auto_schedule(result)
config = {
    "print_ir": True,
    "need_build": True,
    "name": kernel_name,
    "tensor_list": [input_data, result]
    "bool_storage_as_bit":True
}
dsl.build(schedule, config)