Skip to content

Commit

Permalink
Merge pull request chainer#8332 from msakai/fix-onnx-chainer-separate…
Browse files Browse the repository at this point in the history
…-output

Fix onnx_chainer's exporter of Separate to handle single output case
  • Loading branch information
mergify[bot] authored Oct 29, 2019
2 parents 1146a0b + 86c66f2 commit 273b533
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions onnx_chainer/functions/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ def convert_Separate(func, opset_version, input_names, output_names, context):
gb = onnx_helper.GraphBuilder()
split_outs = gb.op(
'Split', input_names, num_outputs=len(output_names), axis=func.axis)
if len(output_names) == 1:
split_outs = [split_outs]
for i, node_name in enumerate(split_outs):
gb.op_output_named(
'Squeeze', [node_name], [output_names[i]], axes=[func.axis])
Expand Down
2 changes: 2 additions & 0 deletions tests/onnx_chainer_tests/functions_tests/test_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@
'input_argname': 'x', 'args': {}, 'name': 'separate_axis0'},
{'ops': 'separate', 'input_shape': (2, 3),
'input_argname': 'x', 'args': {'axis': 1}, 'name': 'separate_axis1'},
{'ops': 'separate', 'input_shape': (1, 2, 3),
'input_argname': 'x', 'args': {}, 'name': 'separate_single_output'},
# moveaxis
{'ops': 'moveaxis', 'input_shape': (2, 3, 4, 5),
Expand Down

0 comments on commit 273b533

Please sign in to comment.