File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed
onnxscript/rewriter/ort_fusions Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change 22# Licensed under the MIT License.
33from __future__ import annotations
44
5- import os
6- import tempfile
7-
85import numpy as np
96import onnx
107import onnxruntime
@@ -27,13 +24,13 @@ def _save(model, modelpath):
2724
2825def ort_run (model_name : str , model , inputs ):
2926 providers = ["CPUExecutionProvider" ]
30- with tempfile . TemporaryDirectory () as temp_dir :
31- model_path = os . path . join ( temp_dir , f" { model_name } .onnx" )
32- _save ( model , model_path )
33- # Run model
34- session = onnxruntime . InferenceSession ( model_path , providers = providers )
35- ort_outputs = session . run ( None , inputs )
36- return ort_outputs
27+ model_proto = ir . serde . serialize_model ( model )
28+ options = onnxruntime . SessionOptions ( )
29+ options . graph_optimization_level = onnxruntime . GraphOptimizationLevel . ORT_DISABLE_ALL
30+ session = onnxruntime . InferenceSession (
31+ model_proto . SerializeToString (), options , providers = providers
32+ )
33+ return session . run ( None , inputs )
3734
3835
3936def assert_allclose (outputs , expected_outputs , rtol = 1e-2 , atol = 1e-2 ):
You can’t perform that action at this time.
0 commit comments