I am using Ansor to tune to get a schedule,but an error occured when calling tvm.build() The error message is below:
Did you forget to bind?
Variable `tensor_2` is directly accessed by host memory (it is not contained in a thread environment or in the function arguments.
Variable `conv0_weight` is directly accessed by host memory (it is not contained in a thread environment or in the function arguments.
Variable `data` is directly accessed by host memory (it is not contained in a thread environment or in the function arguments.
File "/home/sun/gitDownload/tvm/src/tir/analysis/verify_memory.cc", line 202
RuntimeError: Memory verification failed with the following errors:
PrimFunc([data, conv0_weight, tensor_2]) attrs={"global_symbol": "default_function", "tir.noalias": (bool)1, "target": cuda -keys=cuda,gpu -max_num_threads=1024 -thread_warp_size=32}......
Here is my source code:
@auto_scheduler.register_workload
def fused_12():
data = te.placeholder((1,3,224,224), name='data', dtype='float32')
tensor_0 = te.compute((1,3,112,112,7,7), lambda n,c,h1,w1,kh,kw: te.if_then_else(te.all(-3+2*h1+kh>=0,-3+2*h1+kh<224,-3+kw+2*w1>=0,-3+kw+2*w1<224),data[n,c,-3+2*h1+kh,-3+kw+2*w1],tvm.tir.const(0, dtype='float32')),name = 'tensor_0')
conv0_weight = te.placeholder((64,3,7,7), name='conv0_weight', dtype='float32')
# tensor_1 = te.compute((1,64,3,112,112,7,7), lambda n,oc,c,h1,w1,kh,kw: tensor_0[n,c,h1,w1,kh,kw] * conv0_weight[oc,c,kh,kw], name='tensor_1',)
c = te.reduce_axis((0,3),name='c')
kh = te.reduce_axis((0,7),name='kh')
kw = te.reduce_axis((0,7),name='kw')
tensor_2 = te.compute((1,64,112,112), lambda n,oc,h1,w1: te.sum(tensor_0[n,c,h1,w1,kh,kw] * conv0_weight[oc,c,kh,kw],axis = [c,kh,kw]), name='tensor_2')
return [data,conv0_weight,tensor_2]
target = tvm.target.Target("cuda")
target_host = tvm.target.Target("llvm -mtriple=aarch64-linux-gnu")
tune_option= auto_scheduler.TuningOptions(num_measure_trials=10, measure_callbacks=[auto_scheduler.RecordToFile('fused_12.json')],)
task = tvm.auto_scheduler.SearchTask(func=fused_12, args=(), target=target)
task.tune(tune_option)
sch, args = task.apply_best('fused_12.json')
fused_12_func = tvm.build(sch,args,target=target,target_host=target_host)
And my enviroment: tvm0.8 Ubuntu18.04
Thanks a lot!