Skip to content

Make test test_smollm 20% faster #2107

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

Merged
merged 8 commits into from
Mar 16, 2025
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
17 changes: 7 additions & 10 deletions onnxscript/rewriter/ort_fusions/_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
# Licensed under the MIT License.
from __future__ import annotations

import os
import tempfile

import numpy as np
import onnx
import onnxruntime
Expand All @@ -27,13 +24,13 @@ def _save(model, modelpath):

def ort_run(model_name: str, model, inputs):
providers = ["CPUExecutionProvider"]
with tempfile.TemporaryDirectory() as temp_dir:
model_path = os.path.join(temp_dir, f"{model_name}.onnx")
_save(model, model_path)
# Run model
session = onnxruntime.InferenceSession(model_path, providers=providers)
ort_outputs = session.run(None, inputs)
return ort_outputs
model_proto = ir.serde.serialize_model(model)
options = onnxruntime.SessionOptions()
options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_DISABLE_ALL
session = onnxruntime.InferenceSession(
model_proto.SerializeToString(), options, providers=providers
)
return session.run(None, inputs)


def assert_allclose(outputs, expected_outputs, rtol=1e-2, atol=1e-2):
Expand Down
Loading