You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2021/05/06 01:53:35 UTC

[GitHub] [incubator-mxnet] Zha0q1 commented on a change in pull request #20250: [v1.x] ONNX support for _split_v2

Zha0q1 commented on a change in pull request #20250:
URL: https://github.com/apache/incubator-mxnet/pull/20250#discussion_r627024544



##########
File path: python/mxnet/onnx/mx2onnx/_op_translations/_op_translations_opset12.py
##########
@@ -4852,3 +4854,65 @@ def convert_contrib_div_sqrt_dim(node, **kwargs):
     ]
 
     return nodes
+
+
+@mx_op.register('_contrib_div_sqrt_dim')

Review comment:
       why this operator too?

##########
File path: tests/python-pytest/onnx/test_operators.py
##########
@@ -1858,3 +1858,19 @@ def rand_check(out):
     def rand_check_nd(out):
         return rand_check(out.asnumpy())
     op_export_test('sample_multinomial', M, [x], tmp_path, mx_map=rand_check_nd, onnx_map=rand_check)
+
+
+@pytest.mark.parametrize("dtype", ['float32', 'int32', 'int64'])

Review comment:
       Is the customer use case covered by the unit tests?

##########
File path: python/mxnet/onnx/mx2onnx/_op_translations/_op_translations_opset13.py
##########
@@ -1732,3 +1731,70 @@ def convert_logsoftmax(node, **kwargs):
     )
 
     return [node]
+
+
+@mx_op.register('_split_v2', OPSET_VERSION)
+def convert_contrib_split_v2(node, **kwargs):
+    """Map MXNet's _split_v2 operator
+    """
+    from onnx.helper import make_node
+    name, input_nodes, attrs = get_inputs(node, kwargs)
+    axis = int(attrs.get('axis', 0))
+    squeeze_axis = attrs.get('squeeze_axis', 'False')
+    sections = int(attrs.get('sections', 0))
+    indices = convert_string_to_list(attrs.get('indices', '[]'))
+    if sections <= 0 and len(indices) == 0:
+        raise NotImplementedError('section or indices must be set')
+    if sections > 0:
+        output_nodes = [name+str(i) for i in range(sections)]
+        if squeeze_axis == 'False':
+            nodes = [
+                make_node('Split', input_nodes, output_nodes, axis=axis),
+            ]
+        else:
+            output_nodes_ = [name+str(i)+'_' for i in range(sections)]
+            create_tensor([axis], name+'_axis', kwargs['initializer'])
+            nodes = [
+                make_node('Split', input_nodes, output_nodes_, axis=axis),
+            ]
+            for i in range(sections):
+                nodes += [
+                    make_node("Squeeze", [output_nodes_[i], name+'_axis'], [output_nodes[i]]),
+                ]
+    else:
+        # indices += [0]

Review comment:
       consider removing




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org