From 42d81ccaee1a2c375c55de1c20bd75030dfdaae8 Mon Sep 17 00:00:00 2001 From: Wenhao Hu <fumihwh@gmail.com> Date: Sun, 6 May 2018 06:36:09 +0900 Subject: [PATCH] raise error when cannot get shape in reshape (#467) * raise error when cannot get shape in reshape * fix pylint --- nnvm/python/nnvm/frontend/onnx.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nnvm/python/nnvm/frontend/onnx.py b/nnvm/python/nnvm/frontend/onnx.py index fd4f0bb47..2a9540029 100644 --- a/nnvm/python/nnvm/frontend/onnx.py +++ b/nnvm/python/nnvm/frontend/onnx.py @@ -246,6 +246,8 @@ class Reciprocal(OnnxOpConverter): class Reshape(OnnxOpConverter): + """ Operator converter for Reshape. + """ @classmethod def _impl_v1(cls, inputs, attr, params): @@ -253,9 +255,11 @@ class Reshape(OnnxOpConverter): @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): -- GitLab