Can not import relay in tvm runtime


#1

I built and installed tvm runtime
when I tried to import relay I got the following error

    from tvm import relay
  File "/usr/local/lib/python3.5/dist-packages/tvm-0.6.dev0-py3.5-linux-aarch64.egg/tvm/relay/__init__.py", line 24, in <module>
    from . import expr_functor
  File "/usr/local/lib/python3.5/dist-packages/tvm-0.6.dev0-py3.5-linux-aarch64.egg/tvm/relay/expr_functor.py", line 24, in <module>
    from .op import Op
  File "/usr/local/lib/python3.5/dist-packages/tvm-0.6.dev0-py3.5-linux-aarch64.egg/tvm/relay/op/__init__.py", line 20, in <module>
    from .op import get, register, register_schedule, register_compute, register_gradient, \
  File "/usr/local/lib/python3.5/dist-packages/tvm-0.6.dev0-py3.5-linux-aarch64.egg/tvm/relay/op/op.py", line 19, in <module>
    import topi
ImportError: No module named 'topi'

but I can not install topi because make runtime does not build libtvm_topi.so.


#2

Do we need relay for runtime?


#3

I just saw that some people use relay.load_param_dict during the inference:

params = relay.load_param_dict(bytearray(open(path_param, "rb").read()))
m.set_input(**params)

we can probably replace it with

params = bytearray(open(path_param, "rb").read())
m.load_params(params)

What you think?


#4

Yes. We can load params with module method.


#5

code example

import numpy as np
import tvm
import time
 
from tvm.contrib import graph_runtime
 
data_shape = (1, 3, 512, 512)
loaded_json = open("yolo_graph.json").read()
loaded_lib = tvm.module.load("yolo_lib.tar")
loaded_params = bytearray(open("yolo_param.params", "rb").read())
input_data = tvm.nd.array(np.random.uniform(size=data_shape).astype("float32"))
 
ctx = tvm.gpu(0)
module = graph_runtime.create(loaded_json, loaded_lib, ctx)
module.load_params(loaded_params)
...