Repository navigation
feat: allow user-provided ort::Environment - #373
Merged
Merged
Conversation
theHamsta
commented
Nov 7, 2026
| })?; | ||
| let device = | ||
| env.devices() | ||
| .nth(self.device_idx) |
Collaborator
Author
There was a problem hiding this comment.
just relying on the enumeration being reproducible is a bit risky but so it was also before. Maybe the bounds on the types from ort crate would allow now to store the actual device.
The OrtEnvironment has to stay a singleton instead of a context option because having only one environment per process is a limitation of the `ort` crate https://github.com/pykeio/ort/blob/6ed2423cc08ca21d0b07f467b6e4387ef1bee2ce/src/environment.rs#L515-L517 (and probably also safer to have only one from a onnxruntime perspective). This feature allows registering additional EPs also in pywebnn.
mtavenrath
approved these changes
Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OrtEnvironment has to stay a singleton instead of a context option because having only one environment per process is a limitation of the
ortcrate https://github.com/pykeio/ort/blob/6ed2423cc08ca21d0b07f467b6e4387ef1bee2ce/src/environment.rs#L515-L517 (and probably also safer to have only one from a onnxruntime perspective).This feature allows registering additional EPs (also in pywebnn rustnn/pywebnn#33) or to let the user define the path to the onnxruntime library, ort log level and ort log destination.
We could consider in another PR to bind ORT log level with our Rust log level and implement an ort logger that uses log. I believe
ortusing tracing for logging to simply using tracing_subscriber could get us logging.Validation
make testDocumentation
See
docs/development/documentation-policy.mdfor which page belongs to which change.make docs-backend-opsand committeddocs/development/backend-operator-support.mdmake docs-apiandmake ci-docspass if rustdoc or docs pages changed