Skip to content

Apply the outputs argument when converting a MIL program - #2884

Open
Om-singhaI wants to merge 1 commit into
apple:mainfrom
Om-singhaI:fix/milinternal-outputs
Open

Om-singhaI wants to merge 1 commit into
apple:mainfrom
Om-singhaI:fix/milinternal-outputs

Conversation

@Om-singhaI

Copy link
Copy Markdown
Contributor

Fixes #1679

ct.convert ignores outputs when the model is a MIL program. Names and dtypes get dropped, and even a list with the wrong number of entries goes through. Both backends are affected.

MILFrontend only handled inputs. Now it also renames the output vars and calls set_output_types, like the torch and TensorFlow frontends do, so the existing update_output_dtypes pass applies the dtypes. If an output is a function input, or the same var is returned twice, it gets an identity copy under the new name, so the input or the other output keeps its name.

Passing a different number of outputs than the program returns now raises a ValueError instead of being ignored.

The new tests only build pymil programs, so they don't need torch. They fail with converter.py from main and pass on this branch:

pytest coremltools/converters/mil/mil/tests/test_programs.py -k TestMILFrontendOutputs
main:        7 failed
this branch: 7 passed

I also ran all of test_programs.py, test_debug.py, test_api_examples.py, milproto/test_load.py and TestUpdateOutputDtypes on macOS 26: 149 passed, 2 skipped, 3 xfailed.

ct.convert ignored outputs for a MIL program, so the requested names and
dtypes were dropped and a wrong number of outputs was accepted. Rename the
outputs and set the output types in MILFrontend like the other frontends
do, and raise a ValueError when the number of outputs doesn't match. A
function input, or a var returned more than once, gets an identity copy
under the new name instead of being renamed in place.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Output name ignored when converting from milinternal

1 participant