Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible attr in node elemwise_add0 at 1-th input: expected [1,180], got [180] #2599

Closed
mnboos opened this issue Feb 14, 2019 · 9 comments
Assignees

Comments

@mnboos
Copy link
Contributor

mnboos commented Feb 14, 2019

See: https://discuss.tvm.ai/t/nnvm-base-nnvmerror-cannot-find-argument-auto-pad/1644/3

This error occurs when I try to compile an ONNX model. I'm currently clarifying if I'm allowed to share the model or if it's confidential.

Traceback (most recent call last):
  File "/home/martin/Dev/s-tvm/compile_model.py", line 189, in <module>
    compile_model(model_name=model_name, model_path=model_path, output_dir=output_dir)
  File "/home/martin/Dev/s-tvm/compile_model.py", line 93, in compile_model
    dtype=input_dtype_dict)
  File "/home/martin/.local/lib/python3.6/site-packages/nnvm-0.8.0-py3.6.egg/nnvm/compiler/build_module.py", line 270, in build
    ishape, _ = graph_util.infer_shape(graph, **shape)
  File "/home/martin/.local/lib/python3.6/site-packages/nnvm-0.8.0-py3.6.egg/nnvm/compiler/graph_util.py", line 31, in infer_shape
    graph = graph.apply("InferShape")
  File "/home/martin/.local/lib/python3.6/site-packages/nnvm-0.8.0-py3.6.egg/nnvm/graph.py", line 234, in apply
    check_call(_LIB.NNGraphApplyPasses(self.handle, npass, cpass, ctypes.byref(ghandle)))
  File "/home/martin/.local/lib/python3.6/site-packages/nnvm-0.8.0-py3.6.egg/nnvm/_base.py", line 75, in check_call
    raise NNVMError(py_str(_LIB.NNGetLastError()))
nnvm._base.NNVMError: Error in operator elemwise_add0: [07:37:27] /home/martin/Dev/tvm/nnvm/src/top/nn/../elemwise_op_common.h:38: Check failed: assign(&dattr, (*vec)[i]) Incompatible attr in node elemwise_add0 at 1-th input: expected [1,180], got [180]

cc @srkreddy1238

@mnboos
Copy link
Contributor Author

mnboos commented Feb 18, 2019

See the attached model for reproducing the errors:

model.zip

@tqchen
Copy link
Member

tqchen commented Feb 25, 2019

@srkreddy1238 can you followup on this?

@mnboos
Copy link
Contributor Author

mnboos commented Mar 5, 2019

Any update on this?

@mnboos
Copy link
Contributor Author

mnboos commented Mar 13, 2019

@tqchen I would appreciate some feedback.

@srkreddy1238
Copy link
Contributor

@mnboos some how I missed it for a while. Will check it today

@srkreddy1238
Copy link
Contributor

@mnboos can you tell me the graph input shape (i.e shape for conv2d_1_input_0)?

@mnboos
Copy link
Contributor Author

mnboos commented Mar 19, 2019

According to https://lutzroeder.github.io/netron/ it's float32[1,101,161,1]

@srkreddy1238
Copy link
Contributor

@mnboos
#2850 work fine for this model.
BTW, I checked with relay instead of NNVM. I will back port the same to NNVM later.

Here is the sample code

import onnx
import numpy as np
import tvm
import tvm.relay as relay

onnx_model = onnx.load('speech_rand.onnx')
target = 'llvm'

input_name = 'conv2d_1_input_0'
shape_dict = {input_name: [1, 101, 161, 1]}
dtype_dict = {input_name: 'float32'}
sym, params = relay.frontend.from_onnx(onnx_model, shape_dict, dtype=dtype_dict)

with relay.build_config(opt_level=3):
    graph, lib, params = relay.build(sym, target=target, params=params)

x = np.random.uniform(size=(1, 101, 161, 1)).astype('float32')

from tvm.contrib import graph_runtime
dtype = 'float32'
m = graph_runtime.create(graph, lib, tvm.cpu(0))
# set inputs
m.set_input(input_name, tvm.nd.array(x.astype(dtype)))
m.set_input(**params)
# execute
m.run()
# get outputs
tvm_output = m.get_output(0)

print("Out Shape:", tvm_output.shape)

@tqchen tqchen closed this as completed Apr 1, 2019
@mnboos
Copy link
Contributor Author

mnboos commented Apr 2, 2019

Thanks for the fix to both of you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants