Hi, I can’t run nnvm_get_start.py in tutorial.
It seems to be changed the parameter number from 3 to 4.
the error :
Traceback (most recent call last):
File "nnvm_quick_start.py", line 83, in <module>
net, target, shape={"data": data_shape}, params=params)
File "/home/~~~ /tvm/nnvm/python/nnvm/compiler/build_module.py", line 281, in build
graph = optimize(graph, shape, dtype, layout)
File "/home/~~~ /tvm/nnvm/python/nnvm/compiler/build_module.py", line 170, in optimize
graph = graph.apply(["InferShape", "InferType", "AlterOpLayout"])
File "/home/~~~ /tvm/nnvm/python/nnvm/graph.py", line 234, in apply
check_call(_LIB.NNGraphApplyPasses(self.handle, npass, cpass, ctypes.byref(ghandle)))
File "/home/~~~ /tvm/nnvm/python/nnvm/_base.py", line 75, in check_call
raise NNVMError(py_str(_LIB.NNGetLastError()))
nnvm._base.NNVMError: TVMCall CFunc Error:
Traceback (most recent call last):
File "/home/jenny/.local/lib/python2.7/site-packages/tvm-0.5.dev0-py2.7-linux-x86_64.egg/tvm/_ffi/_ctypes/function.py", line 55, in cfun
rv = local_pyfunc(*pyargs)
File "/home/~~~ /tvm/nnvm/python/nnvm/top/nn.py", line 174, in alter_conv2d_layout
return topi.nn.conv2d_alter_layout(attrs, inputs, tinfos, sym)
TypeError: conv2d_alter_layout() takes exactly 3 arguments (4 given)
I think the below commit is related it.
commit 426e3bb0a8e86bb48a25b950fd8ef965ca5d370b
Refs: v0.4-533-g426e3bb
Author: Lianmin Zheng <mercy_zheng@sjtu.edu.cn>
AuthorDate: Tue Jan 8 00:46:34 2019 +0800
Commit: Tianqi Chen <tqchen@users.noreply.github.com>
CommitDate: Mon Jan 7 08:46:34 2019 -0800
diff --git a/nnvm/python/nnvm/top/nn.py b/nnvm/python/nnvm/top/nn.py
index a37a5d7..3aaafae 100644
--- a/nnvm/python/nnvm/top/nn.py
+++ b/nnvm/python/nnvm/top/nn.py
@@ -153,7 +153,25 @@ def schedule_conv2d(attrs, outs, target):
@reg.register_alter_op_layout("conv2d")
def alter_conv2d_layout(attrs, inputs, tinfos):
- return topi.nn.conv2d_alter_layout(attrs, inputs, tinfos)
+ """Replace conv2d op with other layouts or algorithms"""
+ import nnvm.symbol as sym
+
+ # map relay op names to nnvm op names
+ sym.contrib_conv2d_winograd_without_weight_transform = \
+ sym.contrib.conv2d_winograd_without_weight_transform
+ sym.contrib_conv2d_winograd_weight_transform = \
+ sym.contrib.conv2d_winograd_weight_transform
+ sym.nn = sym
+
+ # map relay argument names to nnvm argument names
+ raw_reshape = sym.reshape
+ def _reshape(*args, **kwargs):
+ if "newshape" in kwargs:
+ kwargs['shape'] = kwargs.pop('newshape')
+ return raw_reshape(*args, **kwargs)
+ sym.reshape = _reshape
+
+ return topi.nn.conv2d_alter_layout(attrs, inputs, tinfos, sym)