| import onnxruntime as rt | |
| sess_options = rt.SessionOptions() | |
| sess_options.graph_optimization_level = rt.GraphOptimizationLevel.ORT_ENABLE_ALL | |
| ######################################### | |
| ## Change the Path Accordingly | |
| sess_options.optimized_model_filepath = "d:/tmp/optimized_model.onnx" | |
| ######################################### | |
| ## Change the model.onnx path accordingly | |
| session = rt.InferenceSession("model.onnx" , sess_options, | |
| ###providers=['xxxxxxxxxDmlExecutionProvider', 'CPUExecutionProvider']) | |
| providers=['DmlExecutionProvider']) | |