You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by Wu Zheng via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/03/26 03:07:06 UTC
[Apache TVM Discuss] [Questions] Data type error while using
tensorize
hello! I am trying to use tensorize on my declared conv2d operator. here is my code.import numpy as np
> import tvm
> from tvm import te
> from tvm import autotvm
> from tvm import topi
> from zte.enviroment import get_env
> from zte.intrin import gemm
>
> data = tvm.te.placeholder((1, 64, 112, 112), dtype="int16", name="data")
> kernel = tvm.te.placeholder((64, 64, 3, 3), dtype="int16", name="kernel")
>
> out_w = 110
> out_h = 110
> out_dtype = "int32"
> oshape = (1, 64, 110, 110)
>
> # define the conv2d operator over the padded data
> c = te.reduce_axis((0, 64), name="c")
> k_h = te.reduce_axis((0, 3), name="k_h")
> k_w = te.reduce_axis((0, 3), name="k_w")
> hstride, wstride = 1, 1
> res = te.compute(
> oshape,
> lambda n, o, h, w: te.sum(
> data[n, c, h * hstride + k_h, w * wstride + k_w].astype(out_dtype)
> * kernel[o, c, k_h, k_w].astype(out_dtype),
> axis=[c, k_h, k_w],
> ),
> name="res",
> tag="conv2d_dense",
> )
>
> s = tvm.te.create_schedule(res.op)
>
> env = get_env()
>
> n_o, o_o, h_o, w_o = s[res].op.axis
> c_in, h_1, w_1 = s[res].op.reduce_axis
>
> h_w_data = s[res].fuse(h_o, w_o)
> h_w_kernel = s[res].fuse(k_h, k_w)
> s[res].reorder(n_o, h_w_kernel, h_w_data, o_o, c_in)
>
> xo, yo, xi, yi = s[res].tile(o_o, c_in, x_factor=16, y_factor=16)
> x_y_fuse = s[res].fuse(xo, yo)
> data_out, data_in = s[res].split(h_w_data, 256)
>
> s[res].tensorize(h_w_kernel, gemm(env, 0, 16, 16, 16))
>
> code = tvm.lower(s, [data, kernel, res], simple_mode=True)
> print(code)
And I got this after I run this program.
Traceback (most recent call last):
File "/home/tonywu/Documents/tvm/zte/test_con2d.py", line 53, in <module>
s[res].tensorize(h_w_kernel, gemm(env, 0, 16, 16, 16))
File "/home/tonywu/Documents/tvm/zte/intrin.py", line 60, in gemm
wgt_layout = tvm.tir.decl_buffer(
File "/home/tonywu/Documents/tvm/python/tvm/tir/buffer.py", line 254, in decl_buffer
return _ffi_api.Buffer(
File "/home/tonywu/Documents/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
3: TVMFuncCall
2: _ZNSt17_Function_handlerIFvN3
1: tvm::tir::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#3}::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const [clone .isra.0]
0: tvm::runtime::TVMPODValue_::operator int() const
File "/home/tonywu/Documents/tvm/include/tvm/runtime/packed_func.h", line 513
TVMError: ---------------------------------------------------------------
An internal invariant was violated during the execution of TVM.
Please read TVM's error reporting guidelines.
More details can be found here: https://discuss.tvm.ai/t/error-reporting/7793.
---------------------------------------------------------------
Check failed: type_code_ == kDLInt: expected int but got float
Process finished with exit code 1
I'd appreciate it if you could help me solve this problem. Thank you!
---
[Visit Topic](https://discuss.tvm.apache.org/t/data-type-error-while-using-tensorize/9530/1) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/4d76d8c96d7d4f07ca424bd0b67aff6b29b1abdf57f63ba31547953069e82c23).
[Apache TVM Discuss] [Questions] Data type error while using
tensorize
Posted by Wu Zheng via Apache TVM Discuss <no...@discuss.tvm.ai>.
where to set elem_offset?
---
[Visit Topic](https://discuss.tvm.apache.org/t/data-type-error-while-using-tensorize/9530/3) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/80456542a29b127fef1a1b2adba9cdfbfd4e044968fba678d7a156b1e42991ce).
[Apache TVM Discuss] [Questions] Data type error while using
tensorize
Posted by Wu Zheng via Apache TVM Discuss <no...@discuss.tvm.ai>.
I see, the bug is fixed, thanks!
---
[Visit Topic](https://discuss.tvm.apache.org/t/data-type-error-while-using-tensorize/9530/4) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/73809ba2acc149bc9c301939c3d417a34de3a319c77091064cd21f066a7ade49).
[Apache TVM Discuss] [Questions] Data type error while using
tensorize
Posted by leeexyz via Apache TVM Discuss <no...@discuss.tvm.ai>.
I guess you declared elem_offset as a floating number, let's say 1.0 but not 1. :)
---
[Visit Topic](https://discuss.tvm.apache.org/t/data-type-error-while-using-tensorize/9530/2) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/26060140362cc7733bd445714b8c34ba25d42eb8d044cdfbe12e75098a5ff877).