更新时间:2021-03-18 GMT+08:00
分享

异常处理

接口如果执行异常,一般都是由于错误的入参引起的。下边例子给出了tensor_list不全给出的错误信息。

代码片段

data = tvm.placeholder(shape, name="data", dtype=inp_dtype)
with tvm.target.cce():
    res = te.lang.cce.vabs(data)
    sch = generic.auto_schedule(res)
    config = {"print_ir": need_print,
    "need_build": need_build,
    "name": kernel_name,
    "tensor_list": [res]}
te.lang.cce.cce_build_code(sch, config)

执行会发生如下错误:

Traceback (most recent call last):
  File "llt/tensor_engine/ut/testcase_python/tf_abs/test_tf_abs_cce.py", line 71, in test_cce_tf_abs_99991_fp16
    tf_abs_cce((99991,), dtype = "Float16", need_build = False, need_print = False, kernel_name = "cce_tf_abs")
  File "/home1/repotvm/tensor_engine/topi/python/topi/cce/tf_abs.py", line 68, in tf_abs_cce
    te.lang.cce.cce_build_code(sch, config)
  File "/home1/repotvm/tensor_engine/python/te/lang/cce/te_schedule/cce_schedule.py", line 381, in cce_build_code
    _build(sch, tensor_list, local_config_map["name"])
  File "/home1/repotvm/tensor_engine/python/te/lang/cce/te_schedule/cce_schedule.py", line 338, in _build
    mod = tvm.build(sch, tensor_list, device, name=name)
  File "/home1/repotvm/tensor_engine/python/te/tvm/build_module.py", line 432, in build
    binds=binds)
  File "/home1/repotvm/tensor_engine/python/te/tvm/build_module.py", line 353, in lower
    stmt = ir_pass.StorageFlatten(stmt, binds, 64)
  File "/home1/repotvm/tensor_engine/python/te/tvm/_ffi/function.py", line 280, in my_api_func
    return flocal(*args)
  File "/home1/repotvm/tensor_engine/python/te/tvm/_ffi/_ctypes/function.py", line 183, in __call__
    ctypes.byref(ret_val), ctypes.byref(ret_tcode)))
  File "/home1/repotvm/tensor_engine/python/te/tvm/_ffi/base.py", line 66, in check_call
    raise TVMError(py_str(_LIB.TVMGetLastError()))
TVMError: [17:12:02] /home1/repotvm/tensor_engine/src/pass/storage_flatten.cc:249: Check failed: it != buf_map_.end() Cannot find allocated buffer for placeholder(data, 0x27d7290)

参数更正为如下情况后,问题得到解决。

"tensor_list" : [data, res]
分享:

    相关文档

    相关产品