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

ONNX export makes incorrect assumption about label names #13407

@safrooze

Description

@safrooze

Description

ONNX implementation in mx2onnx.export_model:export_model() makes multiple incorrect assumptions about the symbolic graph which makes its implementation very fragile to any graph that doesn't fit its assumptions.

Incorrect assumptions:

  1. Order that data is fed to network is the order that sym.list_inputs() lists them:
    • This is an incorrect assumption because the order data is fed to network (particularly a gluon block) is determined by custom block's API. However the order that data is listed in sym.list_inputs() is by the dependency in computation graph.
  2. There can be one and only one label in the graph and this label is named after the last node of the graph on sym.get_internals().
    • This is clearly an incorrect assumption. Perhaps if the last node is called 'softmax' and the network's label was called 'softmax_label' (which happens to be the default label name) then this assumption will hold. However under any other condition, I don't think this is a valid assumption.

A proper implementation would be to change the export_model() API to accept a dictionary of name: shape for input instead of a list of shapes. Any input that is not in params or in inputs will then be assumed to be a label and may be ignored. However if incorrectly specified as unnecessary label, then ONNX export will fail.

For backward compatibility, if a list of shapes is provided as inputs, the current automatic name to shape mapping will happen but a warning log is created, warning user to use a dictionary and also warns about the default mapping between shapes and inputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions