Can not import relay in tvm runtime


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/", 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/", 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/", 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/", line 19, in <module>
    import topi
ImportError: No module named 'topi'

but I can not install topi because make runtime does not build


Do we need relay for runtime?


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()))

we can probably replace it with

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

What you think?


Yes. We can load params with module method.


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)