samskalicky commented on issue #14728: [MXNET-1386] fix for shape mismatch URL: https://github.com/apache/incubator-mxnet/pull/14728#issuecomment-486475086 Thanks @reminisce ! thats a better way to check. But I just realized that my test code was missing the whole point of the problem (shapes mismatching) because I made all the data shapes (1)! Heres code with different shapes that does indeed fail: ``` import os import mxnet as mx from collections import namedtuple from mxnet.base import _LIB, check_call, c_str, mx_uint, c_str_array Batch = namedtuple('Batch', ['data']) #setup whitelist op_names = ['elemwise_mul'] check_call(_LIB.MXSetSubgraphPropertyOpNames(c_str("default"), mx_uint(len(op_names)), c_str_array(op_names))) os.environ['MXNET_SUBGRAPH_BACKEND'] = 'default' #setup graph e = mx.sym.var('e') f = mx.sym.var('f') c = mx.sym.var('c') h = mx.sym.var('h') k = mx.sym.var('k') d = e * f b = c * d g = h * d j = k + g a = b + j #bind data ctx = mx.cpu() c_data = mx.nd.ones((1),ctx=ctx) e_data = mx.nd.ones((2),ctx=ctx) f_data = mx.nd.ones((3),ctx=ctx) h_data = mx.nd.ones((4),ctx=ctx) k_data = mx.nd.ones((5),ctx=ctx) args = {'c': c_data, 'e': e_data, 'h': h_data, 'k': k_data} aux = {} mod = mx.mod.Module(symbol=a,data_names=['f'],label_names=None,context=mx.cpu()) mod.bind(for_training=False, data_shapes=[('f',(3,))], label_shapes=mod._label_shapes) mod.set_params(args,aux) #export to symbol/params files mod.save_checkpoint('test',0) #reload from files sym, arg_params, aux_params = mx.model.load_checkpoint('test', 0) mod = mx.mod.Module(symbol=sym, context=ctx, label_names=None, data_names=['f']) mod.bind(for_training=False, data_shapes=[('f', (3,))], label_shapes=mod._label_shapes) mod.set_params(arg_params, aux_params, allow_missing=True) #infer mod.forward(Batch([mx.nd.ones((3,))])) print(mod.get_outputs()) ``` The failure is this message: ``` [17:27:24] src/executor/graph_executor.cc:1486: SubgraphPropertyOpNameSet for subgraph property default has been assigned a value. Please make sure it is initialized only for the testing purpose. Traceback (most recent call last): File "test.py", line 40, in <module> mod.set_params(args,aux) File "/usr/local/lib/python2.7/site-packages/mxnet/module/module.py", line 350, in set_params allow_extra=allow_extra) File "/usr/local/lib/python2.7/site-packages/mxnet/module/module.py", line 309, in init_params _impl(desc, arr, arg_params) File "/usr/local/lib/python2.7/site-packages/mxnet/module/module.py", line 297, in _impl cache_arr.copyto(arr) File "/usr/local/lib/python2.7/site-packages/mxnet/ndarray/ndarray.py", line 2074, in copyto return _internal._copyto(self, out=other) File "<string>", line 25, in _copyto File "/usr/local/lib/python2.7/site-packages/mxnet/_ctypes/ndarray.py", line 92, in _imperative_invoke ctypes.byref(out_stypes))) File "/usr/local/lib/python2.7/site-packages/mxnet/base.py", line 252, in check_call raise MXNetError(py_str(_LIB.MXGetLastError())) mxnet.base.MXNetError: [17:27:24] src/operator/contrib/../tensor/../elemwise_op_common.h:135: Check failed: assign(&dattr, vec.at(i)) Incompatible attr in node at 0-th output: expected [1], got [3] ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
