Skip to content
Merged
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
28 changes: 15 additions & 13 deletions src/mobius/components/_pixtral_vision_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ def test_patch_merger_matches_hf_unfold_ordering():
the outermost loop). The ONNX implementation must reproduce this
ordering so the learned ``merging_layer`` projection is correct.
"""
import tempfile

import torch
from onnxscript._internal.builder import GraphBuilder

Expand Down Expand Up @@ -181,17 +179,21 @@ def test_patch_merger_matches_hf_unfold_ordering():

model = ir.Model(graph, ir_version=11)

with tempfile.NamedTemporaryFile(suffix=".onnx", delete=True) as f:
ir.save(model, f.name)
sess = ort.InferenceSession(f.name, providers=["CPUExecutionProvider"])
onnx_out = sess.run(
None,
{
"x": x,
"grid_h": np.array(grid_h, dtype=np.int64),
"grid_w": np.array(grid_w, dtype=np.int64),
},
)[0]
# Serialize to protobuf in-memory (avoids Windows PermissionError
# from concurrent file access with tempfile + ir.save).
proto = ir.serde.serialize_model(model)
sess = ort.InferenceSession(
proto.SerializeToString(),
providers=["CPUExecutionProvider"],
Comment thread
justinchuby marked this conversation as resolved.
)
onnx_out = sess.run(
None,
{
"x": x,
"grid_h": np.array(grid_h, dtype=np.int64),
"grid_w": np.array(grid_w, dtype=np.int64),
},
)[0]

np.testing.assert_allclose(
onnx_out.squeeze(0),
Expand Down
Loading