[MO] Fix ONNX Clamp-11 shape infer with no min/max inputs (#2603)

This commit is contained in:
Pavel Esir
2020-10-12 09:55:45 +03:00
committed by GitHub
parent ef2aa3ad67
commit 9a9b231c98
3 changed files with 8 additions and 9 deletions

View File

@@ -63,7 +63,7 @@ class ClampNormalizer(BackReplacementPattern):
clamp.out_port(0).get_connection().set_source(min_node.out_port(0))
clamp.in_port(2).get_connection().set_destination(min_node.in_port(1))
assert min_node is not None or max_node is not None, 'Clamp node should have either min or max input used'
rename_node(max_node if min_node is None else min_node, name)
rename_node(min_node if min_node is not None else max_node, name)
else:
a_clamp = AttributedClamp(graph, {'name': name, 'min': min_value, 'max': max_value}).create_node()
rename_node(a_clamp, name)

View File

@@ -73,7 +73,7 @@ class AttributedClampNormalizerTests(unittest.TestCase):
(flag, resp) = compare_graphs(graph, ref_graph, 'result')
self.assertTrue(flag, resp)
def test_no_2nd_input(self):
def test_no_max_input(self):
nodes = {
**regular_op_with_shaped_data('placeholder', [1, 3, 20, 20], {'type': 'Parameter'}),
**regular_op_with_shaped_data('a_clamp', [1, 3, 20, 20], {'type': None, 'op': 'Clamp'}),
@@ -95,7 +95,7 @@ class AttributedClampNormalizerTests(unittest.TestCase):
(flag, resp) = compare_graphs(graph, ref_graph, 'result')
self.assertTrue(flag, resp)
def test_no_1st_input(self):
def test_no_min_input(self):
nodes = {
**regular_op_with_shaped_data('placeholder', [1, 3, 20, 20], {'type': 'Parameter'}),
**regular_op_with_shaped_data('a_clamp', [1, 3, 20, 20], {'type': None, 'op': 'Clamp'}),