Hi folks, I’m working on getting RPC working with an internal Linux port for Hexagon as per my previous thread, and I’ve managed to successfully build the kernel as a shared object for uploading to the TVM runtime on my Hexagon Linux target.
I’m now running into an obscure error when I attempt to upload the kernel shared object to the target via RPC, I get the following error:
Traceback (most recent call last):
File “hexagon_linux_rpc.py”, line 87, in
remote.upload(path,remotepath)
File “/prj/dsp/qdsp6/austin/users/mariog/work/tvm/python/tvm/rpc/client.py”, line 86, in upload
self._remote_funcs[“upload”](target, blob)
File “/prj/dsp/qdsp6/austin/users/mariog/work/tvm/python/tvm/_ffi/_ctypes/function.py”, line 185, in call
ctypes.byref(ret_val), ctypes.byref(ret_tcode)))
File “/prj/dsp/qdsp6/austin/users/mariog/work/tvm/python/tvm/_ffi/base.py”, line 72, in check_call
raise TVMError(py_str(_LIB.TVMGetLastError()))
tvm._ffi.base.TVMError: [16:03:39] /prj/dsp/qdsp6/austin/users/mariog/work/tvm/src/runtime/rpc/rpc_session.cc:942: Check failed: code == RPCCode::kReturn code=4
What could be going wrong in this case? Here’s the relevant portion of my script:
import numpy as np
import tvm
from tvm import rpc
from tvm.contrib import util
from tvm.contrib import cc
M = 512
K = 512
N = 512
tgt = 'llvm -target=hexagon-unknown-elf -mcpu=hexagonv60 -mattr=+hvx,+hvx-length64b -mattr=-small-data'
ctx = tvm.context(tgt, 0)
dtype = "int8"
a = tvm.nd.array(np.random.random_integers(low=-128, high=128, size=(M, K)).astype(dtype), ctx)
b = tvm.nd.array(np.random.random_integers(low=-128, high=128, size=(K, N)).astype(dtype), ctx)
c = tvm.nd.array(np.zeros((M, N), dtype=dtype), ctx)
k = tvm.reduce_axis((0, K), 'k')
A = tvm.placeholder((M, K), name='A', dtype=dtype)
B = tvm.placeholder((K, N), name='B', dtype=dtype)
C = tvm.compute(
(M, N),
lambda x, y: tvm.sum(A[x, k] * B[k, y], axis=k),
name='C')
with tvm.build_config(data_alignment=64):
bn = 64
s = tvm.create_schedule(C.op)
xo, yo, xi, yi = s[C].tile(C.op.axis[0], C.op.axis[1], bn, bn)
k, = s[C].op.reduce_axis
ko, ki = s[C].split(k, factor=16)
s[C].reorder(xo, yo, ko, ki, xi, yi)
s[C].vectorize(yi)
f = tvm.build(s, [A, B, C], target=tgt, name='mmult')
assert f
temp = util.tempdir()
path = temp.relpath("mmult.so")
f.export_library(path,cc.create_shared,cc="/prj/qct/coredev/hexagon/austin/teams/hexagon-linux/builds/latest83/host/usr/bin/hexagon-linux-clang++")
host = '10.222.142.41'
port = 9090
remote = rpc.connect(host, port)
ctx = remote.cpu()
remote.upload(path) #<-- here's where it dies
func = remote.load_module("mmult.so",ctx)
Thanks,
Mario