Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SherlockNoMad committed Nov 30, 2021
1 parent 60e84ef commit e0c6970
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/python/inference/examples/plot_common_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from onnxruntime.datasets import get_example

example2 = get_example("logreg_iris.onnx")
sess = rt.InferenceSession(example2)
sess = rt.InferenceSession(example2, providers=rt.get_available_providers())

input_name = sess.get_inputs()[0].name
output_name = sess.get_outputs()[0].name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import onnxruntime as rt
from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument

sess = rt.InferenceSession("pipeline_vectorize.onnx")
sess = rt.InferenceSession("pipeline_vectorize.onnx", providers=rt.get_available_providers())

import numpy
inp, out = sess.get_inputs()[0], sess.get_outputs()[0]
Expand Down
2 changes: 1 addition & 1 deletion docs/python/inference/examples/plot_load_and_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# The model is available on github `onnx...test_sigmoid <https://github.com/onnx/onnx/tree/master/onnx/backend/test/data/node/test_sigmoid>`_.

example1 = get_example("sigmoid.onnx")
sess = rt.InferenceSession(example1)
sess = rt.InferenceSession(example1, providers=rt.get_available_providers())

#########################
# Let's see the input name and shape.
Expand Down
4 changes: 2 additions & 2 deletions docs/python/inference/examples/plot_profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def change_ir_version(filename, ir_version=6):
example1 = get_example("mul_1.onnx")
onnx_model = change_ir_version(example1)
onnx_model_str = onnx_model.SerializeToString()
sess = rt.InferenceSession(onnx_model_str)
sess = rt.InferenceSession(onnx_model_str, providers=rt.get_available_providers())
input_name = sess.get_inputs()[0].name

x = numpy.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]], dtype=numpy.float32)
Expand All @@ -48,7 +48,7 @@ def change_ir_version(filename, ir_version=6):

options = rt.SessionOptions()
options.enable_profiling = True
sess_profile = rt.InferenceSession(onnx_model_str, options)
sess_profile = rt.InferenceSession(onnx_model_str, options, providers=rt.get_available_providers())
input_name = sess.get_inputs()[0].name

x = numpy.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]], dtype=numpy.float32)
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/test/python/onnxruntime_test_python_keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def testRunModelConv(self):

# runtime
content = converted_model.SerializeToString()
rt = onnxrt.InferenceSession(content)
rt = onnxrt.InferenceSession(content, providers=onnxrt.get_available_providers())
input = {rt.get_inputs()[0].name: x}
actual_rt = rt.run(None, input)
self.assertEqual(len(actual_rt), 1)
Expand Down
4 changes: 2 additions & 2 deletions orttraining/tools/scripts/layer_norm_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ def main():
input_mask = np.ones((batch, sq_length), dtype=np.int64)

# Do forward using the original model.
sess = ort.InferenceSession(model_file_path)
sess = ort.InferenceSession(model_file_path, providers=ort.get_available_providers())
result = sess.run(None, {'input1': input_ids, 'input2': segment_ids, 'input3': input_mask})

# Do forward using the new model.
new_sess = ort.InferenceSession(new_model_file_path)
new_sess = ort.InferenceSession(new_model_file_path, providers=ort.get_available_providers())
new_result = new_sess.run(None, {'input1': input_ids, 'input2': segment_ids, 'input3': input_mask})

# Compare the outcomes from the two models.
Expand Down
4 changes: 2 additions & 2 deletions orttraining/tools/scripts/model_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ def add_expand_shape(model):
input_mask = np.ones((batch, sq_length), dtype=np.int64)

# Do forward using the original model.
sess = ort.InferenceSession(input_model_name)
sess = ort.InferenceSession(input_model_name, providers=ort.get_available_providers())
result = sess.run(None, {'input1': input_ids, 'input2': segment_ids, 'input3': input_mask})

# Do forward using the new model.
new_sess = ort.InferenceSession(output_model_name)
new_sess = ort.InferenceSession(output_model_name, providers=ort.get_available_providers())
new_result = new_sess.run(None, {'input1': input_ids, 'input2': segment_ids, 'input3': input_mask})

# Compare the outcomes from the two models.
Expand Down
2 changes: 1 addition & 1 deletion orttraining/tools/scripts/nv_run_pretraining.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def main():
is_model_exported = False

import onnxruntime as ort
sess = ort.InferenceSession(onnx_path)
sess = ort.InferenceSession(onnx_path, providers=ort.get_available_providers())
result = sess.run(None, {'input1': input_ids.cpu().numpy(), 'input2': segment_ids.cpu().numpy(), 'input3': input_mask.cpu().numpy()})

print('---ORT result---')
Expand Down

0 comments on commit e0c6970

Please sign in to comment.