[MO] update error message when reverse infer was not successful (#10576)

* update error message when reverse infer was not successful

* corrected message when there are several undefined Parameters
This commit is contained in:
Pavel Esir 2022-02-22 13:51:10 +03:00 committed by GitHub
parent efd3c119fa
commit 3d223ebc2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -353,3 +353,20 @@ def reverse_infer(graph: Graph, nodes: list):
log.debug('Inputs:')
log_debug_dict(node.in_nodes(), 'inputs')
parameters_with_no_shape = []
for node in graph.get_op_nodes(op='Parameter'):
if not node.has_valid('shape'):
parameters_with_no_shape.append(node)
if len(parameters_with_no_shape) == 0:
return
parameters_names = ''
for idx, node in enumerate(parameters_with_no_shape):
parameters_names += "'{}'".format(node.soft_get('name', node.id))
if idx < len(parameters_with_no_shape) - 1:
parameters_names += ', '
if len(parameters_with_no_shape) > 0:
raise Error("Model Optimizer is unable to deduce input shapes for the following Parameter nodes: {}. "
"Please use cli options --input or --input_shape to set model input shape.".format(parameters_names))

View File

@ -180,7 +180,7 @@ class TestElementwiseReverseInfer(unittest.TestCase):
def test_reverse_infer_6(self):
# both output and input has the same rank, cannot deduce other inputs rank
with self.assertRaisesRegex(Error, 'Stopped shape/value propagation'):
with self.assertRaisesRegex(Error, "Model Optimizer is unable to deduce input shapes"):
self.build_and_test_reverse_inference(inp_shape_1=[dyn, dyn, dyn, dyn],
inp_shape_2=None,
out_shape=[dyn, dyn, 4, 1],