Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set CoreML EP flags from python #21434

Closed

Conversation

skottmckay
Copy link
Contributor

Description

Add parsing of provider options for CoreML EP.

import onnxruntime as ort
so = ort.SessionOptions()
provider_options = [{'flags': 'COREML_FLAG_ONLY_ALLOW_STATIC_INPUT_SHAPES|COREML_FLAG_CREATE_MLPROGRAM'}, {}]
s = ort.InferenceSession('model.onnx', so, 
                         providers=['CoreMLExecutionProvider', 'CPUExecutionProvider'],
                         provider_options=provider_options)

Motivation and Context

Enable running with ML Program from python

```py
provider_options = [{'flags': 'COREML_FLAG_ONLY_ALLOW_STATIC_INPUT_SHAPES|COREML_FLAG_CREATE_MLPROGRAM'}, {}]

s = ort.InferenceSession('model.onnx', so, providers=['CoreMLExecutionProvider', 'CPUExecutionProvider'],
                         provider_options=provider_options)
```py
edgchen1
edgchen1 previously approved these changes Jul 23, 2024
skottmckay added a commit that referenced this pull request Jul 24, 2024
- Add Concat (#21423)
- Add DepthToSpace (#21426)
- Add LeakyRelu (#21453)
- Add test scripts (#21427)
- Add ability to set coreml flags from python (#21434)

Also updated partitioning utils to support dropping constant initializers from a ComputeCapability's inputs. We copy these to a CoreML model so don't need the originals. If they remain as inputs ORT can't free them as they appear to be in use.

Misc changes
- Fix SkipLayerNormFusion incorrectly setting `modified`
  - causes unnecessary loops of the L2 transformers
@skottmckay
Copy link
Contributor Author

Included in #21472

@skottmckay skottmckay closed this Jul 25, 2024
skottmckay added a commit that referenced this pull request Jul 25, 2024
…#21472)

### Description
<!-- Describe your changes. -->
Add these changes to one PR to simplify checkin
- Add Concat (#21423)
- Add DepthToSpace (#21426)
- Add LeakyRelu (#21453)
- Add test scripts (#21427)
- Add ability to set coreml flags from python (#21434)


Other changes
- updated partitioning utils to support dropping constant initializers
from a ComputeCapability's inputs.
- noticed that the list of inputs to the coreml model was unexpectedly
long due to this
- we copy constant initializers to a CoreML model so don't need the
originals, and if they remain as inputs ORT can't free them as they
appear to be in use.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
@skottmckay skottmckay deleted the skottmckay/AddAbilityToSetCoreMLFlagsFromPython branch September 5, 2024 23:12
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.

2 participants