Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation] example code piece in comment of tvm.build_module.build() not working #4190

Closed
optima2005 opened this issue Oct 24, 2019 · 3 comments

Comments

@optima2005
Copy link
Contributor

The comment under tvm.build_module.build() gives the following example code piece:

        n = 2
        A = tvm.placeholder((n,), name='A')
        B = tvm.placeholder((n,), name='B')
        C = tvm.compute(A.shape, lambda *i: A(*i) + B(*i), name='C')
        s1 = tvm.create_schedule(C.op)
        s2 = topi.cpp.cuda.schedule_injective("cuda", [C])
        f1 = tvm.lower(s1, [A, B, C], name="test_add1")
        f2 = tvm.lower(s2, [A, B, C], name="test_add2")
        m = tvm.build({"llvm": [f1], "cuda": [f2]}, target_host="llvm")

But it reports the below error when running them,

Traceback (most recent call last):

  File "test1.py", line 55, in <module>
    s2 = topi.cpp.cuda.schedule_injective("cuda",[C])

  File "~/conda/envs/py36/lib/python3.6/site-packages/tvm-0.6.dev0-py3.6-linux-ppc64le.egg/tvm/_ffi/_ctypes/function.py", line 211, in __call__
    raise get_last_ffi_error()

tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (3) ~/conda/envs/py36/lib/python3.6/site-packages/tvm-0.6.dev0-py3.6-linux-ppc64le.egg/tvm/libtvm.so(TVMFuncCall+0x90) [0x7ffe9f8f3ef0]
  [bt] (2) ~/conda/envs/py36/lib/python3.6/site-packages/topi-0.6.dev0-py3.6.egg/topi/libtvm_topi.so(+0x642d0) [0x7ffe97d942d0]
  [bt] (1) ~/conda/envs/py36/lib/python3.6/site-packages/tvm-0.6.dev0-py3.6-linux-ppc64le.egg/tvm/libtvm.so(tvm::Target tvm::runtime::TVMArgValue::AsNodeRef<tvm::Target>() const+0x160) [0x7ffe9efe69d0]
  [bt] (0) ~/conda/envs/py36/lib/python3.6/site-packages/tvm-0.6.dev0-py3.6-linux-ppc64le.egg/tvm/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x60) [0x7ffe9ee4de70]
  File "~/tvm/include/tvm/packed_func_ext.h", line 141
TVMError: Check failed: type_code_ == kNodeHandle (11 vs. 8) : expected NodeHandle but get str

It seems they should be modified as following to work:

n = 2
A = tvm.placeholder((n,), name='A')
B = tvm.placeholder((n,), name='B')
C = tvm.compute(A.shape, lambda *i: A(*i) + B(*i), name='C')
s1 = tvm.create_schedule(C.op)
with tvm.target.cuda() as cuda_tgt:
    s2 = topi.cpp.cuda.schedule_injective(cuda_tgt,[C])
    f1 = tvm.lower(s1, [A, B, C], name="test_add1")
    f2 = tvm.lower(s2, [A, B, C], name="test_add2")
    m = tvm.build({"llvm": [f1], "cuda": [f2]}, target_host="llvm")
@tqchen
Copy link
Member

tqchen commented Oct 24, 2019

good catch, can you send a PR to fix the problem?

@optima2005
Copy link
Contributor Author

ok

@OriAlpha
Copy link

It must be the miss-match of the Cuda used while compiling the TVM. For example, while compiling the TVM used different version and now your using different version of CUDA.

@tqchen tqchen closed this as completed Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants