Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
Change log
==========

0.17.2 (2026-06-04)
-------------------

**Other change**

- Disable onnxruntime optimization passes in value propagation as a mitigation for https://github.com/microsoft/onnxruntime/issues/28413 and to speed-up session creation.


0.17.1 (2026-02-17)
-------------------

Expand Down
7 changes: 4 additions & 3 deletions src/spox/_value_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,14 @@ def _run_reference_implementation(
def _run_onnxruntime(
model: onnx.ModelProto, input_feed: dict[str, ORTValue]
) -> dict[str, ORTValue]:
import onnxruntime
import onnxruntime as ort

# Silence possible warnings during execution (especially constant folding)
options = onnxruntime.SessionOptions()
options = ort.SessionOptions()
options.log_severity_level = 3
options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_DISABLE_ALL
try:
session = onnxruntime.InferenceSession(model.SerializeToString(), options)
session = ort.InferenceSession(model.SerializeToString(), options)
output_names = [output.name for output in session.get_outputs()]
output_feed = dict(zip(output_names, session.run(None, input_feed)))
except Exception as e:
Expand Down
16 changes: 15 additions & 1 deletion tests/test_value_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import spox
import spox._future
import spox.opset.ai.onnx.ml.v3 as ml
import spox.opset.ai.onnx.ml.v4 as ml
import spox.opset.ai.onnx.v22 as op
from spox import Optional, Sequence, Tensor, Type, Var, argument
from spox._graph import arguments, results
Expand Down Expand Up @@ -259,3 +259,17 @@ def test_strings():

x, y = op.const(["foo"]), op.const(["bar"])
np.testing.assert_equal(op.string_concat(x, y)._value.value, np.array(["foobar"])) # type: ignore


def test_value_prop_ort_cse_bug_mitigation():
"""Test mitigation against ort CSE crash."""
# A constant string input so value propagation actually runs.
x = op.const(np.array(["a"], dtype=np.str_))

y = ml.label_encoder(
x,
keys_tensor=np.array(["a"], dtype=np.str_),
values_tensor=np.array(["b"], dtype=np.str_),
default_tensor=np.array(["MISSING"], dtype=np.str_),
)
assert y._value is not None
Loading