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

ONNX export makes incorrect assumption about label names #13407

Open
safrooze opened this issue Nov 26, 2018 · 2 comments
Open

ONNX export makes incorrect assumption about label names #13407

safrooze opened this issue Nov 26, 2018 · 2 comments
Labels

Comments

@safrooze
Copy link
Contributor

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.

@safrooze safrooze mentioned this issue Nov 26, 2018
4 tasks
@vdantu
Copy link
Contributor

vdantu commented Nov 26, 2018

@mxnet-label-bot add [onnx]

@Roshrini
Copy link
Member

Thanks Sina for creating issue for it. I am aware of this issue and started working on the fix for it #12946 but got sidelined by other things. I will rebase the PR with latest changes and continue working on the fix.
I also have added optional parameters "label_names", "label_shapes"([name, shape]) to export_model API.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants