Skip to content

Graph or model_exporter doesn't preserve list/tuple and dict outputs #792

@mikeseven

Description

@mikeseven

Issue Type

Feature Request

Source

source

MCT Version

main

OS Platform and Distribution

ubuntu 20.04, pytorch 2

Python version

3.11

Describe the issue

A model with multiple outputs ordered in a list, tuple, or dict is correctly mapped to FX.
However, when the model is exported after quantization, all this information is lost and a set is returned (if the output had activations in 2 lists, only 1 is returned).
When it comes to dict, only unique values are returned.

This is a big problem for multi-head models eg object detection etc.

I think it's a bug but looking at the code, I suspect it's a missing feature that needs to be implemented in multiple places.

Expected behaviour

list, tuple, dict must be preserved exactly like FX traces them.

Code to reproduce the issue

simply make a simple model with output (list1, list2). 
You will get all elements of both lists after pytorch model reconstruction and it is even in the Graph. If some elements are present in both lists, only one will returned.
Likewise for dict, no dict is returned, only unique values.

Log output

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions