Incubator-mxnet: Incorrect ONNX export of SliceChannel

Created on 31 Oct 2018  路  3Comments  路  Source: apache/incubator-mxnet

Description

The operator mapping from MXNet's SliceChannel to ONNX Split is incorrect:

elif squeeze_axis == 0 and num_outputs > 1:
        node = onnx.helper.make_node(
            "Split",
            [input_node],
            [name],
            axis=axis,
            split=[num_outputs],
            name=name,
        )
        return [node]

This means that when an array is supposed to be split into e.g. 10 evenly sized chunks (num_outputs == 10) what is exported instead is an ONNX operator that outputs one chunk of length 10, see https://github.com/onnx/onnx/blob/master/docs/Operators.md#examples-82.

It should instead read something along the lines of


    elif squeeze_axis == 0 and num_outputs > 1:
        node = onnx.helper.make_node(
            "Split",
            [input_node],
            [name + "_%s" % (i) for i in range(num_outputs)],
            axis=axis,
            name=name,
        )
        return [node]

, which will require some additional changes to consumer nodes (they'll have to select which of the "Split" node outputs they need to use).

I encountered this when I exported a model of mine to ONNX and tried to reimport it to MXNet for sanity checks, but the import failed due to the unresolved https://github.com/apache/incubator-mxnet/issues/11594

Bug ONNX

Most helpful comment

All 3 comments

@mxnet-label-bot [Bug, ONNX]

@vandanavk

Was this page helpful?
0 / 5 - 0 ratings