I guess the error maybe caused by model load difference betweenthe onnx and
mxnet model, focusing on ` relay.Function` and `tvm.IRModule.from_expr`,
**1. I am not sure what do they used for, and what should I write for onnx
model?**
```
def customed_network_from_onnx(model_path, input_shapes, dtype="float32"):
import onnx
onnx_model = onnx.load(model_path)
mod, params = relay.frontend.from_onnx(onnx_model, input_shapes,
dtype=dtype)
return mod, params
def get_network(name, batch_size, input_name=None, input_size=None):
...
elif name == 'mxnet':
# an example for mxnet model
from mxnet.gluon.model_zoo.vision import get_model
block = get_model('resnet18_v1', pretrained=True)
mod, params = relay.frontend.from_mxnet(block, shape={'data':
input_shape}, dtype=dtype)
net = mod["main"]
net = relay.Function(net.params, relay.nn.softmax(net.body), None,
net.type_params, net.attrs)
mod = tvm.IRModule.from_expr(net)
elif name.split('.')[-1] == 'onnx':
model_path = '../data/' + name
input_shape = (batch_size, 3, input_size, input_size)
input_shape_dict = {input_name: input_shape}
mod, params = customed_network_from_onnx(model_path, input_shape_dict)
output_shape = (batch_size, 2)
...
```
**2. The breakpoint comes at `tophub_context = autotvm.util.EmptyContext()` for
auto-tune mode, while program goes into `tophub_context =
autotvm.tophub.context(list(target.values()))` with auto-tune closed.**
In `relay.build(mod, target=target, params=params)`:
```
# If current dispatch context is fallback context (the default root
context),
# then load pre-tuned parameters from TopHub
if isinstance(autotvm.DispatchContext.current, autotvm.FallbackContext):
tophub_context = autotvm.tophub.context(list(target.values()))
else:
tophub_context = autotvm.util.EmptyContext()
```
According analysis of 1 and 2, I guess the load method of onnx model caused the
problem.
Anyone can give me some advice to auto-tune my own onnx model?
---
[Visit
Topic](https://discuss.tvm.ai/t/auto-tune-finished-but-build-error-occurs-for-my-own-onnx-model/6409/2)
to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click
here](https://discuss.tvm.ai/email/unsubscribe/320deaee100a51303bbcc3434a3dde5d54d68c6d61770dcaf34b17a7704b5be2).