-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[RELAY][ONNX] Support Deriving channels when it is not provided in AlterLayout. #2972
Conversation
Thanks for the contribution, please add a regression test case as per https://docs.tvm.ai/contribute/code_review.html#ensure-test-coverage |
@tqchen & All, Added testcases, with some comments:
|
@merrymercy , @tqchen , Regarding testcase:
|
LGTM. Only some nits. You can batch my suggestions and commit them. |
It is done, committed the suggestion comment even in +one more place, now all are covered. |
@cbalint13 @tqchen Thanks. It is merged! |
@@ -327,11 +327,16 @@ def _alter_conv2d_layout(attrs, inputs, tinfo, F): | |||
|
|||
copy_inputs = [s for s in inputs] | |||
new_attrs = {k : attrs[k] for k in attrs.keys()} | |||
|
|||
if F == tvm.relay.op: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merrymercy @cbalint13 This call fails if user uses nnvm.compiler.build
. You need to import relay from tvm
first. It fails only for nnvm.compiler.build
, not for relay.build
Compile using nnvm...
Traceback (most recent call last):
File "./compile.py", line 62, in <module>
graph, lib, params = nnvm.compiler.build(sym, target, shape={"data": data_shape}, dtype=dtype, params=params, target_host=target_host)
File "/usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/compiler/build_module.py", line 297, in build
graph = optimize(graph, shape, dtype, layout)
File "/usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/compiler/build_module.py", line 186, in optimize
graph = graph.apply(["InferShape", "InferType", "AlterOpLayout"])
File "/usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/graph.py", line 250, in apply
check_call(_LIB.NNGraphApplyPasses(self.handle, npass, cpass, ctypes.byref(ghandle)))
File "/usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/_base.py", line 91, in check_call
raise NNVMError(py_str(_LIB.NNGetLastError()))
nnvm._base.NNVMError: AttributeError: module 'tvm' has no attribute 'relay'
Stack trace:
if F == tvm.relay.op:
File "/usr/local/lib/python3.6/dist-packages/topi-0.6.dev0-py3.6.egg/topi/x86/conv2d.py", line 331, in _alter_conv2d_layout
return dispatch_dict[k](*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tvm-0.6.dev0-py3.6-linux-x86_64.egg/tvm/target.py", line 372, in dispatch_func
File "</usr/local/lib/python3.6/dist-packages/decorator.py:decorator-gen-18>", line 2, in conv2d_alter_layout
return topi.nn.conv2d_alter_layout(attrs, inputs, tinfos, sym)
File "/usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/top/nn.py", line 194, in alter_conv2d_layout
File "tvm/_ffi/_cython/./function.pxi", line 55, in tvm._ffi._cy3.core.tvm_callback
Stack trace:
[bt] (0) /usr/local/lib/python3.6/dist-packages/tvm-0.6.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0x8e7f8b) [0x7f2ecdc9af8b]
[bt] (1) /usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/libnnvm_compiler.so(+0x12ab65) [0x7f2ec8404b65]
[bt] (2) /usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/libnnvm_compiler.so(+0xe5623) [0x7f2ec83bf623]
[bt] (3) /usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/libnnvm_compiler.so(+0xe7c93) [0x7f2ec83c1c93]
[bt] (4) /usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/libnnvm_compiler.so(+0xea0c9) [0x7f2ec83c40c9]
[bt] (5) /usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/libnnvm_compiler.so(+0xc0800) [0x7f2ec839a800]
[bt] (6) /usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/libnnvm_compiler.so(+0x85a11) [0x7f2ec835fa11]
[bt] (7) /usr/local/lib/python3.6/dist-packages/nnvm-0.8.0-py3.6.egg/nnvm/libnnvm_compiler.so(NNGraphApplyPasses+0x320) [0x7f2ec833df00]
[bt] (8) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call_unix64+0x4c) [0x7f2eee480dae]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Could make it in a new PR ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we had nnvm compilation tests then your PR would not pass CI tests and you needed to fix your code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
- Will add as a new PR today, with testcase using nnvm symbols instead of relay.op
- I'll keep you on Cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbalint13 I'm not sure we want to import relay
if user decided to use nnvm.compiler.build
.
Can we use string comparison here? e.g.
if F.__name__ == 'tvm.relay.op':
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continue discussion in
#3044
Dear All,
I propose this patch that address issue #2941 and all related to subject of altering conv2d layout.
infer_channels()
.