Remove onnxruntime-easy dependency, inline its code#32
Conversation
…e.py Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com> Agent-Logs-Url: https://github.com/onnxruntime/mobius/sessions/2a25ff2f-35b5-4acf-b7e5-4f45dbca8aee
Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com> Agent-Logs-Url: https://github.com/onnxruntime/mobius/sessions/60380e38-d669-4ed2-b8cd-d74d9ee42c9c
…nditional Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com> Agent-Logs-Url: https://github.com/onnxruntime/mobius/sessions/feb5cf18-6cf6-432e-8ef5-ac0224beb18a
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
Performance Comparison
|
There was a problem hiding this comment.
Pull request overview
This PR removes the onnxruntime-easy test dependency by inlining equivalent ORT session/dtype handling logic into the repo’s internal testing utilities, simplifying the dependency graph while keeping ONNX Runtime inference available for tests/examples.
Changes:
- Replaced
onnxruntime-easyusage with a directonnxruntime.InferenceSessionwrapper and OrtValue conversion utilities. - Added
onnxruntimeandml_dtypesto thetestingoptional dependencies and removedonnxruntime-easy.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/mobius/_testing/ort_inference.py | Inlines ORT session creation + OrtValue conversion to replace onnxruntime-easy. |
| pyproject.toml | Updates testing extras to depend on onnxruntime + ml_dtypes instead of onnxruntime-easy. |
| def _to_ort_value(value: np.ndarray, device: str = "cpu") -> ort.OrtValue: | ||
| """Convert a numpy array to an OrtValue, handling special ml_dtypes dtypes.""" | ||
| # Use DLPack when available (e.g. torch tensors or non-zero-size arrays) | ||
| if hasattr(value, "__dlpack__"): | ||
| is_zero_size = hasattr(value, "size") and value.size == 0 | ||
| if not is_zero_size: | ||
| return ort.OrtValue(_ort_c.OrtValue.from_dlpack(value.__dlpack__(), False), value) | ||
| if isinstance(value, np.ndarray): | ||
| try: | ||
| onnx_type = ir.DataType.from_numpy(value.dtype) | ||
| except TypeError: | ||
| pass | ||
| else: | ||
| return ort.OrtValue.ortvalue_from_numpy_with_onnx_type( | ||
| value, onnx_element_type=onnx_type.value | ||
| ) | ||
| return ort.OrtValue.ortvalue_from_numpy(np.asarray(value), device) |
There was a problem hiding this comment.
_to_ort_value(..., device=...) only uses device in the final fallback path; the DLPack and ortvalue_from_numpy_with_onnx_type branches ignore it. Either remove the parameter to avoid a misleading API, or ensure the chosen OrtValue creation path respects the requested device (especially if this is intended to support CUDA inputs).
|
We need to run the tests locally because the CIs are currently broken. Otherwise lgtm. |
|
Is this ready? |
onnxruntime-easyintosrc/mobius/_testing/ort_inference.pyonnxruntime-easyfrompyproject.tomltesting dependencies, addonnxruntimeandml_dtypesinsteadonnx.TensorProtoconstants instead of hardcoded ONNX element type integersOriginal prompt
⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.