[MO] Fix fetching output Place in moc_frontend (#8431)
This commit is contained in:
1 parent
5198c4644c
commit
7720d82366
3 files changed
+18
-60
No files matched your search
@@ -27,11 +27,6 @@ def decode_name_with_port(input_model: InputModel, node_name: str):
|
||||
found_node_names.append('Tensor:' + node_name)
|
||||
found_nodes.append(node)
|
||||
|
||||
node = input_model.get_place_by_operation_name(node_name)
|
||||
if node:
|
||||
found_node_names.append('Operation:' + node_name)
|
||||
found_nodes.append(node)
|
||||
|
||||
regexp_post = r'(.+):(\d+)'
|
||||
match_post = re.search(regexp_post, node_name)
|
||||
if match_post:
|
||||
|
||||
@@ -52,17 +52,6 @@ class TestMainFrontend(unittest.TestCase):
|
||||
model_stat = get_model_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert node
|
||||
|
||||
# Mock model has 'operation' operation place
|
||||
@mock_needed
|
||||
def test_decode_name_with_port_op(self):
|
||||
node = decode_name_with_port(self.model, "operation")
|
||||
model_stat = get_model_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert node
|
||||
|
||||
# pylint: disable=wrong-spelling-in-comment
|
||||
@@ -73,14 +62,13 @@ class TestMainFrontend(unittest.TestCase):
|
||||
decode_name_with_port(self.model, 'mocknoname')
|
||||
model_stat = get_model_statistic()
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
|
||||
# Mock model has both tensor and operation with same name and non-equal data
|
||||
# Mock model has both tensor and tensor:0 places with non equal data
|
||||
# Collision is expected
|
||||
@mock_needed
|
||||
def test_decode_name_with_port_collision_op_tensor(self):
|
||||
def test_decode_name_with_port_collision(self):
|
||||
with self.assertRaisesRegex(Error, 'Name\\ collision.*tensorAndOp*'):
|
||||
decode_name_with_port(self.model, 'tensorAndOp')
|
||||
decode_name_with_port(self.model, 'tensorAndOp:0')
|
||||
model_stat = get_model_statistic()
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
@@ -88,6 +76,7 @@ class TestMainFrontend(unittest.TestCase):
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert place_stat.is_equal_data > 0
|
||||
|
||||
|
||||
# Mock model has 'operation' and output port up to 10
|
||||
@mock_needed
|
||||
def test_decode_name_with_port_delim_op_out(self):
|
||||
@@ -96,7 +85,7 @@ class TestMainFrontend(unittest.TestCase):
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert place_stat.get_output_port == 1
|
||||
assert place_stat.lastArgInt == 7
|
||||
assert node
|
||||
@@ -109,39 +98,11 @@ class TestMainFrontend(unittest.TestCase):
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert place_stat.get_input_port == 1
|
||||
assert place_stat.lastArgInt == 7
|
||||
assert node
|
||||
|
||||
# Mock model has 'operation' and 'operation:0' op places, collision is expected
|
||||
@mock_needed
|
||||
def test_decode_name_with_port_delim_op_collision_out(self):
|
||||
with self.assertRaisesRegex(Error, 'Name\\ collision(?!.*Tensor.*).*operation\\:0*'):
|
||||
decode_name_with_port(self.model, 'operation:0')
|
||||
model_stat = get_model_statistic()
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert place_stat.is_equal_data > 0
|
||||
assert place_stat.get_output_port == 1
|
||||
assert place_stat.lastArgInt == 0
|
||||
|
||||
# Mock model has 'operation' and '0:operation' op places, collision is expected
|
||||
@mock_needed
|
||||
def test_decode_name_with_port_delim_op_collision_in(self):
|
||||
with self.assertRaisesRegex(Error, 'Name\\ collision(?!.*Tensor.*).*0\\:operation*'):
|
||||
decode_name_with_port(self.model, '0:operation')
|
||||
model_stat = get_model_statistic()
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert place_stat.is_equal_data > 0
|
||||
assert place_stat.get_input_port == 1
|
||||
assert place_stat.lastArgInt == 0
|
||||
|
||||
# Mock model has 'tensor' and 'tensor:0' tensor places, no collision is expected
|
||||
@mock_needed
|
||||
def test_decode_name_with_port_delim_tensor_no_collision_out(self):
|
||||
@@ -150,7 +111,7 @@ class TestMainFrontend(unittest.TestCase):
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert place_stat.get_output_port == 0
|
||||
assert node
|
||||
|
||||
@@ -162,7 +123,7 @@ class TestMainFrontend(unittest.TestCase):
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert place_stat.get_input_port == 0
|
||||
assert node
|
||||
|
||||
@@ -175,7 +136,7 @@ class TestMainFrontend(unittest.TestCase):
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert place_stat.get_output_port == 1
|
||||
assert place_stat.lastArgInt == 1234
|
||||
|
||||
@@ -188,7 +149,7 @@ class TestMainFrontend(unittest.TestCase):
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert place_stat.get_input_port == 1
|
||||
assert place_stat.lastArgInt == 1234
|
||||
|
||||
@@ -203,7 +164,7 @@ class TestMainFrontend(unittest.TestCase):
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert place_stat.get_output_port == 1
|
||||
assert place_stat.is_equal_data > 0
|
||||
assert node
|
||||
@@ -219,7 +180,7 @@ class TestMainFrontend(unittest.TestCase):
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert model_stat.get_place_by_operation_name == 1
|
||||
assert place_stat.get_input_port == 1
|
||||
assert place_stat.is_equal_data > 0
|
||||
assert node
|
||||
@@ -238,7 +199,7 @@ class TestMainFrontend(unittest.TestCase):
|
||||
place_stat = get_place_statistic()
|
||||
|
||||
assert model_stat.get_place_by_tensor_name == 1
|
||||
assert model_stat.get_place_by_operation_name == 3
|
||||
assert model_stat.get_place_by_operation_name == 2
|
||||
assert place_stat.get_input_port == 1
|
||||
assert place_stat.get_output_port == 1
|
||||
# At least 3 comparisons of places are expected
|
||||
|
||||
+5
-3
@@ -165,7 +165,7 @@ public:
|
||||
m_stat.m_get_output_port++;
|
||||
m_stat.m_lastArgInt = -1;
|
||||
m_stat.m_lastArgString = outputName;
|
||||
return std::make_shared<PlaceMockPy>();
|
||||
return std::make_shared<PlaceMockPy>(outputName);
|
||||
}
|
||||
|
||||
Place::Ptr get_output_port(const std::string& outputName, int outputPortIndex) const override
|
||||
@@ -199,6 +199,8 @@ public:
|
||||
|
||||
bool is_equal_data(Ptr another) const override
|
||||
{
|
||||
if (m_is_op)
|
||||
throw "Not implemented";
|
||||
m_stat.m_is_equal_data++;
|
||||
m_stat.m_lastArgPlace = another;
|
||||
std::shared_ptr<PlaceMockPy> mock = std::dynamic_pointer_cast<PlaceMockPy>(another);
|
||||
@@ -212,7 +214,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return mock->m_is_op == m_is_op;
|
||||
return !mock->m_is_op && m_name == mock->m_name;
|
||||
}
|
||||
|
||||
//---------------Stat--------------------
|
||||
@@ -284,7 +286,7 @@ class MOCK_API InputModelMockPy : public InputModel
|
||||
"tensor",
|
||||
"tensor:0",
|
||||
"0:tensor",
|
||||
"tensorAndOp",
|
||||
"tensorAndOp:0",
|
||||
"conv2d:0",
|
||||
"0:conv2d",
|
||||
"mock_input1",
|
||||
|
||||
Reference in new issue
Block a user