You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2021/06/07 17:58:46 UTC

[incubator-mxnet] branch v1.x updated: [v1.x] ONNX fix node output sort (#20326)

This is an automated email from the ASF dual-hosted git repository.

zha0q1 pushed a commit to branch v1.x
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/v1.x by this push:
     new 7a557ec  [v1.x] ONNX fix node output sort (#20326)
7a557ec is described below

commit 7a557ec5e4b7d5b0a89ec365f335e0c229318bef
Author: waytrue17 <52...@users.noreply.github.com>
AuthorDate: Mon Jun 7 10:56:05 2021 -0700

    [v1.x] ONNX fix node output sort (#20326)
    
    * fix sort output
    
    * increase int range
    
    * rewrite sort
    
    * fix sanity
    
    * fix sanity
    
    * disable cell-var-from-loop
    
    Co-authored-by: Wei Chu <we...@amazon.com>
---
 python/mxnet/onnx/mx2onnx/_export_onnx.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/python/mxnet/onnx/mx2onnx/_export_onnx.py b/python/mxnet/onnx/mx2onnx/_export_onnx.py
index 1349381..73843bd 100644
--- a/python/mxnet/onnx/mx2onnx/_export_onnx.py
+++ b/python/mxnet/onnx/mx2onnx/_export_onnx.py
@@ -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
@@ -393,15 +394,13 @@ class MXNetGraph(object):
                 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, l):
+                    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, len(name)))
 
                 # match the output names to output dtypes
                 if dtypes is not None: