Skip to content

Commit

Permalink
raise error when cannot get shape in reshape (dmlc#467)
Browse files Browse the repository at this point in the history
* raise error when cannot get shape in reshape

* fix pylint
  • Loading branch information
fumihwh authored and tqchen committed May 5, 2018
1 parent 63bd093 commit 8c0a103
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/nnvm/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,20 @@ def _impl_v1(cls, inputs, attr, params):


class Reshape(OnnxOpConverter):
""" Operator converter for Reshape.
"""

@classmethod
def _impl_v1(cls, inputs, attr, params):
return _sym.reshape(inputs[0], shape=attr['shape'])

@classmethod
def _impl_v5(cls, inputs, attr, params):
return _sym.reshape(
inputs[0],
shape=tuple(params[inputs[1].list_output_names()[0]].asnumpy()))
if inputs[1].list_output_names()[0] in params:
shape = tuple(params[inputs[1].list_output_names()[0]].asnumpy())
else:
raise RuntimeError('Shape is not contained in graph initializer.')
return _sym.reshape(inputs[0], shape=shape)


class Scale(OnnxOpConverter):
Expand Down

0 comments on commit 8c0a103

Please sign in to comment.