Browse Source

Optimize converted rate algorithm

tags/v1.0.0
moran 5 years ago
parent
commit
a5bec2b67a
3 changed files with 15 additions and 5 deletions
  1. +1
    -1
      mindinsight/mindconverter/graph_based_converter/constant.py
  2. +13
    -3
      mindinsight/mindconverter/graph_based_converter/report_generator.py
  3. +1
    -1
      mindinsight/mindconverter/graph_based_converter/third_party_graph/input_node.py

+ 1
- 1
mindinsight/mindconverter/graph_based_converter/constant.py View File

@@ -39,4 +39,4 @@ class NodeType(Enum):
OPERATION = "operation" OPERATION = "operation"
CLASS = "class" CLASS = "class"
FUNC = "func" FUNC = "func"
INPUT = "DataInput"
INPUTS = "DataInput"

+ 13
- 3
mindinsight/mindconverter/graph_based_converter/report_generator.py View File

@@ -109,12 +109,14 @@ class ReportGenerator(metaclass=abc.ABCMeta):
code_lines = code.split(NEW_LINE) code_lines = code.split(NEW_LINE)
num_all_lines = len(code_lines) num_all_lines = len(code_lines)


num_unconverted_line = 0
num_unconverted_operator = 0
num_converted_operator = 0
self._content = self._extra['start'] self._content = self._extra['start']
for num_line in range(0, num_all_lines): for num_line in range(0, num_all_lines):
code_line = code_lines[num_line] code_line = code_lines[num_line]

if 'onnx.' in code_line: if 'onnx.' in code_line:
num_unconverted_line += 1
num_unconverted_operator += 1
unconverted_operator = SEPARATOR_IN_ONNX_OP.join( unconverted_operator = SEPARATOR_IN_ONNX_OP.join(
('onnx', re.findall(r".*onnx.(.*)[(]", code_line)[0])) ('onnx', re.findall(r".*onnx.(.*)[(]", code_line)[0]))
info_unconverted_line = self._gen_unconverted_operator_content( info_unconverted_line = self._gen_unconverted_operator_content(
@@ -123,9 +125,17 @@ class ReportGenerator(metaclass=abc.ABCMeta):
) )
self._content = f"{NEW_LINE}".join((self._content, self._content = f"{NEW_LINE}".join((self._content,
info_unconverted_line)) info_unconverted_line))

if 'P.' in code_line or 'nn.' in code_line:
converted_operator = re.findall(r".*(?:nn.|P.)(.*)[(]", code_line)

if converted_operator:
num_converted_operator += 1

self._content = f"{NEW_LINE}".join((self._content, self._extra['end'])) self._content = f"{NEW_LINE}".join((self._content, self._extra['end']))


converted_rate = (num_all_lines - num_unconverted_line) / num_all_lines
converted_rate = \
num_converted_operator / (num_converted_operator + num_unconverted_operator)
info_converted_rate = f"Converted Rate: {converted_rate * 100:.2f}%.{NEW_LINE}" info_converted_rate = f"Converted Rate: {converted_rate * 100:.2f}%.{NEW_LINE}"
self._content = f"{NEW_LINE}".join((self._content, info_converted_rate)) self._content = f"{NEW_LINE}".join((self._content, info_converted_rate))




+ 1
- 1
mindinsight/mindconverter/graph_based_converter/third_party_graph/input_node.py View File

@@ -67,7 +67,7 @@ class InputNode(GraphNode):
self._op_name = 'Input' self._op_name = 'Input'
self._op_params = {'input_shape': input_shape, self._op_params = {'input_shape': input_shape,
"output_shape": input_shape} "output_shape": input_shape}
self._node_type = NodeType.INPUT.value
self._node_type = NodeType.INPUTS.value


@property @property
def input_shape(self): def input_shape(self):


Loading…
Cancel
Save