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

Commit

Permalink
bump onnx version to 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
RuRo committed Apr 16, 2020
1 parent b1672cb commit 7252018
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ci/docker/install/ubuntu_onnx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ apt-get update || true
apt-get install -y libprotobuf-dev protobuf-compiler

echo "Installing pytest, pytest-cov, protobuf, Pillow, ONNX and tabulate ..."
pip3 install pytest==3.6.3 pytest-cov==2.5.1 protobuf==3.5.2 onnx==1.3.0 Pillow==5.0.0 tabulate==0.7.5
pip3 install pytest==3.6.3 pytest-cov==2.5.1 protobuf==3.5.2 onnx==1.5.0 Pillow==5.0.0 tabulate==0.7.5
40 changes: 33 additions & 7 deletions python/mxnet/contrib/onnx/mx2onnx/_op_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,16 +1614,34 @@ def convert_slice_axis(node, **kwargs):
in_shape = kwargs['in_shape'][0]
ends = in_shape[axes]

export_nodes = []

starts = np.atleast_1d(np.asarray(starts, dtype=np.int))
ends = np.atleast_1d(np.asarray(ends, dtype=np.int))
axes = np.atleast_1d(np.asarray(axes, dtype=np.int))

starts_node = create_helper_tensor_node(starts, name + '__starts', kwargs)
export_nodes.extend(starts_node)
starts_node = starts_node[-1].name

ends_node = create_helper_tensor_node(ends, name + '__ends', kwargs)
export_nodes.extend(ends_node)
ends_node = ends_node[-1].name

axes_node = create_helper_tensor_node(axes, name + '__axes', kwargs)
export_nodes.extend(axes_node)
axes_node = axes_node[-1].name

input_node = input_nodes[0]
node = onnx.helper.make_node(
"Slice",
input_nodes,
[input_node, starts_node, ends_node, axes_node],
[name],
axes=[axes],
starts=[starts],
ends=[int(ends)],
name=name,
)
return [node]
export_nodes.extend([node])

return export_nodes


@mx_op.register("SliceChannel")
Expand Down Expand Up @@ -2181,14 +2199,22 @@ def convert_topk(node, **kwargs):
else:
raise NotImplementedError("ONNX expects both value and indices as output")

export_nodes = []

k = np.asarray([k], dtype=np.int)
k_node = create_helper_tensor_node(k, name + '__k', kwargs)
export_nodes.extend(k_node)
k_node = k_node[-1].name

input_node = input_nodes[0]
topk_node = onnx.helper.make_node(
"TopK",
input_nodes,
[input_node, k_node],
outputs,
axis=axis,
k=k,
name=name
)
export_nodes.extend([topk_node])

return [topk_node]

Expand Down
18 changes: 7 additions & 11 deletions tests/python-pytest/onnx/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
'test_transpose',
'test_globalmaxpool',
'test_globalaveragepool',
'test_slice_cpu',
'test_slice_neg',
'test_slice_end',
'test_reciprocal',
'test_sqrt',
'test_pow',
Expand All @@ -54,19 +51,19 @@
'test_operator_maxpool',
'test_operator_params',
'test_operator_permute2',
'test_cos',
'test_sin',
'test_cos[^h]',
'test_sin[^h]',
'test_tan',
'test_acos',
'test_asin',
'test_atan',
'test_acos[^h]',
'test_asin[^h]',
'test_atan[^h]',
'test_squeeze',
'test_matmul',
'test_matmul_',
'test_depthtospace',
'test_hardsigmoid',
'test_instancenorm',
'test_shape',
'test_cast',
'test_cast((?!STRING).)*$',
'test_clip',
'test_size',
'test_dropout',
Expand All @@ -80,7 +77,6 @@
'test_softplus',
'test_reduce_',
'test_split_equal',
'test_top_k',
'test_gather'
],
'import': ['test_softsign',
Expand Down

0 comments on commit 7252018

Please sign in to comment.