Tvm export model failed for amr64


#1

when i use the code export model for arm64
onnx_graph = onnx.load(’/Users/mac/PycharmProjects/rk3399/chainer-nnvm-example/mobile_v2_is_mks.onnx’)
img = np.ones([1,3,96,96])
img *= 0.2
data_shape = img.shape
out_shape = (1, 136, 1, 1)
sym, params = nnvm.frontend.from_onnx(onnx_graph)
input_name = sym.list_input_names()[0]
key = “Android”
tracker = tvm.rpc.connect_tracker(‘192.168.10.71’, 9190)
remote = tracker.request(‘Android’, priority=0, session_timeout=600)
target = “llvm -target=arm64-linux-android”
target_host = None
ctx = remote.cpu(0)

graph, lib, params = nnvm.compiler.build(sym, target, {input_name: data_shape}, params=params, target_host=target_host)

lib.export_library(‘dpdm-aarch64.so’, ndk.create_shared)
with open(“dpdm-aarch64.json”, “w”) as fo:
fo.write(graph.json())
with open(“dpdm-aarch64.params”, “wb”) as fo:
fo.write(nnvm.compiler.save_param_dict(params))

remote.upload(‘dpdm-aarch64.so’)
rlib = remote.load_module(‘dpdm-aarch64.so’)
params = bytearray(open(“dpdm-aarch64.params”, “rb”).read())
graph = open(“dpdm-aarch64.json”).read()
fcreate = tvm.get_global_func(“tvm.graph_runtime.create”)
gmodule = fcreate(graph, rlib, ctx.device_type, ctx.device_id)
set_input, get_output, run = gmodule[“set_input”], gmodule[“get_output”], gmodule[“run”]
img = tvm.nd.array(img.astype(‘float32’))
set_input(input_name, img)
gmodule"load_params"
run()
output = tvm.nd.empty(out_shape, ctx=ctx)
get_output(0, output)

TVM_NDK_CC=/Users/mac/PycharmProjects/android-ndk-r19c/android-toolchain-arm64/bin/aarch64-linux-android-gcc

use above the code I can get some right model , but sometimes I will got the error ,like below, what is wrong? how can i do to sloved this problem, please help me!

Traceback (most recent call last):
File “run_mobile_onnx.py”, line 86, in
rlib = remote.load_module(‘dpdm-aarch64.so’)
File “/usr/local/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-macosx-10.13-x86_64.egg/tvm/rpc/client.py”, line 148, in load_module
return base._LoadRemoteModule(self._sess, path)
File “/usr/local/lib/python3.7/site-packages/tvm-0.6.dev0-py3.7-macosx-10.13-x86_64.egg/tvm/_ffi/_ctypes/function.py”, line 209, in call
raise get_last_ffi_error()
tvm.ffi.base.TVMError: TVMError: Except caught from RPC call: [07:54:07] /Users/mac/PycharmProjects/tvm/apps/android_rpc/app/src/main/jni/…/…/…/…/…/…/include/tvm/runtime/packed_func.h:702: Check failed: type_code == kModuleHandle (0 vs. 9) : expected ModuleHandle but get int