Skip to content

Commit 9738d79

Browse files
author
Anna Grebneva
authored
Expanded set of suffixes for outputs in postprocess_output_name by regular expression (#3453)
1 parent 18a53a6 commit 9738d79

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

tools/accuracy_checker/openvino/tools/accuracy_checker/adapters/adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def process(self, raw, identifiers, frame_meta):
5151
def configure(self):
5252
pass
5353

54-
def check_output_name(self, output_name, outputs, suffix=('/sink_port_0', ':0')):
54+
def check_output_name(self, output_name, outputs, suffix=('/sink_port_', ':')):
5555
return postprocess_output_name(
5656
output_name, outputs, suffix, self.additional_output_mapping, raise_error=False)
5757

tools/accuracy_checker/openvino/tools/accuracy_checker/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import struct
2424
import sys
2525
import zlib
26+
import re
2627
from enum import Enum
2728

2829
from pathlib import Path
@@ -939,7 +940,7 @@ def parse_partial_shape(partial_shape):
939940

940941

941942
def postprocess_output_name(
942-
output_name, outputs, suffix=('/sink_port_0', ':0', '/sink_port_1'), additional_mapping=None, raise_error=True
943+
output_name, outputs, suffix=('/sink_port_', ':'), additional_mapping=None, raise_error=True
943944
):
944945
suffixes = [suffix] if isinstance(suffix, str) else suffix
945946
outputs = outputs[0] if isinstance(outputs, list) else outputs
@@ -948,10 +949,12 @@ def postprocess_output_name(
948949
if additional_mapping and output_name in additional_mapping:
949950
return additional_mapping[output_name]
950951
for suffix_ in suffixes:
951-
if suffix_ in output_name:
952-
preprocessed_output_name = output_name.replace(suffix_, '')
952+
matches = re.findall(r'{}\d+'.format(suffix_), output_name)
953+
if matches:
954+
preprocessed_output_name = output_name.replace(matches[0], '')
953955
else:
954-
preprocessed_output_name = '{}{}'.format(output_name, suffix_)
956+
suffix_regex = re.compile(output_name + suffix_ + r'\d+')
957+
preprocessed_output_name = [layer_name for layer_name in outputs if suffix_regex.match(layer_name)][0]
955958
if preprocessed_output_name in outputs:
956959
return preprocessed_output_name
957960
if raise_error:

0 commit comments

Comments
 (0)