Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[v1.9.x] ONNX fix node output sort #20327

Merged
merged 5 commits into from
Jun 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions python/mxnet/onnx/mx2onnx/_export_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# coding: utf-8
# pylint: disable=invalid-name,too-many-locals,no-self-use,too-many-arguments,
# pylint: disable=maybe-no-member,too-many-nested-blocks,logging-not-lazy
# pylint: disable=cell-var-from-loop
"""MXNet to ONNX graph converter functions"""
import logging
import json
Expand Down Expand Up @@ -393,15 +394,14 @@ def __init__(self, name, dtype):
if not node_output_names:
node_output_names = [converted[-1].name]
# process node outputs (sort by output index)
def str2int(s):
import re
i = re.search(r'\d{0,2}$', s).group()
if i == '':
return 0
def str2int(s, name):
l = len(name)
if len(s) == l:
return -1
else:
return int(i)
return int(s[l:])

sorted(node_output_names, key=str2int)
node_output_names = sorted(node_output_names, key=lambda x: str2int(x, name))

# match the output names to output dtypes
if dtypes is not None:
Expand Down