API Summary¶
-Summary of public functions and classes exposed -in ONNX Runtime.
+API¶
-
-
- -
- -
- -
- -
- +
- + +
- + -
- +
OrtValue¶
-ONNX Runtime works with native Python data structures which are mapped into ONNX data formats : -Numpy arrays (tensors), dictionaries (maps), and a list of Numpy arrays (sequences). -The data backing these are on CPU.
-ONNX Runtime supports a custom data structure that supports all ONNX data formats that allows users -to place the data backing these on a device, for example, on a CUDA supported device. This allows for -interesting IOBinding scenarios (discussed below). In addition, ONNX Runtime supports directly -working with OrtValue (s) while inferencing a model if provided as part of the input feed.
-Below is an example showing creation of an OrtValue from a Numpy array while placing its backing memory -on a CUDA device:
-# X is numpy array on cpu, create an OrtValue and place it on cuda device id = 0
-ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
-ortvalue.device_name() # 'cuda'
-ortvalue.shape() # shape of the numpy array X
-ortvalue.data_type() # 'tensor(float)'
-ortvalue.is_tensor() # 'True'
+
+API Overview¶
+ONNX Runtime loads and runs inference on a model in ONNX graph format, or ORT format (for memory and disk constrained environments).
+The data consumed and produced by the model can be specified and accessed in the way that best matches your scenario.
+
+Load and run a model¶
+InferenceSession is the main class of ONNX Runtime. It is used to load and run an ONNX model,
+as well as specify environment and application configuration options.
+session = onnxruntime.InferenceSession('model.onnx')
+
+outputs = session.run([output names], inputs)
+
+
+ONNX and ORT format models consist of a graph of computations, modeled as operators,
+and implemented as optimized operator kernels for different hardware targets.
+ONNX Runtime orchestrates the execution of operator kernels via execution providers.
+An execution provider contains the set of kernels for a specific execution target (CPU, GPU, IoT etc).
+Execution provides are configured using the providers parameter. Kernels from different execution
+providers are chosen in the priority order given in the list of providers. In the example below
+if there is a kernel in the CUDA execution provider ONNX Runtime executes that on GPU. If not
+the kernel is executed on CPU.
+session = onnxruntime.InferenceSession(model,
+ providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
+
+
+The list of available execution providers can be found here: Execution Providers.
+Since ONNX Runtime 1.10, you must explicitly specify the execution provider for your target.
+Running on CPU is the only time the API allows no explicit setting of the provider parameter.
+In the examples that follow, the CUDAExecutionProvider and CPUExecutionProvider are used, assuming the application is running on NVIDIA GPUs.
+Replace these with the execution provider specific to your environment.
+You can supply other session configurations via the session options parameter. For example, to enable
+profiling on the session:
+options = onnxruntime.SessionOptions()
+options.enable_profiling=True
+session = onnxruntime.InferenceSession('model.onnx', sess_options=options, providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
+
+
+
+
+Data inputs and outputs¶
+The ONNX Runtime Inference Session consumes and produces data using its OrtValue class.
+
+Data on CPU¶
+On CPU (the default), OrtValues can be mapped to and from native Python data structures: numpy arrays, dictionaries and lists of
+numpy arrays.
+# X is numpy array on cpu
+ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X)
+ortvalue.device_name() # 'cpu'
+ortvalue.shape() # shape of the numpy array X
+ortvalue.data_type() # 'tensor(float)'
+ortvalue.is_tensor() # 'True'
np.array_equal(ortvalue.numpy(), X) # 'True'
# ortvalue can be provided as part of the input feed to a model
-ses = onnxruntime.InferenceSession('model.onnx')
-res = sess.run(["Y"], {"X": ortvalue})
+session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
+results = session.run(["Y"], {"X": ortvalue})
+By default, ONNX Runtime always places input(s) and output(s) on CPU. Having the data on CPU
+may not optimal if the input or output is consumed and produced on a device
+other than CPU because it introduces data copy between CPU and the device.
-
-IOBinding¶
-By default, ONNX Runtime always places input(s) and output(s) on CPU, which
-is not optimal if the input or output is consumed and produced on a device
-other than CPU because it introduces data copy between CPU and the device.
-ONNX Runtime provides a feature, IO Binding, which addresses this issue by
-enabling users to specify which device to place input(s) and output(s) on.
-Here are scenarios to use this feature.
-(In the following code snippets, model.onnx is the model to execute,
-X is the input data to feed, and Y is the output data.)
-Scenario 1:
+
+Data on device¶
+ONNX Runtime supports a custom data structure that supports all ONNX data formats that allows users
+to place the data backing these on a device, for example, on a CUDA supported device. In ONNX Runtime,
+this called IOBinding.
+To use the IOBinding feature, replace InferenceSession.run() with InferenceSession.run_with_iobinding().
A graph is executed on a device other than CPU, for instance CUDA. Users can
-use IOBinding to put input on CUDA as the follows.
+use IOBinding to copy the data onto the GPU.
# X is numpy array on cpu
-session = onnxruntime.InferenceSession('model.onnx')
+session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
# OnnxRuntime will copy the data over to the CUDA device if 'input' is consumed by nodes on the CUDA device
io_binding.bind_cpu_input('input', X)
@@ -128,11 +166,10 @@ IOBindingY = io_binding.copy_outputs_to_cpu()[0]
-Scenario 2:
The input data is on a device, users directly use the input. The output data is on CPU.
# X is numpy array on cpu
X_ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
-session = onnxruntime.InferenceSession('model.onnx')
+session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
io_binding.bind_input(name='input', device_type=X_ortvalue.device_name(), device_id=0, element_type=np.float32, shape=X_ortvalue.shape(), buffer_ptr=X_ortvalue.data_ptr())
io_binding.bind_output('output')
@@ -140,25 +177,23 @@ IOBindingY = io_binding.copy_outputs_to_cpu()[0]
-Scenario 3:
The input data and output data are both on a device, users directly use the input and also place output on the device.
#X is numpy array on cpu
X_ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
Y_ortvalue = onnxruntime.OrtValue.ortvalue_from_shape_and_type([3, 2], np.float32, 'cuda', 0) # Change the shape to the actual shape of the output being bound
-session = onnxruntime.InferenceSession('model.onnx')
+session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
io_binding.bind_input(name='input', device_type=X_ortvalue.device_name(), device_id=0, element_type=np.float32, shape=X_ortvalue.shape(), buffer_ptr=X_ortvalue.data_ptr())
io_binding.bind_output(name='output', device_type=Y_ortvalue.device_name(), device_id=0, element_type=np.float32, shape=Y_ortvalue.shape(), buffer_ptr=Y_ortvalue.data_ptr())
session.run_with_iobinding(io_binding)
-Scenario 4:
Users can request ONNX Runtime to allocate an output on a device. This is particularly useful for dynamic shaped outputs.
Users can use the get_outputs() API to get access to the OrtValue (s) corresponding to the allocated output(s).
Users can thus consume the ONNX Runtime allocated memory for the output as an OrtValue.
#X is numpy array on cpu
X_ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
-session = onnxruntime.InferenceSession('model.onnx')
+session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
io_binding.bind_input(name='input', device_type=X_ortvalue.device_name(), device_id=0, element_type=np.float32, shape=X_ortvalue.shape(), buffer_ptr=X_ortvalue.data_ptr())
#Request ONNX Runtime to bind and allocate memory on CUDA for 'output'
@@ -168,52 +203,57 @@ IOBindingort_output = io_binding.get_outputs()[0]
-Scenario 5:
+In addition, ONNX Runtime supports directly working with OrtValue (s) while inferencing a model if provided as part of the input feed.
Users can bind OrtValue (s) directly.
#X is numpy array on cpu
#X is numpy array on cpu
X_ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
Y_ortvalue = onnxruntime.OrtValue.ortvalue_from_shape_and_type([3, 2], np.float32, 'cuda', 0) # Change the shape to the actual shape of the output being bound
-session = onnxruntime.InferenceSession('model.onnx')
+session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
io_binding.bind_ortvalue_input('input', X_ortvalue)
io_binding.bind_ortvalue_output('output', Y_ortvalue)
session.run_with_iobinding(io_binding)
+You can also bind inputs and outputs directly to a PyTorch tensor.
+# X is a PyTorch tensor on device
+session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
+binding = session.io_binding()
+
+X_tensor = X.contiguous()
+
+binding.bind_input(
+ name='X',
+ device_type='cuda',
+ device_id=0,
+ element_type=np.float32,
+ shape=tuple(x_tensor.shape),
+ buffer_ptr=x_tensor.data_ptr(),
+ )
+
+## Allocate the PyTorch tensor for the model output
+Y_shape = ... # You need to specify the output PyTorch tensor shape
+Y_tensor = torch.empty(Y_shape, dtype=torch.float32, device='cuda:0').contiguous()
+binding.bind_output(
+ name='Y',
+ device_type='cuda',
+ device_id=0,
+ element_type=np.float32,
+ shape=tuple(Y_tensor.shape),
+ buffer_ptr=Y_tensor.data_ptr(),
+)
+
+session.run_with_iobinding(binding)
+
+
-
-Device¶
-The package is compiled for a specific device, GPU or CPU.
-The CPU implementation includes optimizations
-such as MKL (Math Kernel Libary). The following function
-indicates the chosen option:
-
-
-
-Examples and datasets¶
-The package contains a few models stored in ONNX format
-used in the documentation. These don’t need to be downloaded
-as they are installed with the package.
-
-
-
-Load and run a model¶
-ONNX Runtime reads a model saved in ONNX format.
-The main class InferenceSession wraps these functionalities
-in a single place.
-
-Main class¶
+
+API Details¶
+
+InferenceSession¶
-
class onnxruntime.InferenceSession(path_or_bytes, sess_options=None, providers=None, provider_options=None, **kwargs)[source]¶
@@ -339,6 +379,10 @@ Main classrun_options – See onnxruntime.RunOptions.
+- Returns
+list of results, every result is either a numpy array,
+a sparse tensor, a list or a dictionary.
+
sess.run([output_name], {input_name: x})
@@ -367,7 +411,7 @@ Main classParameters
output_names – name of the outputs
-input_feed – dictionary { input_name: input_ort_value }
+
input_dict_ort_values – dictionary { input_name: input_ort_value }
See OrtValue class how to create OrtValue
from numpy array or SparseTensor
run_options – See onnxruntime.RunOptions.
@@ -410,13 +454,25 @@ Main class
-Options¶
+Options¶
-RunOptions¶
+RunOptions¶
-
-class onnxruntime.RunOptions(self: onnxruntime.capi.onnxruntime_pybind11_state.RunOptions) None¶
+class onnxruntime.RunOptions(self: onnxruntime.capi.onnxruntime_pybind11_state.RunOptions)¶
Configuration information for a single Run.
+
+-
+add_run_config_entry(self: onnxruntime.capi.onnxruntime_pybind11_state.RunOptions, arg0: str, arg1: str) None¶
+Set a single run configuration entry as a pair of strings.
+
+
+
+-
+get_run_config_entry(self: onnxruntime.capi.onnxruntime_pybind11_state.RunOptions, arg0: str) str¶
+Get a single run configuration value using the given configuration key.
+
+
-
property log_severity_level¶
@@ -453,11 +509,16 @@ RunOptions
-SessionOptions¶
+SessionOptions¶
-
-class onnxruntime.SessionOptions(self: onnxruntime.capi.onnxruntime_pybind11_state.SessionOptions) None¶
+class onnxruntime.SessionOptions(self: onnxruntime.capi.onnxruntime_pybind11_state.SessionOptions)¶
Configuration information for a session.
+
+-
+add_external_initializers(self: onnxruntime.capi.onnxruntime_pybind11_state.SessionOptions, arg0: list, arg1: list) None¶
+
+
-
add_free_dimension_override_by_denotation(self: onnxruntime.capi.onnxruntime_pybind11_state.SessionOptions, arg0: str, arg1: int) None¶
@@ -595,9 +656,9 @@ SessionOptions
-Data¶
-
-OrtValue¶
+Data¶
+
+OrtValue¶
-
class onnxruntime.OrtValue(ortvalue, numpy_obj=None)[source]¶
@@ -628,6 +689,13 @@ OrtValue
+-
+element_type()[source]¶
+Returns the proto type of the data in the OrtValue
+if the OrtValue is a tensor.
+
+
-
has_value()[source]¶
@@ -706,11 +774,21 @@ OrtValue
+-
+update_inplace(np_arr)[source]¶
+Update the OrtValue in place with a new Numpy array. The numpy contents
+are copied over to the device memory backing the OrtValue. It can be used
+to update the input valuess for an InferenceSession with CUDA graph
+enabled or other scenarios where the OrtValue needs to be updated while
+the memory address can not be changed.
+
+
-SparseTensor¶
+SparseTensor¶
-
class onnxruntime.SparseTensor(sparse_tensor)[source]¶
@@ -871,9 +949,9 @@ SparseTensor
-Devices¶
-
-IOBinding¶
+Devices¶
+
+IOBinding¶
-
class onnxruntime.IOBinding(session)[source]¶
@@ -963,7 +1041,7 @@ IOBinding
-OrtDevice¶
+OrtDevice¶
-Internal classes¶
+Internal classes¶
These classes cannot be instantiated by users but they are returned
by methods or functions of this libary.
-ModelMetadata¶
+ModelMetadata¶
-
class onnxruntime.ModelMetadata¶
@@ -1031,7 +1109,7 @@ ModelMetadata
-NodeArg¶
+NodeArg¶
Quick search
©2018-2021, Microsoft. | - Powered by Sphinx 4.3.2 + Powered by Sphinx 5.1.1 & Alabaster 0.7.12 | diff --git a/docs/api/python/auto_examples/index.html b/docs/api/python/auto_examples/index.html index 88c529d5e42e1..375bb3e3ab934 100644 --- a/docs/api/python/auto_examples/index.html +++ b/docs/api/python/auto_examples/index.html @@ -6,7 +6,7 @@ -Gallery of examples¶
+Gallery of examples¶
-Load and predict with ONNX Runtime and a very simple model
+
-
-
-Quick search
©2018-2021, Microsoft. | - Powered by Sphinx 4.3.2 + Powered by Sphinx 5.1.1 & Alabaster 0.7.12 | diff --git a/docs/api/python/auto_examples/plot_backend.html b/docs/api/python/auto_examples/plot_backend.html index bd45265c05b41..b54b072db7998 100644 --- a/docs/api/python/auto_examples/plot_backend.html +++ b/docs/api/python/auto_examples/plot_backend.html @@ -6,7 +6,7 @@ -ONNX Runtime Backend for ONNX¶
+ONNX Runtime Backend for ONNX¶
ONNX Runtime extends the onnx backend API to run predictions using this runtime. Let’s use the API to compute the prediction of a simple logistic regression model.
import numpy as np
-from onnxruntime import datasets
-from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument
-import onnxruntime.backend as backend
from onnx import load
+
+import onnxruntime.backend as backend
The device depends on how the package was compiled, GPU or CPU.
-from onnxruntime import get_device
+from onnxruntime import datasets, get_device
+from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument
+
device = get_device()
name = datasets.get_example("logreg_iris.onnx")
@@ -75,7 +77,6 @@
print(e)
-Out:
[ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: float_input for the following indices
index: 0 Got: 1 Expected: 3
Please fix either the inputs or the model.
@@ -93,7 +94,6 @@
print(e)
-Out:
[ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: float_input for the following indices
index: 0 Got: 1 Expected: 3
Please fix either the inputs or the model.
@@ -103,7 +103,7 @@
and makes it easier to switch between multiple runtimes
with the same API.
Total running time of the script: ( 0 minutes 0.014 seconds)
-
-
+
@@ -177,7 +177,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/auto_examples/plot_common_errors.html b/docs/api/python/auto_examples/plot_common_errors.html
index 634ade6ec6d99..1c5abe3d1eefc 100644
--- a/docs/api/python/auto_examples/plot_common_errors.html
+++ b/docs/api/python/auto_examples/plot_common_errors.html
@@ -6,7 +6,7 @@
- Common errors with onnxruntime — ONNX Runtime 1.11.0 documentation
+ Common errors with onnxruntime — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -44,7 +45,7 @@
to download the full example code
-Common errors with onnxruntime¶
+Common errors with onnxruntime¶
This example looks into several common situations
in which onnxruntime does not return the model
prediction but raises an exception instead.
@@ -52,9 +53,10 @@
Step 1: Train a model using your favorite framework which produced a logistic regression
trained on Iris datasets. The model takes
a vector of dimension 2 and returns a class among three.
-import onnxruntime as rt
+import numpy
+
+import onnxruntime as rt
from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument
-import numpy
from onnxruntime.datasets import get_example
example2 = get_example("logreg_iris.onnx")
@@ -75,7 +77,6 @@
print("{0}: {1}".format(type(e), e))
-Out:
Unexpected type
<class 'onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument'>: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Unexpected input data type. Actual: (tensor(double)) , expected: (tensor(float))
@@ -90,7 +91,6 @@
print("{0}: {1}".format(type(e), e))
-Out:
Misspelled output name
<class 'onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument'>: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid Output Name:misspelled
@@ -106,7 +106,6 @@
print(e)
-Out:
All outputs
[array([0, 0, 0], dtype=int64), [{0: 0.9505997896194458, 1: 0.027834143489599228, 2: 0.021566055715084076}, {0: 0.9974970817565918, 1: 5.6270167988259345e-05, 2: 0.0024466365575790405}, {0: 0.9997311234474182, 1: 1.787709464906584e-07, 2: 0.0002686927327886224}]]
@@ -120,7 +119,6 @@
print("{0}: {1}".format(type(e), e))
-Out:
Misspelled input name
<class 'onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument'>: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid Feed Input Name:misspelled
@@ -128,12 +126,12 @@
onnxruntime does not necessarily fail if the input
dimension is a multiple of the expected input dimension.
for x in [
- numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
- numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
- numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
- ]:
+ numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
+]:
try:
r = sess.run([output_name], {input_name: x})
print("Shape={0} and predicted labels={1}".format(x.shape, r))
@@ -141,12 +139,12 @@
print("ERROR with Shape={0} - {1}".format(x.shape, e))
for x in [
- numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
- numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
- numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
- ]:
+ numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
+]:
try:
r = sess.run(None, {input_name: x})
print("Shape={0} and predicted probabilities={1}".format(x.shape, r[1]))
@@ -154,7 +152,6 @@
print("ERROR with Shape={0} - {1}".format(x.shape, e))
-Out:
ERROR with Shape=(4,) - [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid rank for input: float_input Got: 1 Expected: 2 Please fix either the inputs or the model.
ERROR with Shape=(1, 4) - [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: float_input for the following indices
index: 0 Got: 1 Expected: 3
@@ -186,10 +183,10 @@
It does not fail either if the number of dimension
is higher than expects but produces a warning.
for x in [
- numpy.array([[[1.0, 2.0], [3.0, 4.0]]], dtype=numpy.float32),
- numpy.array([[[1.0, 2.0, 3.0]]], dtype=numpy.float32),
- numpy.array([[[1.0, 2.0]], [[3.0, 4.0]]], dtype=numpy.float32),
- ]:
+ numpy.array([[[1.0, 2.0], [3.0, 4.0]]], dtype=numpy.float32),
+ numpy.array([[[1.0, 2.0, 3.0]]], dtype=numpy.float32),
+ numpy.array([[[1.0, 2.0]], [[3.0, 4.0]]], dtype=numpy.float32),
+]:
try:
r = sess.run([output_name], {input_name: x})
print("Shape={0} and predicted labels={1}".format(x.shape, r))
@@ -197,14 +194,13 @@
print("ERROR with Shape={0} - {1}".format(x.shape, e))
-Out:
ERROR with Shape=(1, 2, 2) - [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid rank for input: float_input Got: 3 Expected: 2 Please fix either the inputs or the model.
ERROR with Shape=(1, 1, 3) - [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid rank for input: float_input Got: 3 Expected: 2 Please fix either the inputs or the model.
ERROR with Shape=(2, 1, 2) - [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid rank for input: float_input Got: 3 Expected: 2 Please fix either the inputs or the model.
Total running time of the script: ( 0 minutes 0.009 seconds)
-
-
+
@@ -278,7 +274,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/auto_examples/plot_convert_pipeline_vectorizer.html b/docs/api/python/auto_examples/plot_convert_pipeline_vectorizer.html
index 063fe38ba0cb9..1c6dd123afd1d 100644
--- a/docs/api/python/auto_examples/plot_convert_pipeline_vectorizer.html
+++ b/docs/api/python/auto_examples/plot_convert_pipeline_vectorizer.html
@@ -6,7 +6,7 @@
- Train, convert and predict with ONNX Runtime — ONNX Runtime 1.11.0 documentation
+ Train, convert and predict with ONNX Runtime — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -44,7 +45,7 @@
to download the full example code
-Train, convert and predict with ONNX Runtime¶
+Train, convert and predict with ONNX Runtime¶
This example demonstrates an end to end scenario
starting with the training of a scikit-learn pipeline
which takes as inputs not a regular vector but a
@@ -57,20 +58,21 @@
-Train a pipeline¶
+Train a pipeline¶
The first step consists in retrieving the boston datset.
import pandas
from sklearn.datasets import load_boston
+
boston = load_boston()
X, y = boston.data, boston.target
from sklearn.model_selection import train_test_split
+
X_train, X_test, y_train, y_test = train_test_split(X, y)
-X_train_dict = pandas.DataFrame(X_train[:,1:]).T.to_dict().values()
-X_test_dict = pandas.DataFrame(X_test[:,1:]).T.to_dict().values()
+X_train_dict = pandas.DataFrame(X_train[:, 1:]).T.to_dict().values()
+X_test_dict = pandas.DataFrame(X_test[:, 1:]).T.to_dict().values()
-Out:
/home/runner/.local/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function load_boston is deprecated; `load_boston` is deprecated in 1.0 and will be removed in 1.2.
The Boston housing prices dataset has an ethical problem. You can refer to
@@ -86,7 +88,6 @@ Train a pipelineTrain a pipeline
We create a pipeline.
-from sklearn.pipeline import make_pipeline
-from sklearn.ensemble import GradientBoostingRegressor
+from sklearn.ensemble import GradientBoostingRegressor
from sklearn.feature_extraction import DictVectorizer
-pipe = make_pipeline(
- DictVectorizer(sparse=False),
- GradientBoostingRegressor())
+from sklearn.pipeline import make_pipeline
+
+pipe = make_pipeline(DictVectorizer(sparse=False), GradientBoostingRegressor())
pipe.fit(X_train_dict, y_train)
-Out:
-Pipeline(steps=[('dictvectorizer', DictVectorizer(sparse=False)),
- ('gradientboostingregressor', GradientBoostingRegressor())])
-
+
-We compute the prediction on the test set
+
+
We compute the prediction on the test set
and we show the confusion matrix.
from sklearn.metrics import r2_score
@@ -133,21 +133,20 @@ Train a pipelineprint(r2_score(y_test, pred))
-Out:
-0.9209977605173356
+0.8843586896936388
-Conversion to ONNX format¶
+Conversion to ONNX format¶
We use module
sklearn-onnx
to convert the model into ONNX format.
from skl2onnx import convert_sklearn
-from skl2onnx.common.data_types import FloatTensorType, Int64TensorType, DictionaryType, SequenceType
+from skl2onnx.common.data_types import DictionaryType, FloatTensorType, Int64TensorType, SequenceType
# initial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))]
-initial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))]
+initial_type = [("float_input", DictionaryType(Int64TensorType([1]), FloatTensorType([])))]
onx = convert_sklearn(pipe, initial_types=initial_type)
with open("pipeline_vectorize.onnx", "wb") as f:
f.write(onx.SerializeToString())
@@ -161,12 +160,12 @@ Conversion to ONNX formatsess = rt.InferenceSession("pipeline_vectorize.onnx", providers=rt.get_available_providers())
import numpy
+
inp, out = sess.get_inputs()[0], sess.get_outputs()[0]
print("input name='{}' and shape={} and type={}".format(inp.name, inp.shape, inp.type))
print("output name='{}' and shape={} and type={}".format(out.name, out.shape, out.type))
-Out:
input name='float_input' and shape=[] and type=map(int64,tensor(float))
output name='variable' and shape=[None, 1] and type=tensor(float)
@@ -179,7 +178,6 @@ Conversion to ONNX formatprint(e)
-Out:
[ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Unexpected input data type. Actual: ((seq(map(int64,tensor(float))))) , expected: ((map(int64,tensor(float))))
@@ -192,14 +190,13 @@ Conversion to ONNX formatprint(r2_score(pred, pred_onx))
-Out:
-0.9999999999999366
+0.9999999999999561
Very similar. ONNX Runtime uses floats instead of doubles,
that explains the small discrepencies.
-Total running time of the script: ( 0 minutes 0.966 seconds)
-
-
+
@@ -274,7 +271,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/auto_examples/plot_load_and_predict.html b/docs/api/python/auto_examples/plot_load_and_predict.html
index 4a088a2b907c4..6cbc374ea28cc 100644
--- a/docs/api/python/auto_examples/plot_load_and_predict.html
+++ b/docs/api/python/auto_examples/plot_load_and_predict.html
@@ -6,7 +6,7 @@
- Load and predict with ONNX Runtime and a very simple model — ONNX Runtime 1.11.0 documentation
+ Load and predict with ONNX Runtime and a very simple model — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -44,12 +45,13 @@
to download the full example code
-Load and predict with ONNX Runtime and a very simple model¶
+Load and predict with ONNX Runtime and a very simple model¶
This example demonstrates how to load a model and compute
the output for an input vector. It also shows how to
retrieve the definition of its inputs and outputs.
-import onnxruntime as rt
-import numpy
+import numpy
+
+import onnxruntime as rt
from onnxruntime.datasets import get_example
@@ -68,7 +70,6 @@
print("input type", input_type)
-Out:
input name x
input shape [3, 4, 5]
input type tensor(float)
@@ -83,7 +84,6 @@
print("output type", output_type)
-Out:
output name y
output shape [3, 4, 5]
output type tensor(float)
@@ -91,32 +91,32 @@
Let’s compute its outputs (or predictions if it is a machine learned model).
import numpy.random
-x = numpy.random.random((3,4,5))
+
+x = numpy.random.random((3, 4, 5))
x = x.astype(numpy.float32)
res = sess.run([output_name], {input_name: x})
print(res)
-Out:
-[array([[[0.6423601 , 0.65232253, 0.6620137 , 0.708999 , 0.65169865],
- [0.548968 , 0.59544575, 0.7161434 , 0.525905 , 0.7210646 ],
- [0.5178277 , 0.5842683 , 0.5627599 , 0.6324704 , 0.5833795 ],
- [0.69634616, 0.60848683, 0.6746977 , 0.50677085, 0.5549751 ]],
-
- [[0.5097179 , 0.59407187, 0.56360227, 0.7223234 , 0.5392329 ],
- [0.5398089 , 0.5622808 , 0.5369593 , 0.5819309 , 0.5735331 ],
- [0.5688669 , 0.71247685, 0.63964766, 0.63349843, 0.63380575],
- [0.64378905, 0.60552883, 0.5184905 , 0.6312441 , 0.5047166 ]],
-
- [[0.63900065, 0.6108959 , 0.5249817 , 0.5055595 , 0.55390376],
- [0.62443805, 0.550723 , 0.5320551 , 0.5522731 , 0.68858314],
- [0.69650024, 0.54673976, 0.56964463, 0.58536506, 0.5743989 ],
- [0.6382853 , 0.5826889 , 0.53635114, 0.52279866, 0.7300966 ]]],
+[array([[[0.6362598 , 0.69637424, 0.66820115, 0.66656613, 0.66833836],
+ [0.6735109 , 0.7306087 , 0.5827978 , 0.5790133 , 0.5281905 ],
+ [0.5875758 , 0.5256195 , 0.5485236 , 0.6221244 , 0.6873636 ],
+ [0.6726905 , 0.6112579 , 0.52476424, 0.54415625, 0.67545795]],
+
+ [[0.5092699 , 0.69676566, 0.70407355, 0.64738125, 0.59030807],
+ [0.5806675 , 0.56875795, 0.5390076 , 0.54938734, 0.7169268 ],
+ [0.6765016 , 0.6001371 , 0.7239268 , 0.50898796, 0.7079662 ],
+ [0.6985444 , 0.5496287 , 0.6313638 , 0.51122195, 0.65290225]],
+
+ [[0.5237154 , 0.671646 , 0.57126474, 0.6550032 , 0.554477 ],
+ [0.5734256 , 0.53975654, 0.69029194, 0.6799297 , 0.5502332 ],
+ [0.5855049 , 0.68936455, 0.5244481 , 0.6527785 , 0.50686556],
+ [0.512562 , 0.6157843 , 0.6511187 , 0.7200693 , 0.62636346]]],
dtype=float32)]
-Total running time of the script: ( 0 minutes 0.013 seconds)
-
-
+
@@ -190,7 +190,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/auto_examples/plot_metadata.html b/docs/api/python/auto_examples/plot_metadata.html
index c17fbe6318ce8..3527bf225d663 100644
--- a/docs/api/python/auto_examples/plot_metadata.html
+++ b/docs/api/python/auto_examples/plot_metadata.html
@@ -6,7 +6,7 @@
- Metadata — ONNX Runtime 1.11.0 documentation
+ Metadata — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -44,7 +45,7 @@
to download the full example code
-Metadata¶
+Metadata¶
ONNX format contains metadata related to how the
model was produced. It is useful when the model
is deployed to production to keep track of which
@@ -53,9 +54,11 @@
logistic regression model trained with
scikit-learn and converted with sklearn-onnx.
from onnxruntime.datasets import get_example
+
example = get_example("logreg_iris.onnx")
import onnx
+
model = onnx.load(example)
print("doc_string={}".format(model.doc_string))
@@ -67,7 +70,6 @@
print("producer_version={}".format(model.producer_version))
-Out:
doc_string=
domain=onnxml
ir_version=3
@@ -79,6 +81,7 @@
With ONNX Runtime:
import onnxruntime as rt
+
sess = rt.InferenceSession(example, providers=rt.get_available_providers())
meta = sess.get_modelmeta()
@@ -90,7 +93,6 @@
print("version={}".format(meta.version))
-Out:
custom_metadata_map={}
description=
domain=onnxml
@@ -99,8 +101,8 @@
version=0
-Total running time of the script: ( 0 minutes 0.005 seconds)
-
-
+
@@ -174,7 +176,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/auto_examples/plot_pipeline.html b/docs/api/python/auto_examples/plot_pipeline.html
index c8e8705dc666b..faef40f360dda 100644
--- a/docs/api/python/auto_examples/plot_pipeline.html
+++ b/docs/api/python/auto_examples/plot_pipeline.html
@@ -6,7 +6,7 @@
- Draw a pipeline — ONNX Runtime 1.11.0 documentation
+ Draw a pipeline — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -44,7 +45,7 @@
to download the full example code
-Draw a pipeline¶
+Draw a pipeline¶
There is no other way to look into one model stored
in ONNX format than looking into its node with
onnx. This example demonstrates
@@ -57,18 +58,19 @@
-Retrieve a model in JSON format¶
+Retrieve a model in JSON format¶
That’s the most simple way.
from onnxruntime.datasets import get_example
+
example1 = get_example("mul_1.onnx")
import onnx
+
model = onnx.load(example1) # model is a ModelProto protobuf message
print(model)
-Out:
ir_version: 3
producer_name: "chenta"
graph {
@@ -133,46 +135,49 @@ Retrieve a model in JSON format
-Draw a model with ONNX¶
+Draw a model with ONNX¶
We use net_drawer.py
included in onnx package.
We use onnx to load the model
in a different way than before.
from onnx import ModelProto
+
model = ModelProto()
-with open(example1, 'rb') as fid:
+with open(example1, "rb") as fid:
content = fid.read()
model.ParseFromString(content)
We convert it into a graph.
-from onnx.tools.net_drawer import GetPydotGraph, GetOpNodeProducer
-pydot_graph = GetPydotGraph(model.graph, name=model.graph.name, rankdir="LR",
- node_producer=GetOpNodeProducer("docstring"))
+from onnx.tools.net_drawer import GetOpNodeProducer, GetPydotGraph
+
+pydot_graph = GetPydotGraph(
+ model.graph, name=model.graph.name, rankdir="LR", node_producer=GetOpNodeProducer("docstring")
+)
pydot_graph.write_dot("graph.dot")
Then into an image
import os
-os.system('dot -O -Tpng graph.dot')
+
+os.system("dot -O -Tpng graph.dot")
-Out:
0
Which we display…
import matplotlib.pyplot as plt
+
image = plt.imread("graph.dot.png")
plt.imshow(image)
-
Out:
-<matplotlib.image.AxesImage object at 0x7feafe274ac0>
+
<matplotlib.image.AxesImage object at 0x7ff7301cd3a0>
-Total running time of the script: ( 0 minutes 0.196 seconds)
-
-
+
@@ -247,7 +252,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/auto_examples/plot_profiling.html b/docs/api/python/auto_examples/plot_profiling.html
index e8c9aa4385043..efddea551e8cd 100644
--- a/docs/api/python/auto_examples/plot_profiling.html
+++ b/docs/api/python/auto_examples/plot_profiling.html
@@ -6,7 +6,7 @@
- Profile the execution of a simple model — ONNX Runtime 1.11.0 documentation
+ Profile the execution of a simple model — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -44,12 +45,13 @@
to download the full example code
-Profile the execution of a simple model¶
+Profile the execution of a simple model¶
ONNX Runtime can profile the execution of the model.
This example shows how to interpret the results.
-import onnx
+import numpy
+import onnx
+
import onnxruntime as rt
-import numpy
from onnxruntime.datasets import get_example
@@ -75,7 +77,6 @@
print(res)
-Out:
[array([[ 1., 4.],
[ 9., 16.],
[25., 36.]], dtype=float32)]
@@ -95,40 +96,40 @@
print(prof_file)
-Out:
-onnxruntime_profile__2022-01-04_17-09-55.json
+onnxruntime_profile__2022-08-16_04-44-08.json
The results are stored un a file in JSON format.
Let’s see what it contains.
import json
+
with open(prof_file, "r") as f:
sess_time = json.load(f)
import pprint
+
pprint.pprint(sess_time)
-Out:
[{'args': {},
'cat': 'Session',
- 'dur': 56,
+ 'dur': 67,
'name': 'model_loading_array',
'ph': 'X',
- 'pid': 3089,
- 'tid': 3089,
+ 'pid': 3111,
+ 'tid': 3111,
'ts': 1},
{'args': {},
'cat': 'Session',
- 'dur': 240,
+ 'dur': 236,
'name': 'session_initialization',
'ph': 'X',
- 'pid': 3089,
- 'tid': 3089,
- 'ts': 71}]
+ 'pid': 3111,
+ 'tid': 3111,
+ 'ts': 85}]
-Total running time of the script: ( 0 minutes 0.007 seconds)
-
-
+
@@ -202,7 +203,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/auto_examples/plot_train_convert_predict.html b/docs/api/python/auto_examples/plot_train_convert_predict.html
index 9b451dc80273b..1cf321928bd24 100644
--- a/docs/api/python/auto_examples/plot_train_convert_predict.html
+++ b/docs/api/python/auto_examples/plot_train_convert_predict.html
@@ -6,7 +6,7 @@
- Train, convert and predict with ONNX Runtime — ONNX Runtime 1.11.0 documentation
+ Train, convert and predict with ONNX Runtime — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -43,7 +44,7 @@
to download the full example code
-Train, convert and predict with ONNX Runtime¶
+Train, convert and predict with ONNX Runtime¶
This example demonstrates an end to end scenario
starting with the training of a machine learned model
to its use in its converted from.
@@ -56,27 +57,30 @@
-Train a logistic regression¶
+Train a logistic regression¶
The first step consists in retrieving the iris datset.
from sklearn.datasets import load_iris
+
iris = load_iris()
X, y = iris.data, iris.target
from sklearn.model_selection import train_test_split
+
X_train, X_test, y_train, y_test = train_test_split(X, y)
Then we fit a model.
from sklearn.linear_model import LogisticRegression
+
clr = LogisticRegression()
clr.fit(X_train, y_train)
-Out:
-LogisticRegression()
-
+
-We compute the prediction on the test set
+
+
We compute the prediction on the test set
and we show the confusion matrix.
from sklearn.metrics import confusion_matrix
@@ -84,22 +88,21 @@ Train a logistic regressionprint(confusion_matrix(y_test, pred))
-Out:
-[[13 0 0]
+[[17 0 0]
[ 0 10 1]
- [ 0 0 14]]
+ [ 0 0 10]]
-Conversion to ONNX format¶
+Conversion to ONNX format¶
We use module
sklearn-onnx
to convert the model into ONNX format.
from skl2onnx import convert_sklearn
from skl2onnx.common.data_types import FloatTensorType
-initial_type = [('float_input', FloatTensorType([None, 4]))]
+initial_type = [("float_input", FloatTensorType([None, 4]))]
onx = convert_sklearn(clr, initial_types=initial_type)
with open("logreg_iris.onnx", "wb") as f:
f.write(onx.SerializeToString())
@@ -108,15 +111,13 @@ Conversion to ONNX formatimport onnxruntime as rt
+
sess = rt.InferenceSession("logreg_iris.onnx", providers=rt.get_available_providers())
-print("input name='{}' and shape={}".format(
- sess.get_inputs()[0].name, sess.get_inputs()[0].shape))
-print("output name='{}' and shape={}".format(
- sess.get_outputs()[0].name, sess.get_outputs()[0].shape))
+print("input name='{}' and shape={}".format(sess.get_inputs()[0].name, sess.get_inputs()[0].shape))
+print("output name='{}' and shape={}".format(sess.get_outputs()[0].name, sess.get_outputs()[0].shape))
-Out:
input name='float_input' and shape=[None, 4]
output name='output_label' and shape=[None]
@@ -126,20 +127,20 @@ Conversion to ONNX formatlabel_name = sess.get_outputs()[0].name
import numpy
+
pred_onx = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]
print(confusion_matrix(pred, pred_onx))
-Out:
-[[13 0 0]
+[[17 0 0]
[ 0 10 0]
- [ 0 0 15]]
+ [ 0 0 11]]
The prediction are perfectly identical.
-Probabilities¶
+Probabilities¶
Probabilities are needed to compute other
relevant metrics such as the ROC Curve.
Let’s see how to get them first with
@@ -148,10 +149,9 @@
Probabilitiesprint(prob_sklearn[:3])
-Out:
-[[2.95951945e-05 5.69800366e-02 9.42990368e-01]
- [1.84923705e-05 3.93636566e-02 9.60617851e-01]
- [1.30004554e-02 8.03678159e-01 1.83321386e-01]]
+[[1.82164782e-01 8.13598178e-01 4.23703980e-03]
+ [8.12021102e-04 3.37134524e-01 6.62053455e-01]
+ [1.20249493e-06 1.74038501e-02 9.82594947e-01]]
And then with ONNX Runtime.
@@ -160,18 +160,19 @@
Probabilitiesprob_rt = sess.run([prob_name], {input_name: X_test.astype(numpy.float32)})[0]
import pprint
+
pprint.pprint(prob_rt[0:3])
-Out:
-[{0: 2.9595235901069827e-05, 1: 0.05698008090257645, 2: 0.9429903030395508},
- {0: 1.8492364688427188e-05, 1: 0.03936365991830826, 2: 0.9606178402900696},
- {0: 0.013000461272895336, 1: 0.8036782741546631, 2: 0.1833212822675705}]
+[{0: 0.18216472864151, 1: 0.8135982751846313, 2: 0.0042370399460196495},
+ {0: 0.0008120210259221494, 1: 0.3371346592903137, 2: 0.6620532870292664},
+ {0: 1.2024959232803667e-06, 1: 0.01740385964512825, 2: 0.9825949668884277}]
Let’s benchmark.
from timeit import Timer
+
def speed(inst, number=10, repeat=20):
timer = Timer(inst, globals=globals())
raw = numpy.array(timer.repeat(repeat, number=number))
@@ -180,6 +181,7 @@ Probabilitiesprint("Average %1.3g min=%1.3g max=%1.3g" % (ave, mi, ma))
return ave
+
print("Execution time for clr.predict")
speed("clr.predict(X_test)")
@@ -187,13 +189,12 @@ Probabilitiesspeed("sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]")
-Out:
Execution time for clr.predict
-Average 4.38e-05 min=4.25e-05 max=6.07e-05
+Average 4.46e-05 min=4.3e-05 max=5.6e-05
Execution time for ONNX Runtime
-Average 1.97e-05 min=1.92e-05 max=2.46e-05
+Average 1.84e-05 min=1.78e-05 max=2.5e-05
-1.9671264999914226e-05
+1.838059500016698e-05
Let’s benchmark a scenario similar to what a webservice
@@ -205,45 +206,48 @@
Probabilitiesn = nrow
for i in range(0, n):
im = i % nrow
- fct(X_test[im: im+1])
+ fct(X_test[im : im + 1])
+
print("Execution time for clr.predict")
speed("loop(X_test, clr.predict, 100)")
+
def sess_predict(x):
return sess.run([label_name], {input_name: x.astype(numpy.float32)})[0]
+
print("Execution time for sess_predict")
speed("loop(X_test, sess_predict, 100)")
-Out:
Execution time for clr.predict
-Average 0.00404 min=0.00402 max=0.00409
+Average 0.0042 min=0.00418 max=0.00428
Execution time for sess_predict
-Average 0.000881 min=0.000874 max=0.000912
+Average 0.000862 min=0.000856 max=0.000878
-0.0008813192099997735
+0.0008617829299998903
Let’s do the same for the probabilities.
print("Execution time for predict_proba")
speed("loop(X_test, clr.predict_proba, 100)")
+
def sess_predict_proba(x):
return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]
+
print("Execution time for sess_predict_proba")
speed("loop(X_test, sess_predict_proba, 100)")
-Out:
Execution time for predict_proba
-Average 0.00599 min=0.00597 max=0.00606
+Average 0.00617 min=0.00615 max=0.0062
Execution time for sess_predict_proba
-Average 0.000883 min=0.000876 max=0.000916
+Average 0.000887 min=0.00088 max=0.000915
-0.0008830492349999729
+0.0008867338849996997
This second comparison is better as
@@ -252,13 +256,14 @@
Probabilities
-Benchmark with RandomForest¶
+Benchmark with RandomForest¶
We first train and save a model in ONNX format.
from sklearn.ensemble import RandomForestClassifier
+
rf = RandomForestClassifier()
rf.fit(X_train, y_train)
-initial_type = [('float_input', FloatTensorType([1, 4]))]
+initial_type = [("float_input", FloatTensorType([1, 4]))]
onx = convert_sklearn(rf, initial_types=initial_type)
with open("rf_iris.onnx", "wb") as f:
f.write(onx.SerializeToString())
@@ -267,9 +272,11 @@ Benchmark with RandomForestsess = rt.InferenceSession("rf_iris.onnx", providers=rt.get_available_providers())
+
def sess_predict_proba_rf(x):
return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]
+
print("Execution time for predict_proba")
speed("loop(X_test, rf.predict_proba, 100)")
@@ -277,13 +284,12 @@ Benchmark with RandomForestspeed("loop(X_test, sess_predict_proba_rf, 100)")
-Out:
Execution time for predict_proba
-Average 0.717 min=0.715 max=0.72
+Average 0.723 min=0.721 max=0.729
Execution time for sess_predict_proba
-Average 0.00108 min=0.00107 max=0.00111
+Average 0.00103 min=0.00102 max=0.00106
-0.0010817126199989956
+0.0010315913400006592
Let’s see with different number of trees.
@@ -293,65 +299,66 @@ Benchmark with RandomForestprint(n_trees)
rf = RandomForestClassifier(n_estimators=n_trees)
rf.fit(X_train, y_train)
- initial_type = [('float_input', FloatTensorType([1, 4]))]
+ initial_type = [("float_input", FloatTensorType([1, 4]))]
onx = convert_sklearn(rf, initial_types=initial_type)
with open("rf_iris_%d.onnx" % n_trees, "wb") as f:
f.write(onx.SerializeToString())
sess = rt.InferenceSession("rf_iris_%d.onnx" % n_trees, providers=rt.get_available_providers())
+
def sess_predict_proba_loop(x):
return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]
+
tsk = speed("loop(X_test, rf.predict_proba, 100)", number=5, repeat=5)
trt = speed("loop(X_test, sess_predict_proba_loop, 100)", number=5, repeat=5)
- measures.append({'n_trees': n_trees, 'sklearn': tsk, 'rt': trt})
+ measures.append({"n_trees": n_trees, "sklearn": tsk, "rt": trt})
from pandas import DataFrame
+
df = DataFrame(measures)
ax = df.plot(x="n_trees", y="sklearn", label="scikit-learn", c="blue", logy=True)
-df.plot(x="n_trees", y="rt", label="onnxruntime",
- ax=ax, c="green", logy=True)
+df.plot(x="n_trees", y="rt", label="onnxruntime", ax=ax, c="green", logy=True)
ax.set_xlabel("Number of trees")
ax.set_ylabel("Prediction time (s)")
ax.set_title("Speed comparison between scikit-learn and ONNX Runtime\nFor a random forest on Iris dataset")
ax.legend()
-
Out:
-5
-Average 0.0637 min=0.0636 max=0.0639
-Average 0.000869 min=0.000857 max=0.000899
+
5
+Average 0.0519 min=0.0519 max=0.0521
+Average 0.000867 min=0.000856 max=0.000898
10
-Average 0.0982 min=0.098 max=0.0987
-Average 0.000884 min=0.000873 max=0.00091
+Average 0.0872 min=0.0871 max=0.0875
+Average 0.000881 min=0.000877 max=0.000893
15
-Average 0.133 min=0.133 max=0.133
-Average 0.000895 min=0.000885 max=0.000921
+Average 0.123 min=0.122 max=0.123
+Average 0.000908 min=0.000896 max=0.000938
20
-Average 0.168 min=0.167 max=0.168
-Average 0.000915 min=0.000907 max=0.00094
+Average 0.158 min=0.158 max=0.158
+Average 0.000902 min=0.000896 max=0.000918
25
-Average 0.202 min=0.201 max=0.203
-Average 0.000921 min=0.000913 max=0.000948
+Average 0.193 min=0.193 max=0.193
+Average 0.000929 min=0.000914 max=0.000961
30
-Average 0.236 min=0.236 max=0.237
-Average 0.000922 min=0.000914 max=0.000948
+Average 0.228 min=0.228 max=0.229
+Average 0.000927 min=0.000915 max=0.000948
35
-Average 0.271 min=0.271 max=0.271
-Average 0.000941 min=0.000928 max=0.000967
+Average 0.263 min=0.263 max=0.264
+Average 0.000946 min=0.000935 max=0.000978
40
-Average 0.305 min=0.305 max=0.305
-Average 0.000948 min=0.000934 max=0.000977
+Average 0.298 min=0.298 max=0.299
+Average 0.000952 min=0.000943 max=0.000972
45
-Average 0.34 min=0.339 max=0.34
-Average 0.000983 min=0.000972 max=0.00101
+Average 0.334 min=0.333 max=0.335
+Average 0.000953 min=0.000943 max=0.000985
50
-Average 0.375 min=0.374 max=0.375
-Average 0.000972 min=0.000966 max=0.000992
+Average 0.369 min=0.369 max=0.371
+Average 0.000981 min=0.000973 max=0.00101
-<matplotlib.legend.Legend object at 0x7feaf2025c10>
+<matplotlib.legend.Legend object at 0x7ff71efab280>
-Total running time of the script: ( 3 minutes 22.159 seconds)
-
-
+
@@ -425,7 +432,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/auto_examples/sg_execution_times.html b/docs/api/python/auto_examples/sg_execution_times.html
index fbc71647b8669..a99f2bc17e27c 100644
--- a/docs/api/python/auto_examples/sg_execution_times.html
+++ b/docs/api/python/auto_examples/sg_execution_times.html
@@ -6,7 +6,7 @@
- Computation times — ONNX Runtime 1.11.0 documentation
+ Computation times — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -37,8 +38,8 @@
-Computation times¶
-03:23.370 total execution time for auto_examples files:
+Computation times¶
+03:22.379 total execution time for auto_examples files:
@@ -47,35 +48,35 @@
Train, convert and predict with ONNX Runtime (plot_train_convert_predict.py)
-03:22.159
+03:21.167
0.0 MB
Train, convert and predict with ONNX Runtime (plot_convert_pipeline_vectorizer.py)
-00:00.966
+00:00.956
0.0 MB
Draw a pipeline (plot_pipeline.py)
-00:00.196
+00:00.218
0.0 MB
ONNX Runtime Backend for ONNX (plot_backend.py)
00:00.014
0.0 MB
-Load and predict with ONNX Runtime and a very simple model (plot_load_and_predict.py)
-00:00.013
+Common errors with onnxruntime (plot_common_errors.py)
+00:00.009
0.0 MB
-Common errors with onnxruntime (plot_common_errors.py)
-00:00.009
+Load and predict with ONNX Runtime and a very simple model (plot_load_and_predict.py)
+00:00.007
0.0 MB
Profile the execution of a simple model (plot_profiling.py)
-00:00.007
+00:00.005
0.0 MB
Metadata (plot_metadata.py)
-00:00.005
+00:00.003
0.0 MB
@@ -104,7 +105,7 @@ ONNX Runtime
Navigation
@@ -124,7 +125,7 @@ Quick search
-
+
@@ -141,7 +142,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/downloads/07fcc19ba03226cd3d83d4e40ec44385/auto_examples_python.zip b/docs/api/python/downloads/07fcc19ba03226cd3d83d4e40ec44385/auto_examples_python.zip
index 45a147fd36b34..3a0c03fd05f7b 100644
Binary files a/docs/api/python/downloads/07fcc19ba03226cd3d83d4e40ec44385/auto_examples_python.zip and b/docs/api/python/downloads/07fcc19ba03226cd3d83d4e40ec44385/auto_examples_python.zip differ
diff --git a/docs/api/python/downloads/1680115d3d937dfbb2d86adb705d9c5d/plot_train_convert_predict.ipynb b/docs/api/python/downloads/1680115d3d937dfbb2d86adb705d9c5d/plot_train_convert_predict.ipynb
index eee04c34d6f1f..470c162b0ae63 100644
--- a/docs/api/python/downloads/1680115d3d937dfbb2d86adb705d9c5d/plot_train_convert_predict.ipynb
+++ b/docs/api/python/downloads/1680115d3d937dfbb2d86adb705d9c5d/plot_train_convert_predict.ipynb
@@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
- "from sklearn.datasets import load_iris\niris = load_iris()\nX, y = iris.data, iris.target\n\nfrom sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y)"
+ "from sklearn.datasets import load_iris\n\niris = load_iris()\nX, y = iris.data, iris.target\n\nfrom sklearn.model_selection import train_test_split\n\nX_train, X_test, y_train, y_test = train_test_split(X, y)"
]
},
{
@@ -44,7 +44,7 @@
},
"outputs": [],
"source": [
- "from sklearn.linear_model import LogisticRegression\nclr = LogisticRegression()\nclr.fit(X_train, y_train)"
+ "from sklearn.linear_model import LogisticRegression\n\nclr = LogisticRegression()\nclr.fit(X_train, y_train)"
]
},
{
@@ -69,7 +69,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Conversion to ONNX format\n\nWe use module \n`sklearn-onnx `_\nto convert the model into ONNX format.\n\n"
+ "## Conversion to ONNX format\n\nWe use module\n[sklearn-onnx](https://github.com/onnx/sklearn-onnx)\nto convert the model into ONNX format.\n\n"
]
},
{
@@ -80,7 +80,7 @@
},
"outputs": [],
"source": [
- "from skl2onnx import convert_sklearn\nfrom skl2onnx.common.data_types import FloatTensorType\n\ninitial_type = [('float_input', FloatTensorType([None, 4]))]\nonx = convert_sklearn(clr, initial_types=initial_type)\nwith open(\"logreg_iris.onnx\", \"wb\") as f:\n f.write(onx.SerializeToString())"
+ "from skl2onnx import convert_sklearn\nfrom skl2onnx.common.data_types import FloatTensorType\n\ninitial_type = [(\"float_input\", FloatTensorType([None, 4]))]\nonx = convert_sklearn(clr, initial_types=initial_type)\nwith open(\"logreg_iris.onnx\", \"wb\") as f:\n f.write(onx.SerializeToString())"
]
},
{
@@ -98,7 +98,7 @@
},
"outputs": [],
"source": [
- "import onnxruntime as rt\nsess = rt.InferenceSession(\"logreg_iris.onnx\", providers=rt.get_available_providers())\n\nprint(\"input name='{}' and shape={}\".format(\n sess.get_inputs()[0].name, sess.get_inputs()[0].shape))\nprint(\"output name='{}' and shape={}\".format(\n sess.get_outputs()[0].name, sess.get_outputs()[0].shape))"
+ "import onnxruntime as rt\n\nsess = rt.InferenceSession(\"logreg_iris.onnx\", providers=rt.get_available_providers())\n\nprint(\"input name='{}' and shape={}\".format(sess.get_inputs()[0].name, sess.get_inputs()[0].shape))\nprint(\"output name='{}' and shape={}\".format(sess.get_outputs()[0].name, sess.get_outputs()[0].shape))"
]
},
{
@@ -116,7 +116,7 @@
},
"outputs": [],
"source": [
- "input_name = sess.get_inputs()[0].name\nlabel_name = sess.get_outputs()[0].name\n\nimport numpy\npred_onx = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]\nprint(confusion_matrix(pred, pred_onx))"
+ "input_name = sess.get_inputs()[0].name\nlabel_name = sess.get_outputs()[0].name\n\nimport numpy\n\npred_onx = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]\nprint(confusion_matrix(pred, pred_onx))"
]
},
{
@@ -141,7 +141,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "And then with ONNX Runtime.\nThe probabilies appear to be \n\n"
+ "And then with ONNX Runtime.\nThe probabilies appear to be\n\n"
]
},
{
@@ -152,7 +152,7 @@
},
"outputs": [],
"source": [
- "prob_name = sess.get_outputs()[1].name\nprob_rt = sess.run([prob_name], {input_name: X_test.astype(numpy.float32)})[0]\n\nimport pprint\npprint.pprint(prob_rt[0:3])"
+ "prob_name = sess.get_outputs()[1].name\nprob_rt = sess.run([prob_name], {input_name: X_test.astype(numpy.float32)})[0]\n\nimport pprint\n\npprint.pprint(prob_rt[0:3])"
]
},
{
@@ -170,7 +170,7 @@
},
"outputs": [],
"source": [
- "from timeit import Timer\n\ndef speed(inst, number=10, repeat=20):\n timer = Timer(inst, globals=globals())\n raw = numpy.array(timer.repeat(repeat, number=number))\n ave = raw.sum() / len(raw) / number\n mi, ma = raw.min() / number, raw.max() / number\n print(\"Average %1.3g min=%1.3g max=%1.3g\" % (ave, mi, ma))\n return ave\n\nprint(\"Execution time for clr.predict\")\nspeed(\"clr.predict(X_test)\")\n\nprint(\"Execution time for ONNX Runtime\")\nspeed(\"sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]\")"
+ "from timeit import Timer\n\n\ndef speed(inst, number=10, repeat=20):\n timer = Timer(inst, globals=globals())\n raw = numpy.array(timer.repeat(repeat, number=number))\n ave = raw.sum() / len(raw) / number\n mi, ma = raw.min() / number, raw.max() / number\n print(\"Average %1.3g min=%1.3g max=%1.3g\" % (ave, mi, ma))\n return ave\n\n\nprint(\"Execution time for clr.predict\")\nspeed(\"clr.predict(X_test)\")\n\nprint(\"Execution time for ONNX Runtime\")\nspeed(\"sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]\")"
]
},
{
@@ -188,7 +188,7 @@
},
"outputs": [],
"source": [
- "def loop(X_test, fct, n=None):\n nrow = X_test.shape[0]\n if n is None:\n n = nrow\n for i in range(0, n):\n im = i % nrow\n fct(X_test[im: im+1])\n\nprint(\"Execution time for clr.predict\")\nspeed(\"loop(X_test, clr.predict, 100)\")\n\ndef sess_predict(x):\n return sess.run([label_name], {input_name: x.astype(numpy.float32)})[0]\n\nprint(\"Execution time for sess_predict\")\nspeed(\"loop(X_test, sess_predict, 100)\")"
+ "def loop(X_test, fct, n=None):\n nrow = X_test.shape[0]\n if n is None:\n n = nrow\n for i in range(0, n):\n im = i % nrow\n fct(X_test[im : im + 1])\n\n\nprint(\"Execution time for clr.predict\")\nspeed(\"loop(X_test, clr.predict, 100)\")\n\n\ndef sess_predict(x):\n return sess.run([label_name], {input_name: x.astype(numpy.float32)})[0]\n\n\nprint(\"Execution time for sess_predict\")\nspeed(\"loop(X_test, sess_predict, 100)\")"
]
},
{
@@ -206,14 +206,14 @@
},
"outputs": [],
"source": [
- "print(\"Execution time for predict_proba\")\nspeed(\"loop(X_test, clr.predict_proba, 100)\")\n\ndef sess_predict_proba(x):\n return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]\n\nprint(\"Execution time for sess_predict_proba\")\nspeed(\"loop(X_test, sess_predict_proba, 100)\")"
+ "print(\"Execution time for predict_proba\")\nspeed(\"loop(X_test, clr.predict_proba, 100)\")\n\n\ndef sess_predict_proba(x):\n return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]\n\n\nprint(\"Execution time for sess_predict_proba\")\nspeed(\"loop(X_test, sess_predict_proba, 100)\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "This second comparison is better as \nONNX Runtime, in this experience,\ncomputes the label and the probabilities\nin every case.\n\n"
+ "This second comparison is better as\nONNX Runtime, in this experience,\ncomputes the label and the probabilities\nin every case.\n\n"
]
},
{
@@ -231,7 +231,7 @@
},
"outputs": [],
"source": [
- "from sklearn.ensemble import RandomForestClassifier\nrf = RandomForestClassifier()\nrf.fit(X_train, y_train)\n\ninitial_type = [('float_input', FloatTensorType([1, 4]))]\nonx = convert_sklearn(rf, initial_types=initial_type)\nwith open(\"rf_iris.onnx\", \"wb\") as f:\n f.write(onx.SerializeToString())"
+ "from sklearn.ensemble import RandomForestClassifier\n\nrf = RandomForestClassifier()\nrf.fit(X_train, y_train)\n\ninitial_type = [(\"float_input\", FloatTensorType([1, 4]))]\nonx = convert_sklearn(rf, initial_types=initial_type)\nwith open(\"rf_iris.onnx\", \"wb\") as f:\n f.write(onx.SerializeToString())"
]
},
{
@@ -249,7 +249,7 @@
},
"outputs": [],
"source": [
- "sess = rt.InferenceSession(\"rf_iris.onnx\", providers=rt.get_available_providers())\n\ndef sess_predict_proba_rf(x):\n return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]\n\nprint(\"Execution time for predict_proba\")\nspeed(\"loop(X_test, rf.predict_proba, 100)\")\n\nprint(\"Execution time for sess_predict_proba\")\nspeed(\"loop(X_test, sess_predict_proba_rf, 100)\")"
+ "sess = rt.InferenceSession(\"rf_iris.onnx\", providers=rt.get_available_providers())\n\n\ndef sess_predict_proba_rf(x):\n return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]\n\n\nprint(\"Execution time for predict_proba\")\nspeed(\"loop(X_test, rf.predict_proba, 100)\")\n\nprint(\"Execution time for sess_predict_proba\")\nspeed(\"loop(X_test, sess_predict_proba_rf, 100)\")"
]
},
{
@@ -267,7 +267,7 @@
},
"outputs": [],
"source": [
- "measures = []\n\nfor n_trees in range(5, 51, 5): \n print(n_trees)\n rf = RandomForestClassifier(n_estimators=n_trees)\n rf.fit(X_train, y_train)\n initial_type = [('float_input', FloatTensorType([1, 4]))]\n onx = convert_sklearn(rf, initial_types=initial_type)\n with open(\"rf_iris_%d.onnx\" % n_trees, \"wb\") as f:\n f.write(onx.SerializeToString())\n sess = rt.InferenceSession(\"rf_iris_%d.onnx\" % n_trees, providers=rt.get_available_providers())\n def sess_predict_proba_loop(x):\n return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]\n tsk = speed(\"loop(X_test, rf.predict_proba, 100)\", number=5, repeat=5)\n trt = speed(\"loop(X_test, sess_predict_proba_loop, 100)\", number=5, repeat=5)\n measures.append({'n_trees': n_trees, 'sklearn': tsk, 'rt': trt})\n\nfrom pandas import DataFrame\ndf = DataFrame(measures)\nax = df.plot(x=\"n_trees\", y=\"sklearn\", label=\"scikit-learn\", c=\"blue\", logy=True)\ndf.plot(x=\"n_trees\", y=\"rt\", label=\"onnxruntime\",\n ax=ax, c=\"green\", logy=True)\nax.set_xlabel(\"Number of trees\")\nax.set_ylabel(\"Prediction time (s)\")\nax.set_title(\"Speed comparison between scikit-learn and ONNX Runtime\\nFor a random forest on Iris dataset\")\nax.legend()"
+ "measures = []\n\nfor n_trees in range(5, 51, 5):\n print(n_trees)\n rf = RandomForestClassifier(n_estimators=n_trees)\n rf.fit(X_train, y_train)\n initial_type = [(\"float_input\", FloatTensorType([1, 4]))]\n onx = convert_sklearn(rf, initial_types=initial_type)\n with open(\"rf_iris_%d.onnx\" % n_trees, \"wb\") as f:\n f.write(onx.SerializeToString())\n sess = rt.InferenceSession(\"rf_iris_%d.onnx\" % n_trees, providers=rt.get_available_providers())\n\n def sess_predict_proba_loop(x):\n return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]\n\n tsk = speed(\"loop(X_test, rf.predict_proba, 100)\", number=5, repeat=5)\n trt = speed(\"loop(X_test, sess_predict_proba_loop, 100)\", number=5, repeat=5)\n measures.append({\"n_trees\": n_trees, \"sklearn\": tsk, \"rt\": trt})\n\nfrom pandas import DataFrame\n\ndf = DataFrame(measures)\nax = df.plot(x=\"n_trees\", y=\"sklearn\", label=\"scikit-learn\", c=\"blue\", logy=True)\ndf.plot(x=\"n_trees\", y=\"rt\", label=\"onnxruntime\", ax=ax, c=\"green\", logy=True)\nax.set_xlabel(\"Number of trees\")\nax.set_ylabel(\"Prediction time (s)\")\nax.set_title(\"Speed comparison between scikit-learn and ONNX Runtime\\nFor a random forest on Iris dataset\")\nax.legend()"
]
}
],
diff --git a/docs/api/python/downloads/1b60ac13d6a5a4b72d4e4d28d1544f8d/plot_common_errors.ipynb b/docs/api/python/downloads/1b60ac13d6a5a4b72d4e4d28d1544f8d/plot_common_errors.ipynb
index 78c57d9d0d211..bba0472e83a8c 100644
--- a/docs/api/python/downloads/1b60ac13d6a5a4b72d4e4d28d1544f8d/plot_common_errors.ipynb
+++ b/docs/api/python/downloads/1b60ac13d6a5a4b72d4e4d28d1544f8d/plot_common_errors.ipynb
@@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
- "import onnxruntime as rt\nfrom onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument\nimport numpy\nfrom onnxruntime.datasets import get_example\n\nexample2 = get_example(\"logreg_iris.onnx\")\nsess = rt.InferenceSession(example2, providers=rt.get_available_providers())\n\ninput_name = sess.get_inputs()[0].name\noutput_name = sess.get_outputs()[0].name"
+ "import numpy\n\nimport onnxruntime as rt\nfrom onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument\nfrom onnxruntime.datasets import get_example\n\nexample2 = get_example(\"logreg_iris.onnx\")\nsess = rt.InferenceSession(example2, providers=rt.get_available_providers())\n\ninput_name = sess.get_inputs()[0].name\noutput_name = sess.get_outputs()[0].name"
]
},
{
@@ -116,7 +116,7 @@
},
"outputs": [],
"source": [
- "for x in [\n numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),\n numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),\n numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),\n numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),\n numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),\n ]:\n try:\n r = sess.run([output_name], {input_name: x})\n print(\"Shape={0} and predicted labels={1}\".format(x.shape, r))\n except (RuntimeError, InvalidArgument) as e:\n print(\"ERROR with Shape={0} - {1}\".format(x.shape, e))\n\nfor x in [\n numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),\n numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),\n numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),\n numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),\n numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),\n ]:\n try:\n r = sess.run(None, {input_name: x})\n print(\"Shape={0} and predicted probabilities={1}\".format(x.shape, r[1]))\n except (RuntimeError, InvalidArgument) as e:\n print(\"ERROR with Shape={0} - {1}\".format(x.shape, e))"
+ "for x in [\n numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),\n numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),\n numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),\n numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),\n numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),\n]:\n try:\n r = sess.run([output_name], {input_name: x})\n print(\"Shape={0} and predicted labels={1}\".format(x.shape, r))\n except (RuntimeError, InvalidArgument) as e:\n print(\"ERROR with Shape={0} - {1}\".format(x.shape, e))\n\nfor x in [\n numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),\n numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),\n numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),\n numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),\n numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),\n]:\n try:\n r = sess.run(None, {input_name: x})\n print(\"Shape={0} and predicted probabilities={1}\".format(x.shape, r[1]))\n except (RuntimeError, InvalidArgument) as e:\n print(\"ERROR with Shape={0} - {1}\".format(x.shape, e))"
]
},
{
@@ -134,7 +134,7 @@
},
"outputs": [],
"source": [
- "for x in [\n numpy.array([[[1.0, 2.0], [3.0, 4.0]]], dtype=numpy.float32),\n numpy.array([[[1.0, 2.0, 3.0]]], dtype=numpy.float32),\n numpy.array([[[1.0, 2.0]], [[3.0, 4.0]]], dtype=numpy.float32),\n ]:\n try:\n r = sess.run([output_name], {input_name: x})\n print(\"Shape={0} and predicted labels={1}\".format(x.shape, r))\n except (RuntimeError, InvalidArgument) as e:\n print(\"ERROR with Shape={0} - {1}\".format(x.shape, e))"
+ "for x in [\n numpy.array([[[1.0, 2.0], [3.0, 4.0]]], dtype=numpy.float32),\n numpy.array([[[1.0, 2.0, 3.0]]], dtype=numpy.float32),\n numpy.array([[[1.0, 2.0]], [[3.0, 4.0]]], dtype=numpy.float32),\n]:\n try:\n r = sess.run([output_name], {input_name: x})\n print(\"Shape={0} and predicted labels={1}\".format(x.shape, r))\n except (RuntimeError, InvalidArgument) as e:\n print(\"ERROR with Shape={0} - {1}\".format(x.shape, e))"
]
}
],
diff --git a/docs/api/python/downloads/290d1103c4874727a37c05b400ffb83c/plot_load_and_predict.ipynb b/docs/api/python/downloads/290d1103c4874727a37c05b400ffb83c/plot_load_and_predict.ipynb
index 964763966024d..fc384bf89e972 100644
--- a/docs/api/python/downloads/290d1103c4874727a37c05b400ffb83c/plot_load_and_predict.ipynb
+++ b/docs/api/python/downloads/290d1103c4874727a37c05b400ffb83c/plot_load_and_predict.ipynb
@@ -26,14 +26,14 @@
},
"outputs": [],
"source": [
- "import onnxruntime as rt\nimport numpy\nfrom onnxruntime.datasets import get_example"
+ "import numpy\n\nimport onnxruntime as rt\nfrom onnxruntime.datasets import get_example"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Let's load a very simple model.\nThe model is available on github `onnx...test_sigmoid `_.\n\n"
+ "Let's load a very simple model.\nThe model is available on github [onnx...test_sigmoid](https://github.com/onnx/onnx/tree/master/onnx/backend/test/data/node/test_sigmoid).\n\n"
]
},
{
@@ -80,7 +80,7 @@
},
"outputs": [],
"source": [
- "output_name = sess.get_outputs()[0].name\nprint(\"output name\", output_name) \noutput_shape = sess.get_outputs()[0].shape\nprint(\"output shape\", output_shape)\noutput_type = sess.get_outputs()[0].type\nprint(\"output type\", output_type)"
+ "output_name = sess.get_outputs()[0].name\nprint(\"output name\", output_name)\noutput_shape = sess.get_outputs()[0].shape\nprint(\"output shape\", output_shape)\noutput_type = sess.get_outputs()[0].type\nprint(\"output type\", output_type)"
]
},
{
@@ -98,7 +98,7 @@
},
"outputs": [],
"source": [
- "import numpy.random\nx = numpy.random.random((3,4,5))\nx = x.astype(numpy.float32)\nres = sess.run([output_name], {input_name: x})\nprint(res)"
+ "import numpy.random\n\nx = numpy.random.random((3, 4, 5))\nx = x.astype(numpy.float32)\nres = sess.run([output_name], {input_name: x})\nprint(res)"
]
}
],
diff --git a/docs/api/python/downloads/2dbd202de70c8b6a394b8a1c7c1e12b8/plot_pipeline.ipynb b/docs/api/python/downloads/2dbd202de70c8b6a394b8a1c7c1e12b8/plot_pipeline.ipynb
index c79f384172df4..93d0efdcbf5f4 100644
--- a/docs/api/python/downloads/2dbd202de70c8b6a394b8a1c7c1e12b8/plot_pipeline.ipynb
+++ b/docs/api/python/downloads/2dbd202de70c8b6a394b8a1c7c1e12b8/plot_pipeline.ipynb
@@ -26,14 +26,14 @@
},
"outputs": [],
"source": [
- "from onnxruntime.datasets import get_example\nexample1 = get_example(\"mul_1.onnx\")\n\nimport onnx\nmodel = onnx.load(example1) # model is a ModelProto protobuf message\n\nprint(model)"
+ "from onnxruntime.datasets import get_example\n\nexample1 = get_example(\"mul_1.onnx\")\n\nimport onnx\n\nmodel = onnx.load(example1) # model is a ModelProto protobuf message\n\nprint(model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Draw a model with ONNX\nWe use `net_drawer.py `_\nincluded in *onnx* package.\nWe use *onnx* to load the model\nin a different way than before.\n\n"
+ "## Draw a model with ONNX\nWe use [net_drawer.py](https://github.com/onnx/onnx/blob/master/onnx/tools/net_drawer.py)\nincluded in *onnx* package.\nWe use *onnx* to load the model\nin a different way than before.\n\n"
]
},
{
@@ -44,7 +44,7 @@
},
"outputs": [],
"source": [
- "from onnx import ModelProto\nmodel = ModelProto()\nwith open(example1, 'rb') as fid:\n content = fid.read()\n model.ParseFromString(content)"
+ "from onnx import ModelProto\n\nmodel = ModelProto()\nwith open(example1, \"rb\") as fid:\n content = fid.read()\n model.ParseFromString(content)"
]
},
{
@@ -62,7 +62,7 @@
},
"outputs": [],
"source": [
- "from onnx.tools.net_drawer import GetPydotGraph, GetOpNodeProducer\npydot_graph = GetPydotGraph(model.graph, name=model.graph.name, rankdir=\"LR\",\n node_producer=GetOpNodeProducer(\"docstring\"))\npydot_graph.write_dot(\"graph.dot\")"
+ "from onnx.tools.net_drawer import GetOpNodeProducer, GetPydotGraph\n\npydot_graph = GetPydotGraph(\n model.graph, name=model.graph.name, rankdir=\"LR\", node_producer=GetOpNodeProducer(\"docstring\")\n)\npydot_graph.write_dot(\"graph.dot\")"
]
},
{
@@ -80,7 +80,7 @@
},
"outputs": [],
"source": [
- "import os\nos.system('dot -O -Tpng graph.dot')"
+ "import os\n\nos.system(\"dot -O -Tpng graph.dot\")"
]
},
{
@@ -98,7 +98,7 @@
},
"outputs": [],
"source": [
- "import matplotlib.pyplot as plt\nimage = plt.imread(\"graph.dot.png\")\nplt.imshow(image)"
+ "import matplotlib.pyplot as plt\n\nimage = plt.imread(\"graph.dot.png\")\nplt.imshow(image)"
]
}
],
diff --git a/docs/api/python/downloads/3a2955e44bf8f95a0eee6e71695ad788/plot_common_errors.py b/docs/api/python/downloads/3a2955e44bf8f95a0eee6e71695ad788/plot_common_errors.py
index b474574c0fdf6..e4b2b1e05a3ec 100644
--- a/docs/api/python/downloads/3a2955e44bf8f95a0eee6e71695ad788/plot_common_errors.py
+++ b/docs/api/python/downloads/3a2955e44bf8f95a0eee6e71695ad788/plot_common_errors.py
@@ -15,9 +15,10 @@
trained on *Iris* datasets. The model takes
a vector of dimension 2 and returns a class among three.
"""
+import numpy
+
import onnxruntime as rt
from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument
-import numpy
from onnxruntime.datasets import get_example
example2 = get_example("logreg_iris.onnx")
@@ -37,7 +38,7 @@
except Exception as e:
print("Unexpected type")
print("{0}: {1}".format(type(e), e))
-
+
#########################
# The model fails to return an output if the name
# is misspelled.
@@ -76,12 +77,12 @@
# dimension is a multiple of the expected input dimension.
for x in [
- numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
- numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
- numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
- ]:
+ numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
+]:
try:
r = sess.run([output_name], {input_name: x})
print("Shape={0} and predicted labels={1}".format(x.shape, r))
@@ -89,12 +90,12 @@
print("ERROR with Shape={0} - {1}".format(x.shape, e))
for x in [
- numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
- numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
- numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
- ]:
+ numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
+]:
try:
r = sess.run(None, {input_name: x})
print("Shape={0} and predicted probabilities={1}".format(x.shape, r[1]))
@@ -106,10 +107,10 @@
# is higher than expects but produces a warning.
for x in [
- numpy.array([[[1.0, 2.0], [3.0, 4.0]]], dtype=numpy.float32),
- numpy.array([[[1.0, 2.0, 3.0]]], dtype=numpy.float32),
- numpy.array([[[1.0, 2.0]], [[3.0, 4.0]]], dtype=numpy.float32),
- ]:
+ numpy.array([[[1.0, 2.0], [3.0, 4.0]]], dtype=numpy.float32),
+ numpy.array([[[1.0, 2.0, 3.0]]], dtype=numpy.float32),
+ numpy.array([[[1.0, 2.0]], [[3.0, 4.0]]], dtype=numpy.float32),
+]:
try:
r = sess.run([output_name], {input_name: x})
print("Shape={0} and predicted labels={1}".format(x.shape, r))
diff --git a/docs/api/python/downloads/3aca744422de94d33f9aaa3ce99633a9/plot_convert_pipeline_vectorizer.ipynb b/docs/api/python/downloads/3aca744422de94d33f9aaa3ce99633a9/plot_convert_pipeline_vectorizer.ipynb
index b0882340e1346..1859231ebd515 100644
--- a/docs/api/python/downloads/3aca744422de94d33f9aaa3ce99633a9/plot_convert_pipeline_vectorizer.ipynb
+++ b/docs/api/python/downloads/3aca744422de94d33f9aaa3ce99633a9/plot_convert_pipeline_vectorizer.ipynb
@@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "\n# Train, convert and predict with ONNX Runtime\n\nThis example demonstrates an end to end scenario\nstarting with the training of a scikit-learn pipeline\nwhich takes as inputs not a regular vector but a\ndictionary ``{ int: float }`` as its first step is a\n`DictVectorizer `_.\n\n## Train a pipeline\n\nThe first step consists in retrieving the boston datset.\n"
+ "\n# Train, convert and predict with ONNX Runtime\n\nThis example demonstrates an end to end scenario\nstarting with the training of a scikit-learn pipeline\nwhich takes as inputs not a regular vector but a\ndictionary ``{ int: float }`` as its first step is a\n[DictVectorizer](http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.DictVectorizer.html).\n\n## Train a pipeline\n\nThe first step consists in retrieving the boston datset.\n"
]
},
{
@@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
- "import pandas\nfrom sklearn.datasets import load_boston\nboston = load_boston()\nX, y = boston.data, boston.target\n\nfrom sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y)\nX_train_dict = pandas.DataFrame(X_train[:,1:]).T.to_dict().values()\nX_test_dict = pandas.DataFrame(X_test[:,1:]).T.to_dict().values()"
+ "import pandas\nfrom sklearn.datasets import load_boston\n\nboston = load_boston()\nX, y = boston.data, boston.target\n\nfrom sklearn.model_selection import train_test_split\n\nX_train, X_test, y_train, y_test = train_test_split(X, y)\nX_train_dict = pandas.DataFrame(X_train[:, 1:]).T.to_dict().values()\nX_test_dict = pandas.DataFrame(X_test[:, 1:]).T.to_dict().values()"
]
},
{
@@ -44,7 +44,7 @@
},
"outputs": [],
"source": [
- "from sklearn.pipeline import make_pipeline\nfrom sklearn.ensemble import GradientBoostingRegressor\nfrom sklearn.feature_extraction import DictVectorizer\npipe = make_pipeline(\n DictVectorizer(sparse=False),\n GradientBoostingRegressor())\n \npipe.fit(X_train_dict, y_train)"
+ "from sklearn.ensemble import GradientBoostingRegressor\nfrom sklearn.feature_extraction import DictVectorizer\nfrom sklearn.pipeline import make_pipeline\n\npipe = make_pipeline(DictVectorizer(sparse=False), GradientBoostingRegressor())\n\npipe.fit(X_train_dict, y_train)"
]
},
{
@@ -69,7 +69,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Conversion to ONNX format\n\nWe use module \n`sklearn-onnx `_\nto convert the model into ONNX format.\n\n"
+ "## Conversion to ONNX format\n\nWe use module\n[sklearn-onnx](https://github.com/onnx/sklearn-onnx)\nto convert the model into ONNX format.\n\n"
]
},
{
@@ -80,7 +80,7 @@
},
"outputs": [],
"source": [
- "from skl2onnx import convert_sklearn\nfrom skl2onnx.common.data_types import FloatTensorType, Int64TensorType, DictionaryType, SequenceType\n\n# initial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))]\ninitial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))]\nonx = convert_sklearn(pipe, initial_types=initial_type)\nwith open(\"pipeline_vectorize.onnx\", \"wb\") as f:\n f.write(onx.SerializeToString())"
+ "from skl2onnx import convert_sklearn\nfrom skl2onnx.common.data_types import DictionaryType, FloatTensorType, Int64TensorType, SequenceType\n\n# initial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))]\ninitial_type = [(\"float_input\", DictionaryType(Int64TensorType([1]), FloatTensorType([])))]\nonx = convert_sklearn(pipe, initial_types=initial_type)\nwith open(\"pipeline_vectorize.onnx\", \"wb\") as f:\n f.write(onx.SerializeToString())"
]
},
{
@@ -98,7 +98,7 @@
},
"outputs": [],
"source": [
- "import onnxruntime as rt\nfrom onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument\n\nsess = rt.InferenceSession(\"pipeline_vectorize.onnx\", providers=rt.get_available_providers())\n\nimport numpy\ninp, out = sess.get_inputs()[0], sess.get_outputs()[0]\nprint(\"input name='{}' and shape={} and type={}\".format(inp.name, inp.shape, inp.type))\nprint(\"output name='{}' and shape={} and type={}\".format(out.name, out.shape, out.type))"
+ "import onnxruntime as rt\nfrom onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument\n\nsess = rt.InferenceSession(\"pipeline_vectorize.onnx\", providers=rt.get_available_providers())\n\nimport numpy\n\ninp, out = sess.get_inputs()[0], sess.get_outputs()[0]\nprint(\"input name='{}' and shape={} and type={}\".format(inp.name, inp.shape, inp.type))\nprint(\"output name='{}' and shape={} and type={}\".format(out.name, out.shape, out.type))"
]
},
{
diff --git a/docs/api/python/downloads/3e23fa9ebb26f4728ee8426ed7da0f63/plot_backend.py b/docs/api/python/downloads/3e23fa9ebb26f4728ee8426ed7da0f63/plot_backend.py
index 68096bb8a682e..b441012e637ae 100644
--- a/docs/api/python/downloads/3e23fa9ebb26f4728ee8426ed7da0f63/plot_backend.py
+++ b/docs/api/python/downloads/3e23fa9ebb26f4728ee8426ed7da0f63/plot_backend.py
@@ -15,15 +15,16 @@
of a simple logistic regression model.
"""
import numpy as np
-from onnxruntime import datasets
-from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument
-import onnxruntime.backend as backend
from onnx import load
+import onnxruntime.backend as backend
+
########################################
# The device depends on how the package was compiled,
# GPU or CPU.
-from onnxruntime import get_device
+from onnxruntime import datasets, get_device
+from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument
+
device = get_device()
name = datasets.get_example("logreg_iris.onnx")
diff --git a/docs/api/python/downloads/6f1e7a639e0699d6164445b55e6c116d/auto_examples_jupyter.zip b/docs/api/python/downloads/6f1e7a639e0699d6164445b55e6c116d/auto_examples_jupyter.zip
index 70c6d584da4ce..eba50a6499971 100644
Binary files a/docs/api/python/downloads/6f1e7a639e0699d6164445b55e6c116d/auto_examples_jupyter.zip and b/docs/api/python/downloads/6f1e7a639e0699d6164445b55e6c116d/auto_examples_jupyter.zip differ
diff --git a/docs/api/python/downloads/7c8424f45d0156abd4d0221c65601124/plot_load_and_predict.py b/docs/api/python/downloads/7c8424f45d0156abd4d0221c65601124/plot_load_and_predict.py
index 9bfdc5795758d..44e343163a420 100644
--- a/docs/api/python/downloads/7c8424f45d0156abd4d0221c65601124/plot_load_and_predict.py
+++ b/docs/api/python/downloads/7c8424f45d0156abd4d0221c65601124/plot_load_and_predict.py
@@ -12,8 +12,9 @@
retrieve the definition of its inputs and outputs.
"""
-import onnxruntime as rt
import numpy
+
+import onnxruntime as rt
from onnxruntime.datasets import get_example
#########################
@@ -37,7 +38,7 @@
# Let's see the output name and shape.
output_name = sess.get_outputs()[0].name
-print("output name", output_name)
+print("output name", output_name)
output_shape = sess.get_outputs()[0].shape
print("output shape", output_shape)
output_type = sess.get_outputs()[0].type
@@ -47,7 +48,8 @@
# Let's compute its outputs (or predictions if it is a machine learned model).
import numpy.random
-x = numpy.random.random((3,4,5))
+
+x = numpy.random.random((3, 4, 5))
x = x.astype(numpy.float32)
res = sess.run([output_name], {input_name: x})
print(res)
diff --git a/docs/api/python/downloads/932fe1ee7f48f55a6155d2f378bc85a0/plot_metadata.py b/docs/api/python/downloads/932fe1ee7f48f55a6155d2f378bc85a0/plot_metadata.py
index 94c45e688f27f..c76f2e8d9fa7f 100644
--- a/docs/api/python/downloads/932fe1ee7f48f55a6155d2f378bc85a0/plot_metadata.py
+++ b/docs/api/python/downloads/932fe1ee7f48f55a6155d2f378bc85a0/plot_metadata.py
@@ -15,9 +15,11 @@
"""
from onnxruntime.datasets import get_example
+
example = get_example("logreg_iris.onnx")
import onnx
+
model = onnx.load(example)
print("doc_string={}".format(model.doc_string))
@@ -32,6 +34,7 @@
# With *ONNX Runtime*:
import onnxruntime as rt
+
sess = rt.InferenceSession(example, providers=rt.get_available_providers())
meta = sess.get_modelmeta()
diff --git a/docs/api/python/downloads/940d20a5bdb46eb51fb878fbb3bd928d/plot_metadata.ipynb b/docs/api/python/downloads/940d20a5bdb46eb51fb878fbb3bd928d/plot_metadata.ipynb
index f282c7bc03003..3ea14d7fe686e 100644
--- a/docs/api/python/downloads/940d20a5bdb46eb51fb878fbb3bd928d/plot_metadata.ipynb
+++ b/docs/api/python/downloads/940d20a5bdb46eb51fb878fbb3bd928d/plot_metadata.ipynb
@@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
- "from onnxruntime.datasets import get_example\nexample = get_example(\"logreg_iris.onnx\")\n\nimport onnx\nmodel = onnx.load(example)\n\nprint(\"doc_string={}\".format(model.doc_string))\nprint(\"domain={}\".format(model.domain))\nprint(\"ir_version={}\".format(model.ir_version))\nprint(\"metadata_props={}\".format(model.metadata_props))\nprint(\"model_version={}\".format(model.model_version))\nprint(\"producer_name={}\".format(model.producer_name))\nprint(\"producer_version={}\".format(model.producer_version))"
+ "from onnxruntime.datasets import get_example\n\nexample = get_example(\"logreg_iris.onnx\")\n\nimport onnx\n\nmodel = onnx.load(example)\n\nprint(\"doc_string={}\".format(model.doc_string))\nprint(\"domain={}\".format(model.domain))\nprint(\"ir_version={}\".format(model.ir_version))\nprint(\"metadata_props={}\".format(model.metadata_props))\nprint(\"model_version={}\".format(model.model_version))\nprint(\"producer_name={}\".format(model.producer_name))\nprint(\"producer_version={}\".format(model.producer_version))"
]
},
{
@@ -44,7 +44,7 @@
},
"outputs": [],
"source": [
- "import onnxruntime as rt\nsess = rt.InferenceSession(example, providers=rt.get_available_providers())\nmeta = sess.get_modelmeta()\n\nprint(\"custom_metadata_map={}\".format(meta.custom_metadata_map))\nprint(\"description={}\".format(meta.description))\nprint(\"domain={}\".format(meta.domain, meta.domain))\nprint(\"graph_name={}\".format(meta.graph_name))\nprint(\"producer_name={}\".format(meta.producer_name))\nprint(\"version={}\".format(meta.version))"
+ "import onnxruntime as rt\n\nsess = rt.InferenceSession(example, providers=rt.get_available_providers())\nmeta = sess.get_modelmeta()\n\nprint(\"custom_metadata_map={}\".format(meta.custom_metadata_map))\nprint(\"description={}\".format(meta.description))\nprint(\"domain={}\".format(meta.domain, meta.domain))\nprint(\"graph_name={}\".format(meta.graph_name))\nprint(\"producer_name={}\".format(meta.producer_name))\nprint(\"version={}\".format(meta.version))"
]
}
],
diff --git a/docs/api/python/downloads/982a1f7abbb8ffc5d5e98b671c35e5aa/plot_convert_pipeline_vectorizer.py b/docs/api/python/downloads/982a1f7abbb8ffc5d5e98b671c35e5aa/plot_convert_pipeline_vectorizer.py
index af1351d0c87ff..3df6d6dfea9bf 100644
--- a/docs/api/python/downloads/982a1f7abbb8ffc5d5e98b671c35e5aa/plot_convert_pipeline_vectorizer.py
+++ b/docs/api/python/downloads/982a1f7abbb8ffc5d5e98b671c35e5aa/plot_convert_pipeline_vectorizer.py
@@ -21,24 +21,25 @@
"""
import pandas
from sklearn.datasets import load_boston
+
boston = load_boston()
X, y = boston.data, boston.target
from sklearn.model_selection import train_test_split
+
X_train, X_test, y_train, y_test = train_test_split(X, y)
-X_train_dict = pandas.DataFrame(X_train[:,1:]).T.to_dict().values()
-X_test_dict = pandas.DataFrame(X_test[:,1:]).T.to_dict().values()
+X_train_dict = pandas.DataFrame(X_train[:, 1:]).T.to_dict().values()
+X_test_dict = pandas.DataFrame(X_test[:, 1:]).T.to_dict().values()
####################################
# We create a pipeline.
-from sklearn.pipeline import make_pipeline
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.feature_extraction import DictVectorizer
-pipe = make_pipeline(
- DictVectorizer(sparse=False),
- GradientBoostingRegressor())
-
+from sklearn.pipeline import make_pipeline
+
+pipe = make_pipeline(DictVectorizer(sparse=False), GradientBoostingRegressor())
+
pipe.fit(X_train_dict, y_train)
####################################
@@ -53,15 +54,15 @@
# Conversion to ONNX format
# +++++++++++++++++++++++++
#
-# We use module
+# We use module
# `sklearn-onnx `_
# to convert the model into ONNX format.
from skl2onnx import convert_sklearn
-from skl2onnx.common.data_types import FloatTensorType, Int64TensorType, DictionaryType, SequenceType
+from skl2onnx.common.data_types import DictionaryType, FloatTensorType, Int64TensorType, SequenceType
# initial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))]
-initial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))]
+initial_type = [("float_input", DictionaryType(Int64TensorType([1]), FloatTensorType([])))]
onx = convert_sklearn(pipe, initial_types=initial_type)
with open("pipeline_vectorize.onnx", "wb") as f:
f.write(onx.SerializeToString())
@@ -75,6 +76,7 @@
sess = rt.InferenceSession("pipeline_vectorize.onnx", providers=rt.get_available_providers())
import numpy
+
inp, out = sess.get_inputs()[0], sess.get_outputs()[0]
print("input name='{}' and shape={} and type={}".format(inp.name, inp.shape, inp.type))
print("output name='{}' and shape={} and type={}".format(out.name, out.shape, out.type))
@@ -100,4 +102,3 @@
#########################
# Very similar. *ONNX Runtime* uses floats instead of doubles,
# that explains the small discrepencies.
-
diff --git a/docs/api/python/downloads/c647c128e0cf2b3db04ce60b41ef1a14/plot_train_convert_predict.py b/docs/api/python/downloads/c647c128e0cf2b3db04ce60b41ef1a14/plot_train_convert_predict.py
index 4aa36b3dce25c..b5033b503b3eb 100644
--- a/docs/api/python/downloads/c647c128e0cf2b3db04ce60b41ef1a14/plot_train_convert_predict.py
+++ b/docs/api/python/downloads/c647c128e0cf2b3db04ce60b41ef1a14/plot_train_convert_predict.py
@@ -22,16 +22,19 @@
"""
from sklearn.datasets import load_iris
+
iris = load_iris()
X, y = iris.data, iris.target
from sklearn.model_selection import train_test_split
+
X_train, X_test, y_train, y_test = train_test_split(X, y)
####################################
# Then we fit a model.
from sklearn.linear_model import LogisticRegression
+
clr = LogisticRegression()
clr.fit(X_train, y_train)
@@ -47,14 +50,14 @@
# Conversion to ONNX format
# +++++++++++++++++++++++++
#
-# We use module
+# We use module
# `sklearn-onnx `_
# to convert the model into ONNX format.
from skl2onnx import convert_sklearn
from skl2onnx.common.data_types import FloatTensorType
-initial_type = [('float_input', FloatTensorType([None, 4]))]
+initial_type = [("float_input", FloatTensorType([None, 4]))]
onx = convert_sklearn(clr, initial_types=initial_type)
with open("logreg_iris.onnx", "wb") as f:
f.write(onx.SerializeToString())
@@ -64,12 +67,11 @@
# its input and output.
import onnxruntime as rt
+
sess = rt.InferenceSession("logreg_iris.onnx", providers=rt.get_available_providers())
-print("input name='{}' and shape={}".format(
- sess.get_inputs()[0].name, sess.get_inputs()[0].shape))
-print("output name='{}' and shape={}".format(
- sess.get_outputs()[0].name, sess.get_outputs()[0].shape))
+print("input name='{}' and shape={}".format(sess.get_inputs()[0].name, sess.get_inputs()[0].shape))
+print("output name='{}' and shape={}".format(sess.get_outputs()[0].name, sess.get_outputs()[0].shape))
##################################
# We compute the predictions.
@@ -78,6 +80,7 @@
label_name = sess.get_outputs()[0].name
import numpy
+
pred_onx = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]
print(confusion_matrix(pred, pred_onx))
@@ -97,18 +100,20 @@
#############################
# And then with ONNX Runtime.
-# The probabilies appear to be
+# The probabilies appear to be
prob_name = sess.get_outputs()[1].name
prob_rt = sess.run([prob_name], {input_name: X_test.astype(numpy.float32)})[0]
import pprint
+
pprint.pprint(prob_rt[0:3])
###############################
# Let's benchmark.
from timeit import Timer
+
def speed(inst, number=10, repeat=20):
timer = Timer(inst, globals=globals())
raw = numpy.array(timer.repeat(repeat, number=number))
@@ -117,6 +122,7 @@ def speed(inst, number=10, repeat=20):
print("Average %1.3g min=%1.3g max=%1.3g" % (ave, mi, ma))
return ave
+
print("Execution time for clr.predict")
speed("clr.predict(X_test)")
@@ -128,20 +134,24 @@ def speed(inst, number=10, repeat=20):
# experiences: the model has to do one prediction at a time
# as opposed to a batch of prediction.
+
def loop(X_test, fct, n=None):
nrow = X_test.shape[0]
if n is None:
n = nrow
for i in range(0, n):
im = i % nrow
- fct(X_test[im: im+1])
+ fct(X_test[im : im + 1])
+
print("Execution time for clr.predict")
speed("loop(X_test, clr.predict, 100)")
+
def sess_predict(x):
return sess.run([label_name], {input_name: x.astype(numpy.float32)})[0]
+
print("Execution time for sess_predict")
speed("loop(X_test, sess_predict, 100)")
@@ -151,14 +161,16 @@ def sess_predict(x):
print("Execution time for predict_proba")
speed("loop(X_test, clr.predict_proba, 100)")
+
def sess_predict_proba(x):
return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]
+
print("Execution time for sess_predict_proba")
speed("loop(X_test, sess_predict_proba, 100)")
#####################################
-# This second comparison is better as
+# This second comparison is better as
# ONNX Runtime, in this experience,
# computes the label and the probabilities
# in every case.
@@ -169,10 +181,11 @@ def sess_predict_proba(x):
#
# We first train and save a model in ONNX format.
from sklearn.ensemble import RandomForestClassifier
+
rf = RandomForestClassifier()
rf.fit(X_train, y_train)
-initial_type = [('float_input', FloatTensorType([1, 4]))]
+initial_type = [("float_input", FloatTensorType([1, 4]))]
onx = convert_sklearn(rf, initial_types=initial_type)
with open("rf_iris.onnx", "wb") as f:
f.write(onx.SerializeToString())
@@ -182,9 +195,11 @@ def sess_predict_proba(x):
sess = rt.InferenceSession("rf_iris.onnx", providers=rt.get_available_providers())
+
def sess_predict_proba_rf(x):
return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]
+
print("Execution time for predict_proba")
speed("loop(X_test, rf.predict_proba, 100)")
@@ -196,26 +211,28 @@ def sess_predict_proba_rf(x):
measures = []
-for n_trees in range(5, 51, 5):
+for n_trees in range(5, 51, 5):
print(n_trees)
rf = RandomForestClassifier(n_estimators=n_trees)
rf.fit(X_train, y_train)
- initial_type = [('float_input', FloatTensorType([1, 4]))]
+ initial_type = [("float_input", FloatTensorType([1, 4]))]
onx = convert_sklearn(rf, initial_types=initial_type)
with open("rf_iris_%d.onnx" % n_trees, "wb") as f:
f.write(onx.SerializeToString())
sess = rt.InferenceSession("rf_iris_%d.onnx" % n_trees, providers=rt.get_available_providers())
+
def sess_predict_proba_loop(x):
return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]
+
tsk = speed("loop(X_test, rf.predict_proba, 100)", number=5, repeat=5)
trt = speed("loop(X_test, sess_predict_proba_loop, 100)", number=5, repeat=5)
- measures.append({'n_trees': n_trees, 'sklearn': tsk, 'rt': trt})
+ measures.append({"n_trees": n_trees, "sklearn": tsk, "rt": trt})
from pandas import DataFrame
+
df = DataFrame(measures)
ax = df.plot(x="n_trees", y="sklearn", label="scikit-learn", c="blue", logy=True)
-df.plot(x="n_trees", y="rt", label="onnxruntime",
- ax=ax, c="green", logy=True)
+df.plot(x="n_trees", y="rt", label="onnxruntime", ax=ax, c="green", logy=True)
ax.set_xlabel("Number of trees")
ax.set_ylabel("Prediction time (s)")
ax.set_title("Speed comparison between scikit-learn and ONNX Runtime\nFor a random forest on Iris dataset")
diff --git a/docs/api/python/downloads/ccbbfd4f60683438ab99a4c42d3fbbdf/plot_profiling.ipynb b/docs/api/python/downloads/ccbbfd4f60683438ab99a4c42d3fbbdf/plot_profiling.ipynb
index 8c91e80384b42..18bf323925921 100644
--- a/docs/api/python/downloads/ccbbfd4f60683438ab99a4c42d3fbbdf/plot_profiling.ipynb
+++ b/docs/api/python/downloads/ccbbfd4f60683438ab99a4c42d3fbbdf/plot_profiling.ipynb
@@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
- "import onnx\nimport onnxruntime as rt\nimport numpy\nfrom onnxruntime.datasets import get_example\n\n\ndef change_ir_version(filename, ir_version=6):\n \"onnxruntime==1.2.0 does not support opset <= 7 and ir_version > 6\"\n with open(filename, \"rb\") as f:\n model = onnx.load(f)\n model.ir_version = 6\n if model.opset_import[0].version <= 7:\n model.opset_import[0].version = 11\n return model"
+ "import numpy\nimport onnx\n\nimport onnxruntime as rt\nfrom onnxruntime.datasets import get_example\n\n\ndef change_ir_version(filename, ir_version=6):\n \"onnxruntime==1.2.0 does not support opset <= 7 and ir_version > 6\"\n with open(filename, \"rb\") as f:\n model = onnx.load(f)\n model.ir_version = 6\n if model.opset_import[0].version <= 7:\n model.opset_import[0].version = 11\n return model"
]
},
{
@@ -80,7 +80,7 @@
},
"outputs": [],
"source": [
- "import json\nwith open(prof_file, \"r\") as f:\n sess_time = json.load(f)\nimport pprint\npprint.pprint(sess_time)"
+ "import json\n\nwith open(prof_file, \"r\") as f:\n sess_time = json.load(f)\nimport pprint\n\npprint.pprint(sess_time)"
]
}
],
diff --git a/docs/api/python/downloads/cfe61aca1f0a89486c7024466ea500fd/plot_profiling.py b/docs/api/python/downloads/cfe61aca1f0a89486c7024466ea500fd/plot_profiling.py
index 402e7b3baee10..3236f954cc052 100644
--- a/docs/api/python/downloads/cfe61aca1f0a89486c7024466ea500fd/plot_profiling.py
+++ b/docs/api/python/downloads/cfe61aca1f0a89486c7024466ea500fd/plot_profiling.py
@@ -11,9 +11,10 @@
*ONNX Runtime* can profile the execution of the model.
This example shows how to interpret the results.
"""
+import numpy
import onnx
+
import onnxruntime as rt
-import numpy
from onnxruntime.datasets import get_example
@@ -27,8 +28,6 @@ def change_ir_version(filename, ir_version=6):
return model
-
-
#########################
# Let's load a very simple model and compute some prediction.
@@ -61,10 +60,9 @@ def change_ir_version(filename, ir_version=6):
# The results are stored un a file in JSON format.
# Let's see what it contains.
import json
+
with open(prof_file, "r") as f:
sess_time = json.load(f)
import pprint
-pprint.pprint(sess_time)
-
-
+pprint.pprint(sess_time)
diff --git a/docs/api/python/downloads/d436e9922b51a71358604ec00f09e7e4/plot_pipeline.py b/docs/api/python/downloads/d436e9922b51a71358604ec00f09e7e4/plot_pipeline.py
index 0a002f6223e1b..366aadee1c3ae 100644
--- a/docs/api/python/downloads/d436e9922b51a71358604ec00f09e7e4/plot_pipeline.py
+++ b/docs/api/python/downloads/d436e9922b51a71358604ec00f09e7e4/plot_pipeline.py
@@ -21,12 +21,14 @@
"""
from onnxruntime.datasets import get_example
+
example1 = get_example("mul_1.onnx")
import onnx
+
model = onnx.load(example1) # model is a ModelProto protobuf message
-print(model)
+print(model)
#################################
@@ -39,31 +41,30 @@
from onnx import ModelProto
+
model = ModelProto()
-with open(example1, 'rb') as fid:
+with open(example1, "rb") as fid:
content = fid.read()
model.ParseFromString(content)
###################################
# We convert it into a graph.
-from onnx.tools.net_drawer import GetPydotGraph, GetOpNodeProducer
-pydot_graph = GetPydotGraph(model.graph, name=model.graph.name, rankdir="LR",
- node_producer=GetOpNodeProducer("docstring"))
+from onnx.tools.net_drawer import GetOpNodeProducer, GetPydotGraph
+
+pydot_graph = GetPydotGraph(
+ model.graph, name=model.graph.name, rankdir="LR", node_producer=GetOpNodeProducer("docstring")
+)
pydot_graph.write_dot("graph.dot")
#######################################
# Then into an image
import os
-os.system('dot -O -Tpng graph.dot')
+
+os.system("dot -O -Tpng graph.dot")
################################
# Which we display...
import matplotlib.pyplot as plt
+
image = plt.imread("graph.dot.png")
plt.imshow(image)
-
-
-
-
-
-
diff --git a/docs/api/python/downloads/f8e5d8e309ca291f68bd029c26838ccc/plot_backend.ipynb b/docs/api/python/downloads/f8e5d8e309ca291f68bd029c26838ccc/plot_backend.ipynb
index 3dab79a3dbce2..8aa28adefab18 100644
--- a/docs/api/python/downloads/f8e5d8e309ca291f68bd029c26838ccc/plot_backend.ipynb
+++ b/docs/api/python/downloads/f8e5d8e309ca291f68bd029c26838ccc/plot_backend.ipynb
@@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "\n\n# ONNX Runtime Backend for ONNX\n\n*ONNX Runtime* extends the \n`onnx backend API `_\nto run predictions using this runtime.\nLet's use the API to compute the prediction\nof a simple logistic regression model.\n"
+ "\n\n# ONNX Runtime Backend for ONNX\n\n*ONNX Runtime* extends the \n[onnx backend API](https://github.com/onnx/onnx/blob/master/docs/ImplementingAnOnnxBackend.md)\nto run predictions using this runtime.\nLet's use the API to compute the prediction\nof a simple logistic regression model.\n"
]
},
{
@@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
- "import numpy as np\nfrom onnxruntime import datasets\nfrom onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument\nimport onnxruntime.backend as backend\nfrom onnx import load"
+ "import numpy as np\nfrom onnx import load\n\nimport onnxruntime.backend as backend"
]
},
{
@@ -44,7 +44,7 @@
},
"outputs": [],
"source": [
- "from onnxruntime import get_device\ndevice = get_device()\n\nname = datasets.get_example(\"logreg_iris.onnx\")\nmodel = load(name)\n\nrep = backend.prepare(model, device)\nx = np.array([[-1.0, -2.0]], dtype=np.float32)\ntry:\n label, proba = rep.run(x)\n print(\"label={}\".format(label))\n print(\"probabilities={}\".format(proba))\nexcept (RuntimeError, InvalidArgument) as e:\n print(e)"
+ "from onnxruntime import datasets, get_device\nfrom onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument\n\ndevice = get_device()\n\nname = datasets.get_example(\"logreg_iris.onnx\")\nmodel = load(name)\n\nrep = backend.prepare(model, device)\nx = np.array([[-1.0, -2.0]], dtype=np.float32)\ntry:\n label, proba = rep.run(x)\n print(\"label={}\".format(label))\n print(\"probabilities={}\".format(proba))\nexcept (RuntimeError, InvalidArgument) as e:\n print(e)"
]
},
{
diff --git a/docs/api/python/examples_md.html b/docs/api/python/examples_md.html
index 54d0311599a44..c1766e0226aaa 100644
--- a/docs/api/python/examples_md.html
+++ b/docs/api/python/examples_md.html
@@ -6,7 +6,7 @@
- Gallery of examples — ONNX Runtime 1.11.0 documentation
+ Gallery of examples — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -59,7 +60,7 @@ ONNX Runtime
Navigation
@@ -79,7 +80,7 @@ Quick search
-
+
@@ -96,7 +97,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/genindex.html b/docs/api/python/genindex.html
index aa4eb6187c7e6..78da6edc42d36 100644
--- a/docs/api/python/genindex.html
+++ b/docs/api/python/genindex.html
@@ -5,7 +5,7 @@
- Index — ONNX Runtime 1.11.0 documentation
+ Index — ONNX Runtime 1.13.0 documentation
@@ -16,6 +16,7 @@
+
@@ -63,16 +64,20 @@ Index
A
+ - add_external_initializers() (onnxruntime.SessionOptions method)
+
- add_free_dimension_override_by_denotation() (onnxruntime.SessionOptions method)
- add_free_dimension_override_by_name() (onnxruntime.SessionOptions method)
- add_initializer() (onnxruntime.SessionOptions method)
- - add_session_config_entry() (onnxruntime.SessionOptions method)
+
- add_run_config_entry() (onnxruntime.RunOptions method)
+ - add_session_config_entry() (onnxruntime.SessionOptions method)
+
- as_blocksparse_view() (onnxruntime.SparseTensor method)
- as_coo_view() (onnxruntime.SparseTensor method)
@@ -147,16 +152,18 @@
D
E
+ - enable_mem_reuse (onnxruntime.SessionOptions property)
+
- enable_profiling (onnxruntime.SessionOptions property)
- end_profiling() (onnxruntime.InferenceSession method)
@@ -179,10 +186,6 @@
F
G
- - get_device() (in module onnxruntime)
-
- - get_example() (in module onnxruntime.datasets)
-
- get_inputs() (onnxruntime.InferenceSession method)
- get_modelmeta() (onnxruntime.InferenceSession method)
@@ -195,13 +198,15 @@
G
- get_overridable_initializers() (onnxruntime.InferenceSession method)
-
-
+
- get_providers() (onnxruntime.InferenceSession method)
+
+ - get_run_config_entry() (onnxruntime.RunOptions method)
- get_session_config_entry() (onnxruntime.SessionOptions method)
@@ -396,6 +401,10 @@ T
U
+
- use_deterministic_compute (onnxruntime.SessionOptions property)
@@ -437,7 +446,7 @@ ONNX Runtime
Navigation
@@ -457,7 +466,7 @@ Quick search
-
+
@@ -474,7 +483,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
diff --git a/docs/api/python/images/sphx_glr_plot_pipeline_001.png b/docs/api/python/images/sphx_glr_plot_pipeline_001.png
index 34c5fb668a966..6bd7ae5b27746 100644
Binary files a/docs/api/python/images/sphx_glr_plot_pipeline_001.png and b/docs/api/python/images/sphx_glr_plot_pipeline_001.png differ
diff --git a/docs/api/python/images/sphx_glr_plot_train_convert_predict_001.png b/docs/api/python/images/sphx_glr_plot_train_convert_predict_001.png
index a0015a5ad871f..5446b9c7411ab 100644
Binary files a/docs/api/python/images/sphx_glr_plot_train_convert_predict_001.png and b/docs/api/python/images/sphx_glr_plot_train_convert_predict_001.png differ
diff --git a/docs/api/python/images/sphx_glr_plot_train_convert_predict_thumb.png b/docs/api/python/images/sphx_glr_plot_train_convert_predict_thumb.png
index 6eeb0f2bb9225..64204dbac8eb4 100644
Binary files a/docs/api/python/images/sphx_glr_plot_train_convert_predict_thumb.png and b/docs/api/python/images/sphx_glr_plot_train_convert_predict_thumb.png differ
diff --git a/docs/api/python/index.html b/docs/api/python/index.html
index 8b11848df1bfb..8dbb8f6843c71 100644
--- a/docs/api/python/index.html
+++ b/docs/api/python/index.html
@@ -6,7 +6,7 @@
- Python Bindings for ONNX Runtime — ONNX Runtime 1.11.0 documentation
+ Python Bindings for ONNX Runtime — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -38,13 +39,13 @@
-Python Bindings for ONNX Runtime¶
+Python Bindings for ONNX Runtime¶
ONNX Runtime is a performance-focused scoring engine for Open Neural Network Exchange (ONNX) models.
For more information on ONNX Runtime, please see aka.ms/onnxruntime or the Github project.
@@ -72,7 +73,7 @@ ONNX Runtime
Navigation
@@ -93,7 +94,7 @@ Quick search
-
+
@@ -110,7 +111,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
|
diff --git a/docs/api/python/modules/index.html b/docs/api/python/modules/index.html
index 95672aba918e6..ddac275fbf785 100644
--- a/docs/api/python/modules/index.html
+++ b/docs/api/python/modules/index.html
@@ -5,7 +5,7 @@
- Overview: module code — ONNX Runtime 1.11.0 documentation
+ Overview: module code — ONNX Runtime 1.13.0 documentation
@@ -16,6 +16,7 @@
+
@@ -38,7 +39,6 @@
All modules for which code is available
- onnxruntime.capi.onnxruntime_inference_collection
- onnxruntime.capi.onnxruntime_pybind11_state
-- onnxruntime.datasets
@@ -62,7 +62,7 @@ ONNX Runtime
Navigation
@@ -82,7 +82,7 @@ Quick search
-
+
@@ -99,7 +99,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
diff --git a/docs/api/python/modules/onnxruntime/capi/onnxruntime_inference_collection.html b/docs/api/python/modules/onnxruntime/capi/onnxruntime_inference_collection.html
index 62ba39e85ba4b..2fed76086f235 100644
--- a/docs/api/python/modules/onnxruntime/capi/onnxruntime_inference_collection.html
+++ b/docs/api/python/modules/onnxruntime/capi/onnxruntime_inference_collection.html
@@ -5,7 +5,7 @@
- onnxruntime.capi.onnxruntime_inference_collection — ONNX Runtime 1.11.0 documentation
+ onnxruntime.capi.onnxruntime_inference_collection — ONNX Runtime 1.13.0 documentation
@@ -16,6 +16,7 @@
+
@@ -48,16 +49,15 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
from onnxruntime.capi import _pybind_state as C
-def get_ort_device_type(device):
- device_type = device if type(device) is str else device.type.lower()
- if device_type == 'cuda':
+def get_ort_device_type(device_type, device_index):
+ if device_type == "cuda":
return C.OrtDevice.cuda()
- elif device_type == 'cpu':
+ elif device_type == "cpu":
return C.OrtDevice.cpu()
- elif device_type == 'ort':
- return C.get_ort_device(device.index).device_type()
+ elif device_type == "ort":
+ return C.get_ort_device(device_index).device_type()
else:
- raise Exception('Unsupported device type: ' + device_type)
+ raise Exception("Unsupported device type: " + device_type)
def check_and_normalize_provider_args(providers, provider_options, available_provider_names):
@@ -90,8 +90,10 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
def set_provider_options(name, options):
if name not in available_provider_names:
- warnings.warn("Specified provider '{}' is not in available provider names."
- "Available providers: '{}'".format(name, ", ".join(available_provider_names)))
+ warnings.warn(
+ "Specified provider '{}' is not in available provider names."
+ "Available providers: '{}'".format(name, ", ".join(available_provider_names))
+ )
if name in provider_name_to_options:
warnings.warn("Duplicate provider '{}' encountered, ignoring.".format(name))
@@ -123,8 +125,12 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
for provider in providers:
if isinstance(provider, str):
set_provider_options(provider, dict())
- elif isinstance(provider, tuple) and len(provider) == 2 and \
- isinstance(provider[0], str) and isinstance(provider[1], dict):
+ elif (
+ isinstance(provider, tuple)
+ and len(provider) == 2
+ and isinstance(provider[0], str)
+ and isinstance(provider[1], dict)
+ ):
set_provider_options(provider[0], provider[1])
else:
raise ValueError("'providers' values must be either strings or (string, dict) tuples.")
@@ -136,6 +142,7 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
"""
This is the main class used to run a model.
"""
+
def __init__(self):
# self._sess is managed by the derived class and relies on bindings from C.InferenceSession
@@ -214,6 +221,8 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
:param output_names: name of the outputs
:param input_feed: dictionary ``{ input_name: input_value }``
:param run_options: See :class:`onnxruntime.RunOptions`.
+ :return: list of results, every result is either a numpy array,
+ a sparse tensor, a list or a dictionary.
::
@@ -244,7 +253,7 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
Compute the predictions.
:param output_names: name of the outputs
- :param input_feed: dictionary ``{ input_name: input_ort_value }``
+ :param input_dict_ort_values: dictionary ``{ input_name: input_ort_value }``
See ``OrtValue`` class how to create `OrtValue`
from numpy array or `SparseTensor`
:param run_options: See :class:`onnxruntime.RunOptions`.
@@ -254,11 +263,14 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
sess.run([output_name], {input_name: x})
"""
+
def invoke(sess, output_names, input_dict_ort_values, run_options):
input_dict = {}
for n, v in input_dict_ort_values.items():
input_dict[n] = v._get_c_value()
result = sess.run_with_ort_values(input_dict, output_names, run_options)
+ if not isinstance(result, C.OrtValueVector):
+ raise TypeError("run_with_ort_values() must return a instance of type 'OrtValueVector'.")
ort_values = [OrtValue(v) for v in result]
return ort_values
@@ -306,10 +318,10 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
def run_with_iobinding(self, iobinding, run_options=None):
"""
- Compute the predictions.
+ Compute the predictions.
- :param iobinding: the iobinding object that has graph inputs/outputs bind.
- :param run_options: See :class:`onnxruntime.RunOptions`.
+ :param iobinding: the iobinding object that has graph inputs/outputs bind.
+ :param run_options: See :class:`onnxruntime.RunOptions`.
"""
self._sess.run_with_iobinding(iobinding._iobinding, run_options)
@@ -318,6 +330,7 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
"""
This is the main class used to run a model.
"""
+
def __init__(self, path_or_bytes, sess_options=None, providers=None, provider_options=None, **kwargs):
"""
:param path_or_bytes: filename or serialized ONNX or ORT format model in a byte string
@@ -364,10 +377,10 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
self._sess_options = sess_options
self._sess_options_initial = sess_options
self._enable_fallback = True
- self._read_config_from_model = os.environ.get('ORT_LOAD_CONFIG_FROM_MODEL') == '1'
+ self._read_config_from_model = os.environ.get("ORT_LOAD_CONFIG_FROM_MODEL") == "1"
# internal parameters that we don't expect to be used in general so aren't documented
- disabled_optimizers = kwargs['disabled_optimizers'] if 'disabled_optimizers' in kwargs else None
+ disabled_optimizers = kwargs["disabled_optimizers"] if "disabled_optimizers" in kwargs else None
try:
self._create_inference_session(providers, provider_options, disabled_optimizers)
@@ -385,21 +398,25 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
available_providers = C.get_available_providers()
# Tensorrt can fall back to CUDA. All others fall back to CPU.
- if 'TensorrtExecutionProvider' in available_providers:
- self._fallback_providers = ['CUDAExecutionProvider', 'CPUExecutionProvider']
+ if "TensorrtExecutionProvider" in available_providers:
+ self._fallback_providers = ["CUDAExecutionProvider", "CPUExecutionProvider"]
+ elif "MIGraphXExecutionProvider" in available_providers:
+ self._fallback_providers = ["ROCMExecutionProvider", "CPUExecutionProvider"]
else:
- self._fallback_providers = ['CPUExecutionProvider']
+ self._fallback_providers = ["CPUExecutionProvider"]
# validate providers and provider_options before other initialization
- providers, provider_options = check_and_normalize_provider_args(providers,
- provider_options,
- available_providers)
+ providers, provider_options = check_and_normalize_provider_args(
+ providers, provider_options, available_providers
+ )
if providers == [] and len(available_providers) > 1:
self.disable_fallback()
- raise ValueError("This ORT build has {} enabled. ".format(available_providers) +
- "Since ORT 1.9, you are required to explicitly set " +
- "the providers parameter when instantiating InferenceSession. For example, "
- "onnxruntime.InferenceSession(..., providers={}, ...)".format(available_providers))
+ raise ValueError(
+ "This ORT build has {} enabled. ".format(available_providers)
+ + "Since ORT 1.9, you are required to explicitly set "
+ + "the providers parameter when instantiating InferenceSession. For example, "
+ "onnxruntime.InferenceSession(..., providers={}, ...)".format(available_providers)
+ )
session_options = self._sess_options if self._sess_options else C.get_default_session_options()
if self._model_path:
@@ -446,19 +463,20 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
[docs]class IOBinding:
- '''
+ """
This class provides API to bind input/output to a specified device, e.g. GPU.
- '''
+ """
+
def __init__(self, session):
self._iobinding = C.SessionIOBinding(session._sess)
self._numpy_obj_references = {}
[docs] def bind_cpu_input(self, name, arr_on_cpu):
- '''
+ """
bind an input to array on CPU
:param name: input name
:param arr_on_cpu: input values as a python array on CPU
- '''
+ """
# Hold a reference to the numpy object as the bound OrtValue is backed
# directly by the data buffer of the numpy object and so the numpy object
# must be around until this IOBinding instance is around
@@ -466,38 +484,53 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
self._iobinding.bind_input(name, arr_on_cpu)
[docs] def bind_input(self, name, device_type, device_id, element_type, shape, buffer_ptr):
- '''
+ """
:param name: input name
:param device_type: e.g. cpu, cuda
:param device_id: device id, e.g. 0
:param element_type: input element type
:param shape: input shape
:param buffer_ptr: memory pointer to input data
- '''
- self._iobinding.bind_input(name,
- C.OrtDevice(get_ort_device_type(device_type), C.OrtDevice.default_memory(),
- device_id),
- element_type, shape, buffer_ptr)
+ """
+ self._iobinding.bind_input(
+ name,
+ C.OrtDevice(
+ get_ort_device_type(device_type, device_id),
+ C.OrtDevice.default_memory(),
+ device_id,
+ ),
+ element_type,
+ shape,
+ buffer_ptr,
+ )
[docs] def bind_ortvalue_input(self, name, ortvalue):
- '''
+ """
:param name: input name
:param ortvalue: OrtValue instance to bind
- '''
+ """
self._iobinding.bind_ortvalue_input(name, ortvalue._ortvalue)
def synchronize_inputs(self):
self._iobinding.synchronize_inputs()
-[docs] def bind_output(self, name, device_type='cpu', device_id=0, element_type=None, shape=None, buffer_ptr=None):
- '''
+[docs] def bind_output(
+ self,
+ name,
+ device_type="cpu",
+ device_id=0,
+ element_type=None,
+ shape=None,
+ buffer_ptr=None,
+ ):
+ """
:param name: output name
:param device_type: e.g. cpu, cuda, cpu by default
:param device_id: device id, e.g. 0
:param element_type: output element type
:param shape: output shape
:param buffer_ptr: memory pointer to output data
- '''
+ """
# Follow the `if` path when the user has not provided any pre-allocated buffer but still
# would like to bind an output to a specific device (e.g. cuda).
@@ -506,41 +539,51 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
# in which case ORT will allocate the memory for the user
# (2) The output has a dynamic shape and hence the size of the buffer may not be fixed across runs
if buffer_ptr is None:
- self._iobinding.bind_output(name,
- C.OrtDevice(get_ort_device_type(device_type), C.OrtDevice.default_memory(),
- device_id))
+ self._iobinding.bind_output(
+ name,
+ C.OrtDevice(
+ get_ort_device_type(device_type, device_id),
+ C.OrtDevice.default_memory(),
+ device_id,
+ ),
+ )
else:
if element_type is None or shape is None:
raise ValueError("`element_type` and `shape` are to be provided if pre-allocated memory is provided")
- self._iobinding.bind_output(name,
- C.OrtDevice(get_ort_device_type(device_type), C.OrtDevice.default_memory(),
- device_id),
- element_type, shape, buffer_ptr)
+ self._iobinding.bind_output(
+ name,
+ C.OrtDevice(
+ get_ort_device_type(device_type, device_id),
+ C.OrtDevice.default_memory(),
+ device_id,
+ ),
+ element_type,
+ shape,
+ buffer_ptr,
+ )
[docs] def bind_ortvalue_output(self, name, ortvalue):
- '''
+ """
:param name: output name
:param ortvalue: OrtValue instance to bind
- '''
+ """
self._iobinding.bind_ortvalue_output(name, ortvalue._ortvalue)
def synchronize_outputs(self):
self._iobinding.synchronize_outputs()
[docs] def get_outputs(self):
- '''
+ """
Returns the output OrtValues from the Run() that preceded the call.
The data buffer of the obtained OrtValues may not reside on CPU memory
- '''
- returned_ortvalues = []
-
- for ortvalue in self._iobinding.get_outputs():
- returned_ortvalues.append(OrtValue(ortvalue))
-
- return returned_ortvalues
+ """
+ outputs = self._iobinding.get_outputs()
+ if not isinstance(outputs, C.OrtValueVector):
+ raise TypeError("get_outputs() must return an instance of type 'OrtValueVector'.")
+ return [OrtValue(ortvalue) for ortvalue in outputs]
[docs] def copy_outputs_to_cpu(self):
- '''Copy output contents to CPU (if on another device). No-op if already on the CPU.'''
+ """Copy output contents to CPU (if on another device). No-op if already on the CPU."""
return self._iobinding.copy_outputs_to_cpu()
def clear_binding_inputs(self):
@@ -551,11 +594,12 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
[docs]class OrtValue:
- '''
+ """
A data structure that supports all ONNX data formats (tensors and non-tensors) that allows users
to place the data backing these on a device, for example, on a CUDA supported device.
This class provides APIs to construct and deal with OrtValues.
- '''
+ """
+
def __init__(self, ortvalue, numpy_obj=None):
if isinstance(ortvalue, C.OrtValue):
self._ortvalue = ortvalue
@@ -564,140 +608,183 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
self._numpy_obj = numpy_obj
else:
# An end user won't hit this error
- raise ValueError("`Provided ortvalue` needs to be of type " +
- "`onnxruntime.capi.onnxruntime_pybind11_state.OrtValue`")
+ raise ValueError(
+ "`Provided ortvalue` needs to be of type " + "`onnxruntime.capi.onnxruntime_pybind11_state.OrtValue`"
+ )
def _get_c_value(self):
return self._ortvalue
[docs] @staticmethod
- def ortvalue_from_numpy(numpy_obj, device_type='cpu', device_id=0):
- '''
+ def ortvalue_from_numpy(numpy_obj, device_type="cpu", device_id=0):
+ """
Factory method to construct an OrtValue (which holds a Tensor) from a given Numpy object
A copy of the data in the Numpy object is held by the OrtValue only if the device is NOT cpu
:param numpy_obj: The Numpy object to construct the OrtValue from
:param device_type: e.g. cpu, cuda, cpu by default
:param device_id: device id, e.g. 0
- '''
+ """
# Hold a reference to the numpy object (if device_type is 'cpu') as the OrtValue
# is backed directly by the data buffer of the numpy object and so the numpy object
# must be around until this OrtValue instance is around
- return OrtValue(C.OrtValue.ortvalue_from_numpy(numpy_obj, C.OrtDevice(get_ort_device_type(device_type),
- C.OrtDevice.default_memory(), device_id)), numpy_obj if device_type.lower() == 'cpu' else None)
+ return OrtValue(
+ C.OrtValue.ortvalue_from_numpy(
+ numpy_obj,
+ C.OrtDevice(
+ get_ort_device_type(device_type, device_id),
+ C.OrtDevice.default_memory(),
+ device_id,
+ ),
+ ),
+ numpy_obj if device_type.lower() == "cpu" else None,
+ )
[docs] @staticmethod
- def ortvalue_from_shape_and_type(shape=None, element_type=None, device_type='cpu', device_id=0):
- '''
+ def ortvalue_from_shape_and_type(shape=None, element_type=None, device_type="cpu", device_id=0):
+ """
Factory method to construct an OrtValue (which holds a Tensor) from given shape and element_type
:param shape: List of integers indicating the shape of the OrtValue
:param element_type: The data type of the elements in the OrtValue (numpy type)
:param device_type: e.g. cpu, cuda, cpu by default
:param device_id: device id, e.g. 0
- '''
+ """
if shape is None or element_type is None:
raise ValueError("`element_type` and `shape` are to be provided if pre-allocated memory is provided")
- return OrtValue(C.OrtValue.ortvalue_from_shape_and_type(shape, element_type,
- C.OrtDevice(get_ort_device_type(device_type), C.OrtDevice.default_memory(), device_id)))
+ return OrtValue(
+ C.OrtValue.ortvalue_from_shape_and_type(
+ shape,
+ element_type,
+ C.OrtDevice(
+ get_ort_device_type(device_type, device_id),
+ C.OrtDevice.default_memory(),
+ device_id,
+ ),
+ )
+ )
[docs] @staticmethod
def ort_value_from_sparse_tensor(sparse_tensor):
- '''
+ """
The function will construct an OrtValue instance from a valid SparseTensor
The new instance of OrtValue will assume the ownership of sparse_tensor
- '''
+ """
return OrtValue(C.OrtValue.ort_value_from_sparse_tensor(sparse_tensor._get_c_tensor()))
[docs] def as_sparse_tensor(self):
- '''
+ """
The function will return SparseTensor contained in this OrtValue
- '''
+ """
return SparseTensor(self._ortvalue.as_sparse_tensor())
[docs] def data_ptr(self):
- '''
+ """
Returns the address of the first element in the OrtValue's data buffer
- '''
+ """
return self._ortvalue.data_ptr()
[docs] def device_name(self):
- '''
+ """
Returns the name of the device where the OrtValue's data buffer resides e.g. cpu, cuda
- '''
+ """
return self._ortvalue.device_name().lower()
[docs] def shape(self):
- '''
+ """
Returns the shape of the data in the OrtValue
- '''
+ """
return self._ortvalue.shape()
[docs] def data_type(self):
- '''
+ """
Returns the data type of the data in the OrtValue
- '''
+ """
return self._ortvalue.data_type()
+[docs] def element_type(self):
+ """
+ Returns the proto type of the data in the OrtValue
+ if the OrtValue is a tensor.
+ """
+ return self._ortvalue.element_type()
+
[docs] def has_value(self):
- '''
+ """
Returns True if the OrtValue corresponding to an
optional type contains data, else returns False
- '''
+ """
return self._ortvalue.has_value()
[docs] def is_tensor(self):
- '''
+ """
Returns True if the OrtValue contains a Tensor, else returns False
- '''
+ """
return self._ortvalue.is_tensor()
[docs] def is_sparse_tensor(self):
- '''
+ """
Returns True if the OrtValue contains a SparseTensor, else returns False
- '''
+ """
return self._ortvalue.is_sparse_tensor()
[docs] def is_tensor_sequence(self):
- '''
+ """
Returns True if the OrtValue contains a Tensor Sequence, else returns False
- '''
+ """
return self._ortvalue.is_tensor_sequence()
[docs] def numpy(self):
- '''
+ """
Returns a Numpy object from the OrtValue.
Valid only for OrtValues holding Tensors. Throws for OrtValues holding non-Tensors.
Use accessors to gain a reference to non-Tensor objects such as SparseTensor
- '''
- return self._ortvalue.numpy()
+ """
+ return self._ortvalue.numpy()
+
+[docs] def update_inplace(self, np_arr):
+ """
+ Update the OrtValue in place with a new Numpy array. The numpy contents
+ are copied over to the device memory backing the OrtValue. It can be used
+ to update the input valuess for an InferenceSession with CUDA graph
+ enabled or other scenarios where the OrtValue needs to be updated while
+ the memory address can not be changed.
+ """
+ self._ortvalue.update_inplace(np_arr)
[docs]class OrtDevice:
- '''
+ """
A data structure that exposes the underlying C++ OrtDevice
- '''
+ """
+
def __init__(self, c_ort_device):
- '''
+ """
Internal constructor
- '''
+ """
if isinstance(c_ort_device, C.OrtDevice):
self._ort_device = c_ort_device
else:
- raise ValueError("`Provided object` needs to be of type " +
- "`onnxruntime.capi.onnxruntime_pybind11_state.OrtDevice`")
+ raise ValueError(
+ "`Provided object` needs to be of type " + "`onnxruntime.capi.onnxruntime_pybind11_state.OrtDevice`"
+ )
def _get_c_device(self):
- '''
+ """
Internal accessor to underlying object
- '''
+ """
return self._ort_device
@staticmethod
def make(ort_device_name, device_id):
- return OrtDevice(C.OrtDevice(get_ort_device_type(ort_device_name),
- C.OrtDevice.default_memory(), device_id))
+ return OrtDevice(
+ C.OrtDevice(
+ get_ort_device_type(ort_device_name, device_id),
+ C.OrtDevice.default_memory(),
+ device_id,
+ )
+ )
def device_id(self):
return self._ort_device.device_id()
@@ -707,29 +794,31 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
[docs]class SparseTensor:
- '''
+ """
A data structure that project the C++ SparseTensor object
The class provides API to work with the object.
Depending on the format, the class will hold more than one buffer
depending on the format
- '''
+ """
+
def __init__(self, sparse_tensor):
- '''
+ """
Internal constructor
- '''
+ """
if isinstance(sparse_tensor, C.SparseTensor):
self._tensor = sparse_tensor
else:
# An end user won't hit this error
- raise ValueError("`Provided object` needs to be of type " +
- "`onnxruntime.capi.onnxruntime_pybind11_state.SparseTensor`")
+ raise ValueError(
+ "`Provided object` needs to be of type " + "`onnxruntime.capi.onnxruntime_pybind11_state.SparseTensor`"
+ )
def _get_c_tensor(self):
return self._tensor
[docs] @staticmethod
def sparse_coo_from_numpy(dense_shape, values, coo_indices, ort_device):
- '''
+ """
Factory method to construct a SparseTensor in COO format from given arguments
:param dense_shape: 1-D numpy array(int64) or a python list that contains a dense_shape of the sparse tensor
@@ -748,13 +837,14 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
on GC. The buffers may reside in any storage either CPU or GPU.
For strings and objects, it will create a copy of the arrays in CPU memory as ORT does not support those
on other devices and their memory can not be mapped.
- '''
- return SparseTensor(C.SparseTensor.sparse_coo_from_numpy(dense_shape, values, coo_indices,
- ort_device._get_c_device()))
+ """
+ return SparseTensor(
+ C.SparseTensor.sparse_coo_from_numpy(dense_shape, values, coo_indices, ort_device._get_c_device())
+ )
[docs] @staticmethod
def sparse_csr_from_numpy(dense_shape, values, inner_indices, outer_indices, ort_device):
- '''
+ """
Factory method to construct a SparseTensor in CSR format from given arguments
:param dense_shape: 1-D numpy array(int64) or a python list that contains a dense_shape of the
@@ -773,20 +863,27 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
The buffers may reside in any storage either CPU or GPU.
For strings and objects, it will create a copy of the arrays in CPU memory as ORT does not support those
on other devices and their memory can not be mapped.
- '''
- return SparseTensor(C.SparseTensor.sparse_csr_from_numpy(dense_shape, values, inner_indices, outer_indices,
- ort_device._get_c_device()))
+ """
+ return SparseTensor(
+ C.SparseTensor.sparse_csr_from_numpy(
+ dense_shape,
+ values,
+ inner_indices,
+ outer_indices,
+ ort_device._get_c_device(),
+ )
+ )
[docs] def values(self):
- '''
+ """
The method returns a numpy array that is backed by the native memory
if the data type is numeric. Otherwise, the returned numpy array that contains
copies of the strings.
- '''
+ """
return self._tensor.values()
[docs] def as_coo_view(self):
- '''
+ """
The method will return coo representation of the sparse tensor which will enable
querying COO indices. If the instance did not contain COO format, it would throw.
You can query coo indices as:
@@ -796,11 +893,11 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
coo_indices = sparse_tensor.as_coo_view().indices()
which will return a numpy array that is backed by the native memory.
- '''
+ """
return self._tensor.get_coo_data()
[docs] def as_csrc_view(self):
- '''
+ """
The method will return CSR(C) representation of the sparse tensor which will enable
querying CRS(C) indices. If the instance dit not contain CSR(C) format, it would throw.
You can query indices as:
@@ -811,11 +908,11 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
outer_ndices = sparse_tensor.as_csrc_view().outer()
returning numpy arrays backed by the native memory.
- '''
+ """
return self._tensor.get_csrc_data()
[docs] def as_blocksparse_view(self):
- '''
+ """
The method will return coo representation of the sparse tensor which will enable
querying BlockSparse indices. If the instance did not contain BlockSparse format, it would throw.
You can query coo indices as:
@@ -825,11 +922,11 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
block_sparse_indices = sparse_tensor.as_blocksparse_view().indices()
which will return a numpy array that is backed by the native memory
- '''
+ """
return self._tensor.get_blocksparse_data()
[docs] def to_cuda(self, ort_device):
- '''
+ """
Returns a copy of this instance on the specified cuda device
:param ort_device: with name 'cuda' and valid gpu device id
@@ -840,31 +937,31 @@ Source code for onnxruntime.capi.onnxruntime_inference_collection
- this instance is already on GPU. Cross GPU copy is not supported
- CUDA is not present in this build
- if the specified device is not valid
- '''
+ """
return SparseTensor(self._tensor.to_cuda(ort_device._get_c_device()))
[docs] def format(self):
- '''
+ """
Returns a OrtSparseFormat enumeration
- '''
+ """
return self._tensor.format
[docs] def dense_shape(self):
- '''
+ """
Returns a numpy array(int64) containing a dense shape of a sparse tensor
- '''
+ """
return self._tensor.dense_shape()
[docs] def data_type(self):
- '''
+ """
Returns a string data type of the data in the OrtValue
- '''
+ """
return self._tensor.data_type()
[docs] def device_name(self):
- '''
+ """
Returns the name of the device where the SparseTensor data buffers reside e.g. cpu, cuda
- '''
+ """
return self._tensor.device_name().lower()
@@ -889,7 +986,7 @@ ONNX Runtime
Navigation
@@ -911,7 +1008,7 @@ Quick search
-
+
@@ -928,7 +1025,7 @@ Quick search
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
diff --git a/docs/api/python/modules/onnxruntime/datasets.html b/docs/api/python/modules/onnxruntime/datasets.html
deleted file mode 100644
index b4e759a2d8dd6..0000000000000
--- a/docs/api/python/modules/onnxruntime/datasets.html
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
-
- onnxruntime.datasets — ONNX Runtime 1.11.0 documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Source code for onnxruntime.datasets
-# Copyright (c) Microsoft Corporation. All rights reserved.
-# Licensed under the MIT License.
-"""
-Short examples used in the documentation.
-"""
-import os
-
-
-[docs]def get_example(name):
- """
- Retrieves the absolute file name of an example.
- """
- this = os.path.abspath(os.path.dirname(__file__))
- full = os.path.join(this, name)
- if not os.path.exists(full):
- raise FileNotFoundError("Unable to find example '{0}'".format(name))
- return full
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/api/python/objects.inv b/docs/api/python/objects.inv
index 138759759d8a3..e87c37d6a1e5c 100644
Binary files a/docs/api/python/objects.inv and b/docs/api/python/objects.inv differ
diff --git a/docs/api/python/search.html b/docs/api/python/search.html
index 75827edb1896e..5347ffb91beac 100644
--- a/docs/api/python/search.html
+++ b/docs/api/python/search.html
@@ -5,7 +5,7 @@
- Search — ONNX Runtime 1.11.0 documentation
+ Search — ONNX Runtime 1.13.0 documentation
@@ -17,6 +17,7 @@
+
@@ -93,7 +94,7 @@ ONNX Runtime
Navigation
@@ -120,7 +121,7 @@ Related Topics
©2018-2021, Microsoft.
|
- Powered by Sphinx 4.3.2
+ Powered by Sphinx 5.1.1
& Alabaster 0.7.12
diff --git a/docs/api/python/searchindex.js b/docs/api/python/searchindex.js
index 33823485fffc9..429ff14e448f1 100644
--- a/docs/api/python/searchindex.js
+++ b/docs/api/python/searchindex.js
@@ -1 +1 @@
-Search.setIndex({docnames:["api_summary","auto_examples/index","auto_examples/plot_backend","auto_examples/plot_common_errors","auto_examples/plot_convert_pipeline_vectorizer","auto_examples/plot_load_and_predict","auto_examples/plot_metadata","auto_examples/plot_pipeline","auto_examples/plot_profiling","auto_examples/plot_train_convert_predict","auto_examples/sg_execution_times","examples_md","index","tutorial"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["api_summary.rst","auto_examples/index.rst","auto_examples/plot_backend.rst","auto_examples/plot_common_errors.rst","auto_examples/plot_convert_pipeline_vectorizer.rst","auto_examples/plot_load_and_predict.rst","auto_examples/plot_metadata.rst","auto_examples/plot_pipeline.rst","auto_examples/plot_profiling.rst","auto_examples/plot_train_convert_predict.rst","auto_examples/sg_execution_times.rst","examples_md.rst","index.rst","tutorial.rst"],objects:{"onnxruntime.IOBinding":[[0,1,1,"","bind_cpu_input"],[0,1,1,"","bind_input"],[0,1,1,"","bind_ortvalue_input"],[0,1,1,"","bind_ortvalue_output"],[0,1,1,"","bind_output"],[0,1,1,"","copy_outputs_to_cpu"],[0,1,1,"","get_outputs"]],"onnxruntime.InferenceSession":[[0,1,1,"","disable_fallback"],[0,1,1,"","enable_fallback"],[0,1,1,"","end_profiling"],[0,1,1,"","get_inputs"],[0,1,1,"","get_modelmeta"],[0,1,1,"","get_outputs"],[0,1,1,"","get_overridable_initializers"],[0,1,1,"","get_profiling_start_time_ns"],[0,1,1,"","get_provider_options"],[0,1,1,"","get_providers"],[0,1,1,"","get_session_options"],[0,1,1,"","io_binding"],[0,1,1,"","run"],[0,1,1,"","run_with_iobinding"],[0,1,1,"","run_with_ort_values"],[0,1,1,"","set_providers"]],"onnxruntime.ModelMetadata":[[0,2,1,"","custom_metadata_map"],[0,2,1,"","description"],[0,2,1,"","domain"],[0,2,1,"","graph_description"],[0,2,1,"","graph_name"],[0,2,1,"","producer_name"],[0,2,1,"","version"]],"onnxruntime.NodeArg":[[0,2,1,"","name"],[0,2,1,"","shape"],[0,2,1,"","type"]],"onnxruntime.OrtValue":[[0,1,1,"","as_sparse_tensor"],[0,1,1,"","data_ptr"],[0,1,1,"","data_type"],[0,1,1,"","device_name"],[0,1,1,"","has_value"],[0,1,1,"","is_sparse_tensor"],[0,1,1,"","is_tensor"],[0,1,1,"","is_tensor_sequence"],[0,1,1,"","numpy"],[0,1,1,"","ort_value_from_sparse_tensor"],[0,1,1,"","ortvalue_from_numpy"],[0,1,1,"","ortvalue_from_shape_and_type"],[0,1,1,"","shape"]],"onnxruntime.RunOptions":[[0,2,1,"","log_severity_level"],[0,2,1,"","log_verbosity_level"],[0,2,1,"","logid"],[0,2,1,"","only_execute_path_to_fetches"],[0,2,1,"","terminate"]],"onnxruntime.SessionOptions":[[0,1,1,"","add_free_dimension_override_by_denotation"],[0,1,1,"","add_free_dimension_override_by_name"],[0,1,1,"","add_initializer"],[0,1,1,"","add_session_config_entry"],[0,2,1,"","enable_cpu_mem_arena"],[0,2,1,"","enable_mem_pattern"],[0,2,1,"","enable_mem_reuse"],[0,2,1,"","enable_profiling"],[0,2,1,"","execution_mode"],[0,2,1,"","execution_order"],[0,1,1,"","get_session_config_entry"],[0,2,1,"","graph_optimization_level"],[0,2,1,"","inter_op_num_threads"],[0,2,1,"","intra_op_num_threads"],[0,2,1,"","log_severity_level"],[0,2,1,"","log_verbosity_level"],[0,2,1,"","logid"],[0,2,1,"","optimized_model_filepath"],[0,2,1,"","profile_file_prefix"],[0,1,1,"","register_custom_ops_library"],[0,2,1,"","use_deterministic_compute"]],"onnxruntime.SparseTensor":[[0,1,1,"","as_blocksparse_view"],[0,1,1,"","as_coo_view"],[0,1,1,"","as_csrc_view"],[0,1,1,"","data_type"],[0,1,1,"","dense_shape"],[0,1,1,"","device_name"],[0,1,1,"","format"],[0,1,1,"","sparse_coo_from_numpy"],[0,1,1,"","sparse_csr_from_numpy"],[0,1,1,"","to_cuda"],[0,1,1,"","values"]],"onnxruntime.backend":[[0,3,1,"","is_compatible"],[0,3,1,"","prepare"],[0,3,1,"","run"],[0,3,1,"","supports_device"]],"onnxruntime.datasets":[[0,3,1,"","get_example"]],onnxruntime:[[0,0,1,"","IOBinding"],[0,0,1,"","InferenceSession"],[0,0,1,"","ModelMetadata"],[0,0,1,"","NodeArg"],[0,0,1,"","OrtDevice"],[0,0,1,"","OrtValue"],[0,0,1,"","RunOptions"],[0,0,1,"","SessionOptions"],[0,0,1,"","SparseTensor"],[0,3,1,"","get_device"]]},objnames:{"0":["py","class","Python class"],"1":["py","method","Python method"],"2":["py","property","Python property"],"3":["py","function","Python function"]},objtypes:{"0":"py:class","1":"py:method","2":"py:property","3":"py:function"},terms:{"0":[0,2,3,4,5,6,7,8,9,10,13],"00":10,"0002686927327886224":3,"000857":9,"000869":9,"000873":9,"000874":9,"000876":9,"000881":9,"0008813192099997735":9,"000883":9,"0008830492349999729":9,"000884":9,"000885":9,"000895":9,"000899":9,"000907":9,"00091":9,"000912":9,"000913":9,"000914":9,"000915":9,"000916":9,"000921":9,"000922":9,"000928":9,"000934":9,"00094":9,"000941":9,"000948":9,"000966":9,"000967":9,"000972":9,"000977":9,"000983":9,"000992":9,"00101":9,"00107":9,"00108":9,"0010817126199989956":9,"00111":9,"0024466365575790405":3,"00402":9,"00404":9,"00409":9,"005":[6,10],"00597":9,"00599":9,"00606":9,"007":[8,10],"009":[3,10],"01":[8,9],"0116":6,"013":[5,10],"013000461272895336":9,"014":[2,10],"02":9,"021566055715084076":3,"027834143489599228":3,"03":10,"03678159e":9,"03936365991830826":9,"04_17":8,"05":[3,9],"05698008090257645":9,"0636":9,"0637":9,"0639":9,"07":3,"07e":9,"09":8,"098":9,"0982":9,"0987":9,"0x7feaf2025c10":9,"0x7feafe274ac0":7,"1":[0,2,3,4,6,7,8,9],"10":9,"100":9,"100n":0,"11":8,"13":9,"133":9,"14":9,"15":9,"159":[9,10],"16":8,"167":9,"168":9,"1833212822675705":9,"196":[7,10],"2":[0,2,3,4,6,7,8,9],"20":9,"201":9,"202":9,"203":9,"22":[4,9,10],"23":10,"236":9,"237":9,"240":8,"25":[8,9],"25e":9,"271":9,"3":[0,2,3,5,6,7,8,9],"30":9,"30004554e":9,"305":9,"3089":8,"339":9,"34":9,"35":9,"36":8,"370":10,"374":9,"375":9,"38e":9,"3c59201b940f410fa29dc71ea9d5767d":6,"3g":9,"4":[0,3,5,7,8,9,13],"40":9,"42990368e":9,"45":9,"46e":9,"5":[0,3,5,7,8,9],"50":9,"5047166":5,"5055595":5,"50677085":5,"5097179":5,"51":9,"5178277":5,"5184905":5,"52279866":5,"5249817":5,"525905":5,"5320551":5,"53635114":5,"5369593":5,"5392329":5,"5398089":5,"54673976":5,"548968":5,"55":8,"550723":5,"5522731":5,"55390376":5,"5549751":5,"56":8,"5622808":5,"5627599":5,"56360227":5,"5688669":5,"56964463":5,"5735331":5,"5743989":5,"5819309":5,"5826889":5,"5833795":5,"5842683":5,"58536506":5,"59407187":5,"59544575":5,"6":[3,7,8,9],"60552883":5,"60617851e":9,"60848683":5,"6108959":5,"62443805":5,"6270167988259345e":3,"6312441":5,"6324704":5,"63349843":5,"63380575":5,"6382853":5,"63900065":5,"63964766":5,"6423601":5,"64378905":5,"65169865":5,"65232253":5,"6620137":5,"6746977":5,"68858314":5,"69634616":5,"69650024":5,"69800366e":9,"7":[7,8],"708999":5,"71":8,"71247685":5,"715":9,"7161434":5,"717":9,"72":9,"7210646":5,"7223234":5,"7300966":5,"787709464906584e":3,"8":[4,9],"8036782741546631":9,"83321386e":9,"8492364688427188e":9,"84923705e":9,"87":4,"9":[8,9],"9209977605173356":4,"92e":9,"93636566e":9,"9429903030395508":9,"9505997896194458":3,"95951945e":9,"9595235901069827e":9,"9606178402900696":9,"966":[4,10],"9671264999914226e":9,"97e":9,"9974970817565918":3,"9997311234474182":3,"9999999999999366":4,"boolean":0,"byte":[0,3],"case":[0,4,9],"class":3,"default":0,"do":[4,6,9],"float":[0,3,4,5],"function":[0,4],"import":[2,3,4,5,6,7,8,9,13],"int":[0,4],"new":0,"public":0,"return":[0,3,8,9],"static":0,"switch":2,"throw":0,"true":[0,4,8,9],"try":[2,3,4],"while":0,A:0,And:9,At:13,But:4,By:0,For:[0,12],If:0,In:[0,4,13],It:[0,3,5,6,13],Its:0,NOT:0,No:0,On:0,That:7,The:[0,2,3,4,5,8,9,13],Then:[7,9],There:[7,13],These:0,To:0,With:6,about:[0,4],absolut:0,access:0,accessor:0,across:0,actual:[0,3,4],add_free_dimension_override_by_denot:0,add_free_dimension_override_by_nam:0,add_initi:0,add_session_config_entri:0,addit:0,address:0,after:0,aka:12,all:[0,1,3],alloc:0,allow:0,alreadi:0,also:[0,2,5],altern:4,alwai:0,am:4,among:3,an:[0,3,4,5,7,9,13],ani:[0,3],anoth:0,api:[2,12],appear:9,append:[0,9],appli:0,applic:13,ar:[0,8,9,13],arena:0,arg0:0,arg1:0,arg:[0,8],argument:0,arr_on_cpu:0,arrai:[0,2,3,5,8,9],array_equ:0,as_blocksparse_view:0,as_coo_view:0,as_csrc_view:0,as_fram:4,as_sparse_tensor:0,associ:0,assum:0,astyp:[5,9,13],auto_exampl:10,auto_examples_jupyt:1,auto_examples_python:1,av:9,avail:[0,5],averag:9,ax:9,axesimag:7,back:0,backend:[1,10],bad:3,basic:0,batch:[9,13],becaus:[0,4],befor:[7,8],being:0,below:0,better:9,between:[0,2,9],bind:0,bind_cpu_input:0,bind_input:0,bind_ortvalue_input:0,bind_ortvalue_output:0,bind_output:0,block_sparse_indic:0,blockspars:0,blue:9,boston:4,both:0,bound:0,briefli:13,buffer:0,buffer_ptr:0,build:0,c:[0,9],c_ort_devic:0,california:4,call:[0,4],can:[0,2,3,4,8,13],cannot:[0,3],capabl:0,capi:[0,2,3,4],cat:8,categori:4,chang:[0,13],change_ir_vers:8,check:0,chenta:7,choos:0,chosen:0,click:[2,3,4,5,6,7,8,9],clr:[9,13],cmu:4,code:[0,1,2,3,4,5,6,7,8,9,13],col:0,common:[1,4,9,10,13],commonli:13,compar:[0,4,9],comparison:[0,9],compat:0,compil:[0,2],compos:13,comput:[0,2,4,5,8,9,13],config:0,configur:0,conform:0,confus:[4,9],confusion_matrix:9,consist:[4,9],construct:0,constructor:0,consum:0,contain:[0,6,8],content:[0,7],contigu:0,convert:[1,6,7,10],convert_sklearn:[4,9,13],coo:0,coo_indic:0,coordin:0,copi:0,copy_outputs_to_cpu:0,correspond:0,could:4,count:0,cpu:[0,2,13],cpuexecutionprovid:0,cr:0,creat:[0,4,13],creation:0,cross:0,csr:0,cuda:0,cudaexecutionprovid:0,current:0,curv:9,custom:0,custom_metadata_map:[0,6],d:[0,9],data:[3,4,9,13],data_ptr:0,data_typ:[0,4,7,9,13],data_url:4,datafram:[4,9],dataset:[2,3,4,5,6,7,8,9,13],datset:[4,9],deal:0,debug:0,decreas:0,decrement:0,def:[8,9],defin:[0,13],definit:[0,5],demonstr:[4,5,7,9],denot:0,dens:0,dense_shap:0,depend:[0,2,13],deploi:6,deprec:4,describ:[0,13],descript:[0,6],detail:[4,13],determinist:0,devic:2,device_id:0,device_nam:0,device_typ:0,df:9,dict:0,dictionari:[0,4],dictionarytyp:4,dictvector:4,did:0,differ:[7,9],dim:7,dim_valu:7,dimens:[0,2,3],directli:[0,2],disabl:0,disable_fallback:0,discourag:4,discrep:4,discuss:0,displai:7,dit:0,doc_str:6,docstr:7,document:[0,4],doe:[0,3,8],domain:[0,6,7],don:0,dot:7,doubl:[3,4],download:[0,1,2,3,4,5,6,7,8,9],draw:[1,10],dtype:[2,3,5,8],due:[0,3],dur:8,dynam:0,e:[0,2,3,4],each:0,easi:13,easier:2,edu:4,educ:4,either:[0,2,3],elem_typ:7,element:0,element_typ:0,els:0,enabl:[0,8],enable_cpu_mem_arena:0,enable_fallback:0,enable_mem_pattern:0,enable_mem_reus:0,enable_profil:[0,8],end:[0,4,9],end_profil:[0,8],engin:12,ensembl:[4,9],entri:0,enumer:0,equal:0,error:[0,1,10],etc:0,ethic:4,everi:9,ex:0,exactli:0,exampl:[2,3,4,5,6,7,8,9,12],example1:[5,7,8],example2:3,except:[2,3,4],exchang:12,execut:[0,1,9,10],execution_mod:0,execution_ord:0,exit:0,expect:[2,3,4],experi:9,explain:4,explicitli:0,expos:0,extend:2,extens:0,f:[4,8,9,13],facilit:0,factori:0,fail:[0,3,4],failur:0,fall:0,fallback:0,fals:[0,4],famou:13,fatal:0,favorit:3,fct:9,featur:0,feature_extract:4,feed:[0,3],fetch:[0,4],fetch_california_h:4,fetch_openml:4,few:0,fid:7,file:[0,8,10],filenam:[0,8],first:[0,3,4,9,13],fit:[4,9,13],fix:[2,3],float32:[0,2,3,5,8,9,13],float64:3,float_data:7,float_input:[2,3,4,9,13],floattensortyp:[4,9,13],focus:12,follow:[0,2,3,4],forest:9,format:[0,2,3,6,8],framework:[2,3],free:0,from:[0,2,3,4,5,6,7,8,9,13],full:[2,3,4,5,6,7,8,9],func:4,further:4,futur:0,futurewarn:4,g:0,gain:0,galleri:[2,3,4,5,6,7,8,9,12],gc:0,gced:0,gener:[0,1,2,3,4,5,6,7,8,9],get:[0,9,13],get_available_provid:[3,4,5,6,8,9,13],get_devic:[0,2],get_exampl:[0,2,3,5,6,7,8],get_input:[0,3,4,5,8,9,13],get_modelmeta:[0,6],get_output:[0,3,4,5,9,13],get_overridable_initi:0,get_profiling_start_time_n:0,get_provid:0,get_provider_opt:0,get_session_config_entri:0,get_session_opt:0,getopnodeproduc:7,getpydotgraph:7,github:[5,12],given:0,global:9,goe:3,got:[2,3],gpu:[0,2,13],gracefulli:0,gradientboostingregressor:4,graph:[0,7],graph_descript:0,graph_nam:[0,6],graph_optimization_level:0,green:9,ha:[0,4,9],handl:3,has_valu:0,have:0,header:4,held:0,here:[0,2,3,4,5,6,7,8,9,13],high:13,higher:3,hold:0,home:4,homogen:0,host:0,hous:4,house_pric:4,how:[0,2,5,6,7,8,9],hstack:4,http:4,i:[4,9],id:0,ident:9,identifi:0,im:9,imag:7,implement:[0,2],imread:7,imshow:7,includ:[0,4,7],increment:0,index:[0,2,3],indic:[0,2,3],individu:0,infer:0,inferenc:0,inferencesess:[0,3,4,5,6,8,9,13],info:0,inform:[0,12],initi:[0,7],initial_typ:[4,9,13],inner:0,inner_indic:0,inner_ndic:0,inp:4,input:[0,2,3,4,5,7,9],input_dict_ort_valu:0,input_fe:0,input_nam:[0,3,5,8,9,13],input_ort_valu:0,input_shap:5,input_typ:5,input_valu:0,insensit:0,inst:9,instal:0,instanc:[0,6],instanti:0,instead:[3,4],int64:[0,3,4],int64tensortyp:4,integ:0,inter_op_num_thread:0,interest:0,interpret:8,intra_op_num_thread:0,introduc:0,invalid:[2,3],invalid_argu:[2,3,4],invalidargu:[2,3,4],invoc:0,io:0,io_bind:0,ipynb:[2,3,4,5,6,7,8,9],ir_vers:[6,7,8],iri:[3,9,13],is_compat:0,is_sparse_tensor:0,is_tensor:0,is_tensor_sequ:0,issu:[0,4],its:[0,4,5,7,9,13],json:8,jupyt:[1,2,3,4,5,6,7,8,9],keep:6,kei:0,kernel:0,kind:3,kwarg:0,label:[2,3,9],label_nam:[9,13],learn:[4,5,6,9,13],legend:9,len:9,length:0,let:[0,2,5,6,8,9],level:[0,13],lib:4,libari:0,librari:0,linear:0,linear_model:[9,13],list:[0,13],ll:13,load:[1,2,3,4,6,7,8,9,10],load_boston:4,load_iri:[9,13],load_model_format:0,local:4,log:0,log_severity_level:0,log_verbosity_level:0,logger:0,logi:9,logid:0,logist:[2,3,6],logisticregress:[9,13],logreg_iri:[2,3,6,9,13],look:[3,4,7,9],loop:9,lr:7,ma:9,machin:[4,5,9,13],maco:0,mai:0,maintain:4,make:2,make_pipelin:4,map:[0,4],math:0,matplotlib:[7,9],matrix:[4,9],max:9,mb:10,mean:0,measur:9,mechan:0,memori:0,messag:7,meta:6,metadata:[0,1,10],metadata_prop:6,method:0,metric:[4,9],mi:9,min:9,minut:[2,3,4,5,6,7,8,9],misspel:3,mkl:0,mode:0,model:[1,2,3,4,6,9,10,12],model_loading_arrai:8,model_select:[4,9,13],model_vers:6,modelproto:[0,7],modul:[4,9],monotonic_n:0,more:[0,12,13],most:7,ms:12,msg:4,mul:7,mul_1:[7,8],multipl:[2,3],must:0,n:9,n_estim:9,n_tree:9,name:[0,2,3,4,5,7,8,9,13],nanosecond:0,nativ:0,necessarili:3,need:[0,8,9],net_draw:7,network:12,neural:12,nfor:9,nnz:0,node:[0,7],node_produc:7,non:0,none:[0,3,4,8,9,13],notebook:[1,2,3,4,5,6,7,8,9],np:[0,2,4],nrow:9,number:[0,3,9],numer:0,nummpi:0,numpi:[0,2,3,4,5,8,9,13],numpy_obj:0,o:7,object:[0,7,9],observ:4,obtain:0,one:[0,4,7,9,13],ones:4,onli:[0,3],only_execute_path_to_fetch:0,onnx:[0,1,3,6,8,10],onnx_model:8,onnx_model_str:8,onnxml:6,onnxmltool:[6,13],onnxruntim:[0,1,2,4,5,6,7,8,9,10,12,13],onnxruntime_profile__2022:8,onnxruntime_pybind11_st:[0,2,3,4],onnxruntimeerror:[2,3,4],onx:[4,9,13],op:0,op_typ:7,open:[4,7,8,9,12,13],oper:13,oppos:9,opset:8,opset_import:[7,8],optim:[0,13],optimized_model_filepath:0,option:[3,8],order:0,origin:4,ort:0,ort_devic:0,ort_output:0,ort_value_from_sparse_tensor:0,ortsparseformat:0,ortvalue_from_numpi:0,ortvalue_from_shape_and_typ:0,os:7,other:[0,2,3,7,9,13],otherwis:0,out:[2,3,4,5,6,7,8,9],outer:0,outer_indic:0,outer_ndic:0,output:[0,3,4,5,7,9,13],output_label:9,output_nam:[0,3,5],output_shap:5,output_typ:5,over:0,own:0,ownership:0,packag:[0,2,4,7],pair:0,panda:[4,9],parallel:0,param:0,paramet:0,parsefromstr:7,part:0,particular:0,particularli:0,path:0,path_or_byt:0,pattern:0,pd:4,perfectli:9,perform:[0,12,13],ph:8,pid:8,pipe:4,pipelin:[1,10,13],pipeline_vector:4,place:0,platform:0,pleas:[2,3,12],plot:9,plot_backend:[2,10],plot_common_error:[3,10],plot_convert_pipeline_vector:[4,10],plot_load_and_predict:[5,10],plot_metadata:[6,10],plot_pipelin:[7,10],plot_profil:[8,10],plot_train_convert_predict:[9,10],plt:7,png:7,pointer:0,pprint:[8,9],pre:0,preced:0,precis:0,pred:[4,9],pred_onx:[4,9,13],predict:[0,1,2,3,8,10,13],predict_proba:9,prefix:0,prepar:[0,2],present:0,price:4,primit:0,print:[2,3,4,5,6,7,8,9,13],prob_nam:9,prob_rt:9,prob_sklearn:9,proba:2,probabili:9,probabl:[2,3],problem:4,produc:[0,3,6],producer_nam:[0,6,7],producer_vers:6,product:6,prof_fil:8,profil:[0,1,10],profile_file_prefix:0,project:[0,12],properti:0,protobuf:7,provid:[0,3,4,5,6,8,9,13],provider_opt:0,purpos:4,put:0,py:[2,3,4,5,6,7,8,9,10],pydot_graph:7,pyplot:7,python3:4,python:[0,1,2,3,4,5,6,7,8,9],queri:0,r2_score:4,r:[3,8],rais:3,random:[5,9],randomforestclassifi:9,rang:9,rank:3,rankdir:7,rather:13,raw:9,raw_df:4,rb:[7,8],re:[0,3,5,8],read:[0,7],read_csv:4,readi:0,refer:[0,4],regist:0,register_custom_ops_librari:0,regress:[2,3,6],regular:[0,4],relat:6,relev:9,remov:4,rep:2,repeat:9,replac:3,represent:0,request:0,requir:0,reset:0,resid:0,result:[0,8],retriev:[0,4,5,9],reus:0,rf:9,rf_iri:9,rf_iris_:9,roc:9,row:[0,4],rt:[3,4,5,6,8,9,13],run:[2,3,4,5,6,7,8,9],run_log_severity_level:0,run_opt:0,run_with_iobind:0,run_with_ort_valu:0,runner:4,runtim:[0,1,6,8,10],runtimeerror:[2,3,4],s:[0,2,4,5,6,7,8,9],same:[2,3,9],save:[0,9],save_model_format:0,scenario:[0,4,9,13],scienc:4,scikit:[4,6,9,13],score:12,script:[2,3,4,5,6,7,8,9],se:0,second:[2,3,4,5,6,7,8,9],see:[0,5,6,8,9,12,13],self:0,sep:4,seq:4,sequenc:0,sequencetyp:4,sequenti:0,serial:0,serializetostr:[4,8,9,13],servic:13,sess:[0,3,4,5,6,8,9,13],sess_opt:0,sess_predict:9,sess_predict_proba:9,sess_predict_proba_loop:9,sess_predict_proba_rf:9,sess_profil:8,sess_tim:8,session:[0,8],session_initi:8,session_log_severity_level:0,sessionopt:8,set:[0,4,9,13],set_provid:0,set_titl:9,set_xlabel:9,set_ylabel:9,sever:[0,3],shape:[0,3,4,5,7,9],share:0,should:0,show:[0,4,5,8,9],sigmoid:5,similar:[4,9],simpl:[1,2,6,7,10],singl:[0,3],site:[4,13],situat:3,size:0,skiprow:4,skl2onnx:[4,9,13],sklearn:[4,6,9,13],small:4,snippet:0,so:0,some:[0,8],sourc:[0,1,2,3,4,5,6,7,8,9],spars:[0,4],sparse_coo_from_numpi:0,sparse_csr_from_numpi:0,sparse_tensor:0,special:4,specif:[0,6,13],specifi:[0,13],speed:9,sphinx:[1,2,3,4,5,6,7,8,9],start:[0,3,4,9],stat:4,statu:0,step:[3,4,9],storag:0,store:[0,7,8],str:0,string:0,strongli:4,structur:0,studi:4,suit:0,sum:9,summari:12,suppli:0,suppor:0,support:[0,8],supports_devic:0,system:7,t:[0,4],take:[3,4],target:[4,9,13],tensor:[0,3,4,5],tensor_typ:7,termin:0,test:[0,4,7,9],test_sigmoid:5,than:[0,3,7,13],thei:0,them:[0,4,9],therefor:4,thi:[0,2,3,4,5,7,8,9,13],those:0,thread:0,three:3,thu:0,tid:8,time:[0,2,3,4,5,6,7,8,9],timeit:9,timer:[0,9],to_cuda:0,to_dict:4,tool:[7,13],topolog:0,total:[2,3,4,5,6,7,8,9,10],tpng:7,track:6,train:[1,3,6,10],train_test_split:[4,9,13],tree:9,trt:9,ts:8,tsk:9,tupl:0,tutori:12,twice:0,type:[0,3,4,5,7],un:8,underli:0,unexpect:[3,4],unless:[0,4],unus:0,us:[0,2,3,4,6,7,9],usabl:0,usag:0,use_deterministic_comput:0,user:0,usual:[0,13],util:4,valid:0,valu:[0,4],variabl:4,vector:[3,4,5],verbos:0,veri:[1,4,8,10],verif:0,version:[0,6,7,8],vlog:0,w:7,wa:[2,6],wai:[7,13],want:0,warn:[0,3,4],wb:[4,9,13],we:[4,7,8,9,13],webservic:9,what:[8,9],when:[0,6],where:0,whether:0,which:[0,3,4,6,7,13],window:0,within:0,without:[2,13],work:0,would:0,wrap:0,write:[4,9,13],write_dot:7,x:[0,2,3,4,5,7,8,9,13],x_ortvalu:0,x_test:[4,9,13],x_test_dict:4,x_train:[4,9,13],x_train_dict:4,y:[0,4,5,7,9,13],y_ortvalu:0,y_test:[4,9,13],y_train:[4,9,13],you:[0,4,13],your:3,zero:0,zip:1},titles:["API Summary","Gallery of examples","ONNX Runtime Backend for ONNX","Common errors with onnxruntime","Train, convert and predict with ONNX Runtime","Load and predict with ONNX Runtime and a very simple model","Metadata","Draw a pipeline","Profile the execution of a simple model","Train, convert and predict with ONNX Runtime","Computation times","Gallery of examples","Python Bindings for ONNX Runtime","Tutorial"],titleterms:{"1":13,"2":13,"3":13,"class":0,"export":13,api:0,backend:[0,2],benchmark:9,bind:12,common:3,comput:10,convers:[4,9],convert:[4,9,13],data:0,dataset:0,devic:0,draw:7,error:3,exampl:[0,1],execut:8,favorit:13,format:[4,7,9,13],framework:13,galleri:1,intern:0,iobind:0,json:7,load:[0,5,13],logist:9,main:0,metadata:6,model:[0,5,7,8,13],modelmetadata:0,nodearg:0,onnx:[2,4,5,7,9,12,13],onnxruntim:3,option:0,ortdevic:0,ortvalu:0,pipelin:[4,7],predict:[4,5,9],probabl:9,profil:8,python:12,randomforest:9,regress:9,retriev:7,run:[0,13],runopt:0,runtim:[2,4,5,9,12,13],sessionopt:0,simpl:[5,8],sparsetensor:0,step:13,summari:0,time:10,train:[4,9,13],tutori:13,us:13,veri:5,your:13}})
\ No newline at end of file
+Search.setIndex({"docnames": ["api_summary", "auto_examples/index", "auto_examples/plot_backend", "auto_examples/plot_common_errors", "auto_examples/plot_convert_pipeline_vectorizer", "auto_examples/plot_load_and_predict", "auto_examples/plot_metadata", "auto_examples/plot_pipeline", "auto_examples/plot_profiling", "auto_examples/plot_train_convert_predict", "auto_examples/sg_execution_times", "examples_md", "index", "tutorial"], "filenames": ["api_summary.rst", "auto_examples/index.rst", "auto_examples/plot_backend.rst", "auto_examples/plot_common_errors.rst", "auto_examples/plot_convert_pipeline_vectorizer.rst", "auto_examples/plot_load_and_predict.rst", "auto_examples/plot_metadata.rst", "auto_examples/plot_pipeline.rst", "auto_examples/plot_profiling.rst", "auto_examples/plot_train_convert_predict.rst", "auto_examples/sg_execution_times.rst", "examples_md.rst", "index.rst", "tutorial.rst"], "titles": ["API", "Gallery of examples", "ONNX Runtime Backend for ONNX", "Common errors with onnxruntime", "Train, convert and predict with ONNX Runtime", "Load and predict with ONNX Runtime and a very simple model", "Metadata", "Draw a pipeline", "Profile the execution of a simple model", "Train, convert and predict with ONNX Runtime", "Computation times", "Gallery of examples", "Python Bindings for ONNX Runtime", "Tutorial"], "terms": {"onnx": [0, 1, 3, 6, 8, 10], "runtim": [0, 1, 6, 8, 10], "infer": 0, "graph": [0, 7], "format": [0, 2, 3, 6, 8], "ort": 0, "memori": 0, "disk": 0, "constrain": 0, "environ": [0, 4, 9], "The": [0, 2, 3, 4, 5, 8, 9, 13], "consum": 0, "produc": [0, 3, 6], "can": [0, 2, 3, 4, 8, 13], "specifi": [0, 13], "access": 0, "wai": [0, 7, 13], "best": 0, "match": 0, "your": [0, 3], "scenario": [0, 4, 9, 13], "i": [0, 2, 3, 4, 5, 6, 7, 9, 12, 13], "main": 0, "It": [0, 3, 5, 6, 13], "us": [0, 2, 3, 4, 6, 7, 9], "an": [0, 3, 4, 5, 7, 9, 13], "well": 0, "applic": [0, 13], "configur": 0, "session": [0, 8], "onnxruntim": [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 12, 13], "name": [0, 2, 3, 4, 5, 7, 8, 9, 13], "consist": [0, 4, 9], "comput": [0, 2, 4, 5, 8, 9, 13], "oper": [0, 13], "implement": [0, 2], "optim": [0, 13], "kernel": 0, "differ": [0, 7, 9], "hardwar": 0, "target": [0, 4, 9, 13], "orchestr": 0, "execut": [0, 1, 9, 10], "via": 0, "provid": [0, 3, 4, 5, 6, 8, 9, 13], "contain": [0, 6, 8], "set": [0, 4, 9, 13], "specif": [0, 6, 13], "gpu": [0, 2, 13], "iot": 0, "etc": 0, "ar": [0, 8, 9, 13], "paramet": 0, "from": [0, 2, 3, 4, 5, 6, 7, 8, 9, 13], "chosen": 0, "prioriti": 0, "order": 0, "given": 0, "list": [0, 13], "In": [0, 4, 9, 13], "exampl": [0, 2, 3, 4, 5, 6, 7, 8, 9, 12], "below": 0, "cuda": 0, "If": 0, "cudaexecutionprovid": 0, "cpuexecutionprovid": 0, "avail": [0, 5], "found": 0, "here": [0, 2, 3, 4, 5, 6, 7, 8, 9, 13], "sinc": 0, "1": [0, 2, 3, 4, 6, 7, 8, 9], "10": [0, 9], "you": [0, 4, 13], "must": 0, "explicitli": 0, "onli": [0, 3], "time": [0, 2, 3, 4, 5, 6, 7, 8, 9], "allow": 0, "explicit": 0, "follow": [0, 2, 3, 4], "assum": 0, "nvidia": 0, "replac": [0, 3], "suppli": 0, "other": [0, 2, 3, 7, 9, 13], "For": [0, 12], "enabl": [0, 8], "profil": [0, 1, 10], "enable_profil": [0, 8], "true": [0, 4, 8, 9], "sess_opt": 0, "its": [0, 4, 5, 7, 9, 13], "On": [0, 4, 9], "default": 0, "map": [0, 4], "nativ": 0, "python": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "structur": 0, "numpi": [0, 2, 3, 4, 5, 8, 9, 13], "arrai": [0, 2, 3, 5, 8, 9], "dictionari": [0, 4], "x": [0, 2, 3, 4, 5, 7, 8, 9, 13], "ortvalue_from_numpi": 0, "device_nam": 0, "shape": [0, 3, 4, 5, 7, 9], "data_typ": [0, 4, 7, 9, 13], "tensor": [0, 3, 4, 5], "float": [0, 3, 4, 5], "is_tensor": 0, "np": [0, 2, 4], "array_equ": 0, "part": 0, "feed": [0, 3], "result": [0, 8], "y": [0, 4, 5, 7, 9, 13], "By": 0, "alwai": 0, "place": 0, "": [0, 2, 4, 5, 6, 7, 8, 9], "have": 0, "mai": 0, "than": [0, 3, 7, 13], "becaus": [0, 4], "introduc": 0, "copi": 0, "between": [0, 2, 9], "support": [0, 8], "custom": 0, "all": [0, 1, 3], "user": 0, "back": 0, "thi": [0, 2, 3, 4, 5, 7, 8, 9, 13], "call": [0, 4], "To": 0, "featur": 0, "run_with_iobind": 0, "A": 0, "instanc": [0, 6], "onto": 0, "io_bind": 0, "over": 0, "node": [0, 7], "bind_cpu_input": 0, "bind_output": 0, "copy_outputs_to_cpu": 0, "0": [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13], "directli": [0, 2], "x_ortvalu": 0, "bind_input": 0, "device_typ": 0, "device_id": 0, "element_typ": 0, "float32": [0, 2, 3, 5, 8, 9, 13], "buffer_ptr": 0, "data_ptr": 0, "both": 0, "also": [0, 2, 5], "y_ortvalu": 0, "ortvalue_from_shape_and_typ": 0, "3": [0, 2, 3, 5, 6, 7, 8, 9], "2": [0, 2, 3, 4, 6, 7, 8, 9], "chang": [0, 13], "actual": [0, 3, 4], "being": 0, "bound": 0, "request": 0, "alloc": 0, "particularli": 0, "dynam": 0, "get_output": [0, 3, 4, 5, 9, 13], "get": [0, 9, 13], "correspond": 0, "thu": 0, "bind": 0, "return": [0, 3, 8, 9], "which": [0, 3, 4, 6, 7, 13], "ha": [0, 4, 9], "ort_output": 0, "addit": 0, "work": 0, "while": 0, "inferenc": 0, "bind_ortvalue_input": 0, "bind_ortvalue_output": 0, "pytorch": 0, "x_tensor": 0, "contigu": 0, "tupl": 0, "y_shape": 0, "need": [0, 8, 9], "y_tensor": 0, "torch": 0, "empti": 0, "dtype": [0, 2, 3, 5, 8], "path_or_byt": 0, "none": [0, 3, 4, 8, 9, 13], "provider_opt": 0, "kwarg": 0, "sourc": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "filenam": [0, 8], "serial": 0, "byte": [0, 3], "string": 0, "sequenc": 0, "decreas": 0, "preced": 0, "valu": [0, 4], "either": [0, 2, 3], "dict": 0, "type": [0, 3, 4, 5, 7], "unless": [0, 4], "so": 0, "add_session_config_entri": 0, "load_model_format": 0, "file": [0, 8, 10], "extens": 0, "when": [0, 6], "ani": [0, 3], "should": 0, "mean": 0, "capabl": 0, "otherwis": 0, "disable_fallback": 0, "disabl": 0, "fallback": 0, "mechan": 0, "enable_fallback": 0, "fail": [0, 3, 4], "due": [0, 3], "failur": 0, "reset": 0, "fall": 0, "end_profil": [0, 8], "end": [0, 4, 9], "store": [0, 7, 8], "get_input": [0, 3, 4, 5, 8, 9, 13], "metadata": [0, 1, 10], "get_modelmeta": [0, 6], "see": [0, 5, 6, 8, 9, 12, 13], "get_overridable_initi": 0, "includ": [0, 4, 7], "initi": [0, 7], "get_profiling_start_time_n": 0, "nanosecond": 0, "start": [0, 3, 4, 9], "compar": [0, 4, 9], "monotonic_n": 0, "after": 0, "some": [0, 8], "platform": 0, "timer": [0, 9], "precis": 0, "window": 0, "maco": 0, "100n": 0, "get_provider_opt": 0, "regist": 0, "get_provid": 0, "get_session_opt": 0, "object": [0, 7, 9], "output_nam": [0, 3, 5], "input_fe": 0, "run_opt": 0, "predict": [0, 1, 2, 3, 8, 10, 13], "input_nam": [0, 3, 5, 8, 9, 13], "input_valu": 0, "everi": [0, 9], "spars": [0, 4], "sess": [0, 3, 4, 5, 6, 8, 9, 13], "run_with_ort_valu": 0, "input_dict_ort_valu": 0, "input_ort_valu": 0, "how": [0, 2, 5, 6, 7, 8, 9], "creat": [0, 4, 13], "set_provid": 0, "underli": 0, "re": [0, 3, 5, 8], "self": 0, "capi": [0, 2, 3, 4], "onnxruntime_pybind11_st": [0, 2, 3, 4], "inform": [0, 12], "singl": [0, 3], "add_run_config_entri": 0, "arg0": 0, "str": 0, "arg1": 0, "entri": 0, "pair": 0, "get_run_config_entri": 0, "kei": 0, "properti": 0, "log_severity_level": 0, "log": 0, "sever": [0, 3], "level": [0, 13], "particular": 0, "invoc": 0, "verbos": 0, "info": 0, "warn": [0, 3, 4], "error": [0, 1, 10], "4": [0, 3, 5, 7, 8, 9, 13], "fatal": 0, "log_verbosity_level": 0, "vlog": 0, "debug": 0, "build": 0, "run_log_severity_level": 0, "appli": 0, "logid": 0, "identifi": 0, "gener": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "only_execute_path_to_fetch": 0, "fetch": [0, 4], "termin": 0, "current": 0, "individu": 0, "exit": 0, "gracefulli": 0, "statu": 0, "add_external_initi": 0, "add_free_dimension_override_by_denot": 0, "int": [0, 4], "dimens": [0, 2, 3], "size": 0, "each": 0, "denot": 0, "associ": 0, "free": 0, "add_free_dimension_override_by_nam": 0, "within": 0, "add_initi": 0, "enable_cpu_mem_arena": 0, "arena": 0, "pre": 0, "futur": 0, "usag": 0, "fals": [0, 4], "don": 0, "t": [0, 4, 8], "want": 0, "enable_mem_pattern": 0, "pattern": 0, "enable_mem_reus": 0, "reus": 0, "execution_mod": 0, "mode": 0, "sequenti": 0, "execution_ord": 0, "basic": 0, "topolog": 0, "get_session_config_entri": 0, "graph_optimization_level": 0, "inter_op_num_thread": 0, "number": [0, 3, 9], "thread": 0, "parallel": 0, "across": 0, "let": [0, 2, 5, 6, 8, 9], "choos": 0, "intra_op_num_thread": 0, "session_log_severity_level": 0, "logger": 0, "id": 0, "optimized_model_filepath": 0, "path": 0, "save_model_format": 0, "config": 0, "case": [0, 4, 9], "insensit": 0, "profile_file_prefix": 0, "prefix": 0, "append": [0, 9], "register_custom_ops_librari": 0, "share": 0, "librari": 0, "op": 0, "requir": 0, "use_deterministic_comput": 0, "whether": 0, "determinist": 0, "numpy_obj": 0, "non": 0, "construct": 0, "deal": 0, "as_sparse_tensor": 0, "function": [0, 4], "address": 0, "first": [0, 3, 4, 9, 13], "element": 0, "buffer": 0, "where": 0, "resid": 0, "e": [0, 2, 3, 4], "g": 0, "proto": 0, "has_valu": 0, "els": 0, "is_sparse_tensor": 0, "is_tensor_sequ": 0, "valid": 0, "hold": 0, "throw": 0, "accessor": 0, "gain": 0, "refer": [0, 4], "static": 0, "ort_value_from_sparse_tensor": 0, "sparse_tensor": 0, "new": 0, "ownership": 0, "factori": 0, "method": 0, "held": 0, "NOT": 0, "integ": 0, "indic": [0, 2, 3], "update_inplac": 0, "np_arr": 0, "updat": 0, "content": [0, 7], "valuess": 0, "project": [0, 12], "c": [0, 9], "depend": [0, 2, 13], "more": [0, 12, 13], "one": [0, 4, 7, 9, 13], "constructor": 0, "as_blocksparse_view": 0, "coo": 0, "represent": [0, 4, 9], "queri": 0, "blockspars": 0, "did": 0, "would": 0, "block_sparse_indic": 0, "as_coo_view": 0, "coo_indic": 0, "as_csrc_view": 0, "csr": 0, "cr": 0, "dit": 0, "inner_ndic": 0, "inner": 0, "outer_ndic": 0, "outer": 0, "dense_shap": 0, "int64": [0, 3, 4], "dens": 0, "ortsparseformat": 0, "enumer": 0, "sparse_coo_from_numpi": 0, "ort_devic": 0, "argument": 0, "d": [0, 9], "homogen": 0, "zero": 0, "linear": 0, "index": [0, 2, 3], "length": 0, "equal": 0, "coordin": 0, "nnz": 0, "exactli": 0, "twice": 0, "describ": [0, 13], "own": 0, "nummpi": 0, "suppor": 0, "numer": 0, "primit": 0, "them": [0, 4, 9], "storag": 0, "increment": 0, "count": 0, "decrement": 0, "gc": 0, "doe": [0, 3, 8], "those": 0, "sparse_csr_from_numpi": 0, "inner_indic": 0, "outer_indic": 0, "row": [0, 4], "col": 0, "Its": 0, "gced": 0, "to_cuda": 0, "alreadi": 0, "cross": 0, "present": 0, "arr_on_cpu": 0, "param": 0, "pointer": 0, "anoth": 0, "No": 0, "obtain": 0, "c_ort_devic": 0, "expos": 0, "These": 0, "cannot": [0, 3], "instanti": 0, "thei": 0, "libari": 0, "defin": [0, 13], "about": [0, 4], "usual": [0, 13], "facilit": 0, "comparison": [0, 9], "custom_metadata_map": [0, 6], "descript": [0, 6], "domain": [0, 6, 7], "graph_descript": 0, "host": 0, "graph_nam": [0, 6], "producer_nam": [0, 6, 7], "version": [0, 6, 7, 8], "definit": [0, 5], "arg": [0, 8], "regular": [0, 4], "perform": [0, 12, 13], "usabl": 0, "verif": 0, "conform": 0, "is_compat": 0, "compat": 0, "unus": 0, "ex": 0, "boolean": 0, "prepar": [0, 2], "readi": 0, "modelproto": [0, 7], "compil": [0, 2], "supports_devic": 0, "check": 0, "test": [0, 4, 7, 9], "suit": 0, "draw": [1, 10], "pipelin": [1, 10, 13], "load": [1, 2, 3, 4, 6, 7, 8, 9, 10], "veri": [1, 4, 8, 10], "simpl": [1, 2, 6, 7, 10], "model": [1, 2, 3, 4, 6, 9, 10, 12], "backend": [1, 10], "train": [1, 3, 6, 10], "convert": [1, 6, 7, 10], "common": [1, 4, 9, 10, 13], "download": [1, 2, 3, 4, 5, 6, 7, 8, 9], "code": [1, 2, 3, 4, 5, 6, 7, 8, 9, 13], "auto_examples_python": 1, "zip": 1, "jupyt": [1, 2, 3, 4, 5, 6, 7, 8, 9], "notebook": [1, 2, 3, 4, 5, 6, 7, 8, 9], "auto_examples_jupyt": 1, "sphinx": [1, 2, 3, 4, 5, 6, 7, 8, 9], "click": [2, 3, 4, 5, 6, 7, 8, 9], "full": [2, 3, 4, 5, 6, 7, 8, 9], "extend": 2, "api": [2, 12], "run": [2, 3, 4, 5, 6, 7, 8, 9], "logist": [2, 3, 6], "regress": [2, 3, 6], "import": [2, 3, 4, 5, 6, 7, 8, 9, 13], "devic": 2, "packag": [2, 4, 7], "wa": [2, 6], "cpu": [2, 13], "dataset": [2, 3, 4, 5, 6, 7, 8, 9, 13], "get_devic": 2, "invalidargu": [2, 3, 4], "get_exampl": [2, 3, 5, 6, 7, 8], "logreg_iri": [2, 3, 6, 9, 13], "rep": 2, "try": [2, 3, 4, 9], "label": [2, 3, 9], "proba": 2, "print": [2, 3, 4, 5, 6, 7, 8, 9, 13], "probabl": [2, 3], "except": [2, 3, 4], "runtimeerror": [2, 3, 4], "onnxruntimeerror": [2, 3, 4], "invalid_argu": [2, 3, 4], "got": [2, 3], "invalid": [2, 3], "input": [2, 3, 4, 5, 7, 9], "float_input": [2, 3, 4, 9, 13], "expect": [2, 3, 4], "pleas": [2, 3, 4, 9, 12], "fix": [2, 3], "without": [2, 13], "framework": [2, 3], "make": 2, "easier": 2, "switch": 2, "multipl": [2, 3], "same": [2, 3, 9], "total": [2, 3, 4, 5, 6, 7, 8, 9, 10], "script": [2, 3, 4, 5, 6, 7, 8, 9], "minut": [2, 3, 4, 5, 6, 7, 8, 9], "014": [2, 10], "second": [2, 3, 4, 5, 6, 7, 8, 9], "plot_backend": [2, 10], "py": [2, 3, 4, 5, 6, 7, 8, 9, 10], "ipynb": [2, 3, 4, 5, 6, 7, 8, 9], "galleri": [2, 3, 4, 5, 6, 7, 8, 9, 12], "look": [3, 4, 7, 9], "situat": 3, "rais": 3, "instead": [3, 4], "step": [3, 4, 9], "favorit": 3, "iri": [3, 9, 13], "take": [3, 4], "vector": [3, 4, 5], "class": 3, "among": 3, "three": 3, "rt": [3, 4, 5, 6, 8, 9, 13], "example2": 3, "inferencesess": [3, 4, 5, 6, 8, 9, 13], "get_available_provid": [3, 4, 5, 6, 8, 9, 13], "bad": 3, "handl": 3, "kind": 3, "5": [3, 5, 7, 8, 9], "6": [3, 7, 8, 9], "float64": 3, "unexpect": [3, 4], "data": [3, 4, 9, 13], "doubl": [3, 4], "output": [3, 4, 5, 7, 9, 13], "misspel": 3, "option": [3, 8], "9505997896194458": 3, "027834143489599228": 3, "021566055715084076": 3, "9974970817565918": 3, "6270167988259345e": 3, "05": [3, 9], "0024466365575790405": 3, "9997311234474182": 3, "787709464906584e": 3, "07": 3, "0002686927327886224": 3, "goe": 3, "necessarili": 3, "r": [3, 8], "rank": 3, "higher": 3, "009": [3, 10], "plot_common_error": [3, 10], "demonstr": [4, 5, 7, 9], "scikit": [4, 6, 9, 13], "learn": [4, 5, 6, 9, 13], "dictvector": 4, "retriev": [4, 5, 9], "boston": 4, "datset": [4, 9], "panda": [4, 9], "sklearn": [4, 6, 9, 13], "load_boston": 4, "model_select": [4, 9, 13], "train_test_split": [4, 9, 13], "x_train": [4, 9, 13], "x_test": [4, 9, 13], "y_train": [4, 9, 13], "y_test": [4, 9, 13], "x_train_dict": 4, "datafram": [4, 9], "to_dict": 4, "x_test_dict": 4, "home": 4, "runner": 4, "local": 4, "lib": 4, "python3": 4, "8": [4, 9], "site": [4, 13], "util": 4, "deprec": 4, "87": 4, "futurewarn": 4, "remov": 4, "hous": 4, "price": 4, "ethic": 4, "problem": 4, "document": 4, "further": 4, "detail": [4, 13], "maintain": 4, "therefor": 4, "strongli": 4, "discourag": 4, "purpos": 4, "studi": 4, "educ": 4, "issu": 4, "scienc": 4, "machin": [4, 5, 9, 13], "special": 4, "origin": 4, "pd": 4, "data_url": 4, "http": 4, "stat": 4, "cmu": 4, "edu": 4, "raw_df": 4, "read_csv": 4, "sep": 4, "skiprow": 4, "22": [4, 10], "header": 4, "hstack": 4, "altern": 4, "california": 4, "func": 4, "fetch_california_h": 4, "am": 4, "fetch_openml": 4, "house_pric": 4, "as_fram": 4, "msg": 4, "categori": 4, "we": [4, 7, 8, 9, 13], "ensembl": [4, 9], "gradientboostingregressor": 4, "feature_extract": 4, "make_pipelin": 4, "pipe": 4, "fit": [4, 9, 13], "x27": 4, "rerun": [4, 9], "cell": [4, 9], "show": [4, 5, 8, 9], "html": [4, 9], "trust": [4, 9], "github": [4, 5, 9, 12], "unabl": [4, 9], "render": [4, 9], "page": [4, 9], "nbviewer": [4, 9], "org": [4, 9], "pipelinepipelin": 4, "dictvectorizerdictvector": 4, "gradientboostingregressorgradientboostingregressor": 4, "confus": [4, 9], "matrix": [4, 9], "metric": [4, 9], "r2_score": 4, "pred": [4, 9], "8843586896936388": 4, "modul": [4, 9], "skl2onnx": [4, 9, 13], "convert_sklearn": [4, 9, 13], "dictionarytyp": 4, "floattensortyp": [4, 9, 13], "int64tensortyp": 4, "sequencetyp": 4, "initial_typ": [4, 9, 13], "onx": [4, 9, 13], "open": [4, 7, 8, 9, 12, 13], "pipeline_vector": 4, "wb": [4, 9, 13], "f": [4, 8, 9, 13], "write": [4, 9, 13], "serializetostr": [4, 8, 9, 13], "inp": 4, "out": 4, "variabl": 4, "could": 4, "do": [4, 6, 9], "pred_onx": [4, 9, 13], "seq": 4, "But": 4, "observ": 4, "ones": 4, "9999999999999561": 4, "similar": [4, 9], "explain": 4, "small": 4, "discrep": 4, "956": [4, 10], "plot_convert_pipeline_vector": [4, 10], "test_sigmoid": 5, "example1": [5, 7, 8], "sigmoid": 5, "input_shap": 5, "input_typ": 5, "output_shap": 5, "output_typ": 5, "random": [5, 9], "astyp": [5, 9, 13], "6362598": 5, "69637424": 5, "66820115": 5, "66656613": 5, "66833836": 5, "6735109": 5, "7306087": 5, "5827978": 5, "5790133": 5, "5281905": 5, "5875758": 5, "5256195": 5, "5485236": 5, "6221244": 5, "6873636": 5, "6726905": 5, "6112579": 5, "52476424": 5, "54415625": 5, "67545795": 5, "5092699": 5, "69676566": 5, "70407355": 5, "64738125": 5, "59030807": 5, "5806675": 5, "56875795": 5, "5390076": 5, "54938734": 5, "7169268": 5, "6765016": 5, "6001371": 5, "7239268": 5, "50898796": 5, "7079662": 5, "6985444": 5, "5496287": 5, "6313638": 5, "51122195": 5, "65290225": 5, "5237154": 5, "671646": 5, "57126474": 5, "6550032": 5, "554477": 5, "5734256": 5, "53975654": 5, "69029194": 5, "6799297": 5, "5502332": 5, "5855049": 5, "68936455": 5, "5244481": 5, "6527785": 5, "50686556": 5, "512562": 5, "6157843": 5, "6511187": 5, "7200693": 5, "62636346": 5, "007": [5, 10], "plot_load_and_predict": [5, 10], "relat": 6, "deploi": 6, "product": 6, "keep": 6, "track": 6, "doc_str": 6, "ir_vers": [6, 7, 8], "metadata_prop": 6, "model_vers": 6, "producer_vers": 6, "onnxml": 6, "onnxmltool": [6, 13], "0116": 6, "With": 6, "meta": 6, "3c59201b940f410fa29dc71ea9d5767d": 6, "003": [6, 10], "plot_metadata": [6, 10], "There": [7, 13], "That": 7, "most": 7, "mul_1": [7, 8], "protobuf": 7, "messag": 7, "chenta": 7, "w": 7, "op_typ": 7, "mul": 7, "dim": 7, "float_data": 7, "tensor_typ": 7, "elem_typ": 7, "dim_valu": 7, "opset_import": [7, 8], "7": [7, 8], "net_draw": 7, "befor": [7, 8], "rb": [7, 8], "fid": 7, "read": 7, "parsefromstr": 7, "tool": [7, 13], "getopnodeproduc": 7, "getpydotgraph": 7, "pydot_graph": 7, "rankdir": 7, "lr": 7, "node_produc": 7, "docstr": 7, "write_dot": 7, "dot": 7, "Then": [7, 9], "imag": 7, "o": 7, "system": 7, "tpng": 7, "displai": 7, "matplotlib": [7, 9], "pyplot": 7, "plt": 7, "imread": 7, "png": 7, "imshow": 7, "axesimag": 7, "0x7ff7301cd3a0": 7, "218": [7, 10], "plot_pipelin": [7, 10], "interpret": 8, "def": [8, 9], "change_ir_vers": 8, "opset": 8, "11": [8, 9], "onnx_model": 8, "onnx_model_str": 8, "9": [8, 9], "16": 8, "25": [8, 9], "36": 8, "sessionopt": 8, "sess_profil": 8, "prof_fil": 8, "onnxruntime_profile__2022": 8, "08": 8, "16_04": 8, "44": 8, "json": 8, "un": 8, "what": [8, 9], "sess_tim": 8, "pprint": [8, 9], "cat": 8, "dur": 8, "67": 8, "model_loading_arrai": 8, "ph": 8, "pid": 8, "3111": 8, "tid": 8, "236": 8, "session_initi": 8, "85": 8, "005": [8, 10], "plot_profil": [8, 10], "load_iri": [9, 13], "linear_model": [9, 13], "logisticregress": [9, 13], "clr": [9, 13], "logisticregressionlogisticregress": 9, "confusion_matrix": 9, "17": 9, "output_label": 9, "label_nam": [9, 13], "perfectli": 9, "ident": 9, "relev": 9, "roc": 9, "curv": 9, "prob_sklearn": 9, "predict_proba": 9, "82164782e": 9, "01": 9, "13598178e": 9, "23703980e": 9, "03": [9, 10], "12021102e": 9, "04": 9, "37134524e": 9, "62053455e": 9, "20249493e": 9, "06": 9, "74038501e": 9, "02": 9, "82594947e": 9, "And": 9, "probabili": 9, "appear": 9, "prob_nam": 9, "prob_rt": 9, "18216472864151": 9, "8135982751846313": 9, "0042370399460196495": 9, "0008120210259221494": 9, "3371346592903137": 9, "6620532870292664": 9, "2024959232803667e": 9, "01740385964512825": 9, "9825949668884277": 9, "timeit": 9, "speed": 9, "inst": 9, "repeat": 9, "20": 9, "global": 9, "raw": 9, "av": 9, "sum": 9, "len": 9, "mi": 9, "ma": 9, "min": 9, "max": 9, "averag": 9, "3g": 9, "46e": 9, "3e": 9, "6e": 9, "84e": 9, "78e": 9, "5e": 9, "838059500016698e": 9, "webservic": 9, "experi": 9, "oppos": 9, "batch": [9, 13], "loop": 9, "fct": 9, "n": 9, "nrow": 9, "rang": 9, "im": 9, "100": 9, "sess_predict": 9, "0042": 9, "00418": 9, "00428": 9, "000862": 9, "000856": 9, "000878": 9, "0008617829299998903": 9, "sess_predict_proba": 9, "00617": 9, "00615": 9, "0062": 9, "000887": 9, "00088": 9, "000915": 9, "0008867338849996997": 9, "better": 9, "save": 9, "randomforestclassifi": 9, "rf": 9, "rf_iri": 9, "sess_predict_proba_rf": 9, "723": 9, "721": 9, "729": 9, "00103": 9, "00102": 9, "00106": 9, "0010315913400006592": 9, "tree": 9, "measur": 9, "n_tree": 9, "51": 9, "n_estim": 9, "rf_iris_": 9, "sess_predict_proba_loop": 9, "tsk": 9, "trt": 9, "df": 9, "ax": 9, "plot": 9, "blue": 9, "logi": 9, "green": 9, "set_xlabel": 9, "set_ylabel": 9, "set_titl": 9, "nfor": 9, "forest": 9, "legend": 9, "0519": 9, "0521": 9, "000867": 9, "000898": 9, "0872": 9, "0871": 9, "0875": 9, "000881": 9, "000877": 9, "000893": 9, "15": 9, "123": 9, "122": 9, "000908": 9, "000896": 9, "000938": 9, "158": 9, "000902": 9, "000918": 9, "193": 9, "000929": 9, "000914": 9, "000961": 9, "30": 9, "228": 9, "229": 9, "000927": 9, "000948": 9, "35": 9, "263": 9, "264": 9, "000946": 9, "000935": 9, "000978": 9, "40": 9, "298": 9, "299": 9, "000952": 9, "000943": 9, "000972": 9, "45": 9, "334": 9, "333": 9, "335": 9, "000953": 9, "000985": 9, "50": 9, "369": 9, "371": 9, "000981": 9, "000973": 9, "00101": 9, "0x7ff71efab280": 9, "21": [9, 10], "167": [9, 10], "plot_train_convert_predict": [9, 10], "379": 10, "auto_exampl": 10, "mb": 10, "00": 10, "focus": 12, "score": 12, "engin": 12, "neural": 12, "network": 12, "exchang": 12, "aka": 12, "m": 12, "tutori": 12, "easi": 13, "high": 13, "rather": 13, "servic": 13, "At": 13, "briefli": 13, "ll": 13, "famou": 13, "commonli": 13, "compos": 13}, "objects": {"onnxruntime": [[0, 0, 1, "", "IOBinding"], [0, 0, 1, "", "InferenceSession"], [0, 0, 1, "", "ModelMetadata"], [0, 0, 1, "", "NodeArg"], [0, 0, 1, "", "OrtDevice"], [0, 0, 1, "", "OrtValue"], [0, 0, 1, "", "RunOptions"], [0, 0, 1, "", "SessionOptions"], [0, 0, 1, "", "SparseTensor"]], "onnxruntime.IOBinding": [[0, 1, 1, "", "bind_cpu_input"], [0, 1, 1, "", "bind_input"], [0, 1, 1, "", "bind_ortvalue_input"], [0, 1, 1, "", "bind_ortvalue_output"], [0, 1, 1, "", "bind_output"], [0, 1, 1, "", "copy_outputs_to_cpu"], [0, 1, 1, "", "get_outputs"]], "onnxruntime.InferenceSession": [[0, 1, 1, "", "disable_fallback"], [0, 1, 1, "", "enable_fallback"], [0, 1, 1, "", "end_profiling"], [0, 1, 1, "", "get_inputs"], [0, 1, 1, "", "get_modelmeta"], [0, 1, 1, "", "get_outputs"], [0, 1, 1, "", "get_overridable_initializers"], [0, 1, 1, "", "get_profiling_start_time_ns"], [0, 1, 1, "", "get_provider_options"], [0, 1, 1, "", "get_providers"], [0, 1, 1, "", "get_session_options"], [0, 1, 1, "", "io_binding"], [0, 1, 1, "", "run"], [0, 1, 1, "", "run_with_iobinding"], [0, 1, 1, "", "run_with_ort_values"], [0, 1, 1, "", "set_providers"]], "onnxruntime.ModelMetadata": [[0, 2, 1, "", "custom_metadata_map"], [0, 2, 1, "", "description"], [0, 2, 1, "", "domain"], [0, 2, 1, "", "graph_description"], [0, 2, 1, "", "graph_name"], [0, 2, 1, "", "producer_name"], [0, 2, 1, "", "version"]], "onnxruntime.NodeArg": [[0, 2, 1, "", "name"], [0, 2, 1, "", "shape"], [0, 2, 1, "", "type"]], "onnxruntime.OrtValue": [[0, 1, 1, "", "as_sparse_tensor"], [0, 1, 1, "", "data_ptr"], [0, 1, 1, "", "data_type"], [0, 1, 1, "", "device_name"], [0, 1, 1, "", "element_type"], [0, 1, 1, "", "has_value"], [0, 1, 1, "", "is_sparse_tensor"], [0, 1, 1, "", "is_tensor"], [0, 1, 1, "", "is_tensor_sequence"], [0, 1, 1, "", "numpy"], [0, 1, 1, "", "ort_value_from_sparse_tensor"], [0, 1, 1, "", "ortvalue_from_numpy"], [0, 1, 1, "", "ortvalue_from_shape_and_type"], [0, 1, 1, "", "shape"], [0, 1, 1, "", "update_inplace"]], "onnxruntime.RunOptions": [[0, 1, 1, "", "add_run_config_entry"], [0, 1, 1, "", "get_run_config_entry"], [0, 2, 1, "", "log_severity_level"], [0, 2, 1, "", "log_verbosity_level"], [0, 2, 1, "", "logid"], [0, 2, 1, "", "only_execute_path_to_fetches"], [0, 2, 1, "", "terminate"]], "onnxruntime.SessionOptions": [[0, 1, 1, "", "add_external_initializers"], [0, 1, 1, "", "add_free_dimension_override_by_denotation"], [0, 1, 1, "", "add_free_dimension_override_by_name"], [0, 1, 1, "", "add_initializer"], [0, 1, 1, "", "add_session_config_entry"], [0, 2, 1, "", "enable_cpu_mem_arena"], [0, 2, 1, "", "enable_mem_pattern"], [0, 2, 1, "", "enable_mem_reuse"], [0, 2, 1, "", "enable_profiling"], [0, 2, 1, "", "execution_mode"], [0, 2, 1, "", "execution_order"], [0, 1, 1, "", "get_session_config_entry"], [0, 2, 1, "", "graph_optimization_level"], [0, 2, 1, "", "inter_op_num_threads"], [0, 2, 1, "", "intra_op_num_threads"], [0, 2, 1, "", "log_severity_level"], [0, 2, 1, "", "log_verbosity_level"], [0, 2, 1, "", "logid"], [0, 2, 1, "", "optimized_model_filepath"], [0, 2, 1, "", "profile_file_prefix"], [0, 1, 1, "", "register_custom_ops_library"], [0, 2, 1, "", "use_deterministic_compute"]], "onnxruntime.SparseTensor": [[0, 1, 1, "", "as_blocksparse_view"], [0, 1, 1, "", "as_coo_view"], [0, 1, 1, "", "as_csrc_view"], [0, 1, 1, "", "data_type"], [0, 1, 1, "", "dense_shape"], [0, 1, 1, "", "device_name"], [0, 1, 1, "", "format"], [0, 1, 1, "", "sparse_coo_from_numpy"], [0, 1, 1, "", "sparse_csr_from_numpy"], [0, 1, 1, "", "to_cuda"], [0, 1, 1, "", "values"]], "onnxruntime.backend": [[0, 3, 1, "", "is_compatible"], [0, 3, 1, "", "prepare"], [0, 3, 1, "", "run"], [0, 3, 1, "", "supports_device"]]}, "objtypes": {"0": "py:class", "1": "py:method", "2": "py:property", "3": "py:function"}, "objnames": {"0": ["py", "class", "Python class"], "1": ["py", "method", "Python method"], "2": ["py", "property", "Python property"], "3": ["py", "function", "Python function"]}, "titleterms": {"api": 0, "overview": 0, "load": [0, 5, 13], "run": [0, 13], "model": [0, 5, 7, 8, 13], "data": 0, "input": 0, "output": 0, "cpu": 0, "devic": 0, "detail": 0, "inferencesess": 0, "option": 0, "runopt": 0, "sessionopt": 0, "ortvalu": 0, "sparsetensor": 0, "iobind": 0, "ortdevic": 0, "intern": 0, "class": 0, "modelmetadata": 0, "nodearg": 0, "backend": [0, 2], "galleri": 1, "exampl": 1, "onnx": [2, 4, 5, 7, 9, 12, 13], "runtim": [2, 4, 5, 9, 12, 13], "common": 3, "error": 3, "onnxruntim": 3, "train": [4, 9, 13], "convert": [4, 9, 13], "predict": [4, 5, 9], "pipelin": [4, 7], "convers": [4, 9], "format": [4, 7, 9, 13], "veri": 5, "simpl": [5, 8], "metadata": 6, "draw": 7, "retriev": 7, "json": 7, "profil": 8, "execut": 8, "logist": 9, "regress": 9, "probabl": 9, "benchmark": 9, "randomforest": 9, "comput": 10, "time": 10, "python": 12, "bind": 12, "tutori": 13, "step": 13, "1": 13, "us": 13, "your": 13, "favorit": 13, "framework": 13, "2": 13, "export": 13, "3": 13}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.intersphinx": 1, "sphinx.ext.viewcode": 1, "sphinx": 56}})
\ No newline at end of file
diff --git a/docs/api/python/sources/api_summary.rst.txt b/docs/api/python/sources/api_summary.rst.txt
index 0325cdd47fa97..12d17bafd3ee9 100644
--- a/docs/api/python/sources/api_summary.rst.txt
+++ b/docs/api/python/sources/api_summary.rst.txt
@@ -1,65 +1,107 @@
-===========
-API Summary
-===========
-
-Summary of public functions and classes exposed
-in *ONNX Runtime*.
+===
+API
+===
.. contents::
:local:
-OrtValue
-=========
+API Overview
+============
-*ONNX Runtime* works with native Python data structures which are mapped into ONNX data formats :
-Numpy arrays (tensors), dictionaries (maps), and a list of Numpy arrays (sequences).
-The data backing these are on CPU.
+*ONNX Runtime* loads and runs inference on a model in ONNX graph format, or ORT format (for memory and disk constrained environments).
-*ONNX Runtime* supports a custom data structure that supports all ONNX data formats that allows users
-to place the data backing these on a device, for example, on a CUDA supported device. This allows for
-interesting *IOBinding* scenarios (discussed below). In addition, *ONNX Runtime* supports directly
-working with *OrtValue* (s) while inferencing a model if provided as part of the input feed.
+The data consumed and produced by the model can be specified and accessed in the way that best matches your scenario.
+
+Load and run a model
+--------------------
-Below is an example showing creation of an *OrtValue* from a Numpy array while placing its backing memory
-on a CUDA device:
+InferenceSession is the main class of ONNX Runtime. It is used to load and run an ONNX model,
+as well as specify environment and application configuration options.
.. code-block:: python
- # X is numpy array on cpu, create an OrtValue and place it on cuda device id = 0
- ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
- ortvalue.device_name() # 'cuda'
- ortvalue.shape() # shape of the numpy array X
- ortvalue.data_type() # 'tensor(float)'
- ortvalue.is_tensor() # 'True'
+ session = onnxruntime.InferenceSession('model.onnx')
+
+ outputs = session.run([output names], inputs)
+
+ONNX and ORT format models consist of a graph of computations, modeled as operators,
+and implemented as optimized operator kernels for different hardware targets.
+ONNX Runtime orchestrates the execution of operator kernels via `execution providers`.
+An execution provider contains the set of kernels for a specific execution target (CPU, GPU, IoT etc).
+Execution provides are configured using the `providers` parameter. Kernels from different execution
+providers are chosen in the priority order given in the list of providers. In the example below
+if there is a kernel in the CUDA execution provider ONNX Runtime executes that on GPU. If not
+the kernel is executed on CPU.
+
+.. code-block:: python
+
+ session = onnxruntime.InferenceSession(model,
+ providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
+
+The list of available execution providers can be found here: `Execution Providers `_.
+
+Since ONNX Runtime 1.10, you must explicitly specify the execution provider for your target.
+Running on CPU is the only time the API allows no explicit setting of the `provider` parameter.
+In the examples that follow, the `CUDAExecutionProvider` and `CPUExecutionProvider` are used, assuming the application is running on NVIDIA GPUs.
+Replace these with the execution provider specific to your environment.
+
+You can supply other session configurations via the `session options` parameter. For example, to enable
+profiling on the session:
+
+.. code-block:: python
+
+ options = onnxruntime.SessionOptions()
+ options.enable_profiling=True
+ session = onnxruntime.InferenceSession('model.onnx', sess_options=options, providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
+
+
+Data inputs and outputs
+-----------------------
+
+The ONNX Runtime Inference Session consumes and produces data using its OrtValue class.
+
+Data on CPU
+^^^^^^^^^^^
+
+On CPU (the default), OrtValues can be mapped to and from native Python data structures: numpy arrays, dictionaries and lists of
+numpy arrays.
+
+.. code-block:: python
+
+ # X is numpy array on cpu
+ ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X)
+ ortvalue.device_name() # 'cpu'
+ ortvalue.shape() # shape of the numpy array X
+ ortvalue.data_type() # 'tensor(float)'
+ ortvalue.is_tensor() # 'True'
np.array_equal(ortvalue.numpy(), X) # 'True'
# ortvalue can be provided as part of the input feed to a model
- ses = onnxruntime.InferenceSession('model.onnx')
- res = sess.run(["Y"], {"X": ortvalue})
+ session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
+ results = session.run(["Y"], {"X": ortvalue})
-IOBinding
-=========
+By default, *ONNX Runtime* always places input(s) and output(s) on CPU. Having the data on CPU
+may not optimal if the input or output is consumed and produced on a device
+other than CPU because it introduces data copy between CPU and the device.
-By default, *ONNX Runtime* always places input(s) and output(s) on CPU, which
-is not optimal if the input or output is consumed and produced on a device
-other than CPU because it introduces data copy between CPU and the device.
-*ONNX Runtime* provides a feature, *IO Binding*, which addresses this issue by
-enabling users to specify which device to place input(s) and output(s) on.
-Here are scenarios to use this feature.
-(In the following code snippets, *model.onnx* is the model to execute,
-*X* is the input data to feed, and *Y* is the output data.)
+Data on device
+^^^^^^^^^^^^^^
+
+*ONNX Runtime* supports a custom data structure that supports all ONNX data formats that allows users
+to place the data backing these on a device, for example, on a CUDA supported device. In ONNX Runtime,
+this called `IOBinding`.
-Scenario 1:
+To use the `IOBinding` feature, replace `InferenceSession.run()` with `InferenceSession.run_with_iobinding()`.
A graph is executed on a device other than CPU, for instance CUDA. Users can
-use IOBinding to put input on CUDA as the follows.
+use IOBinding to copy the data onto the GPU.
.. code-block:: python
# X is numpy array on cpu
- session = onnxruntime.InferenceSession('model.onnx')
+ session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
# OnnxRuntime will copy the data over to the CUDA device if 'input' is consumed by nodes on the CUDA device
io_binding.bind_cpu_input('input', X)
@@ -67,37 +109,32 @@ use IOBinding to put input on CUDA as the follows.
session.run_with_iobinding(io_binding)
Y = io_binding.copy_outputs_to_cpu()[0]
-Scenario 2:
-
The input data is on a device, users directly use the input. The output data is on CPU.
.. code-block:: python
# X is numpy array on cpu
X_ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
- session = onnxruntime.InferenceSession('model.onnx')
+ session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
io_binding.bind_input(name='input', device_type=X_ortvalue.device_name(), device_id=0, element_type=np.float32, shape=X_ortvalue.shape(), buffer_ptr=X_ortvalue.data_ptr())
io_binding.bind_output('output')
session.run_with_iobinding(io_binding)
Y = io_binding.copy_outputs_to_cpu()[0]
-Scenario 3:
-
-The input data and output data are both on a device, users directly use the input and also place output on the device.
+The input data and output data are both on a device, users directly use the input and also place output on the device.
.. code-block:: python
#X is numpy array on cpu
X_ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
Y_ortvalue = onnxruntime.OrtValue.ortvalue_from_shape_and_type([3, 2], np.float32, 'cuda', 0) # Change the shape to the actual shape of the output being bound
- session = onnxruntime.InferenceSession('model.onnx')
+ session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
io_binding.bind_input(name='input', device_type=X_ortvalue.device_name(), device_id=0, element_type=np.float32, shape=X_ortvalue.shape(), buffer_ptr=X_ortvalue.data_ptr())
io_binding.bind_output(name='output', device_type=Y_ortvalue.device_name(), device_id=0, element_type=np.float32, shape=Y_ortvalue.shape(), buffer_ptr=Y_ortvalue.data_ptr())
session.run_with_iobinding(io_binding)
-Scenario 4:
Users can request *ONNX Runtime* to allocate an output on a device. This is particularly useful for dynamic shaped outputs.
Users can use the *get_outputs()* API to get access to the *OrtValue* (s) corresponding to the allocated output(s).
@@ -107,7 +144,7 @@ Users can thus consume the *ONNX Runtime* allocated memory for the output as an
#X is numpy array on cpu
X_ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
- session = onnxruntime.InferenceSession('model.onnx')
+ session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
io_binding.bind_input(name='input', device_type=X_ortvalue.device_name(), device_id=0, element_type=np.float32, shape=X_ortvalue.shape(), buffer_ptr=X_ortvalue.data_ptr())
#Request ONNX Runtime to bind and allocate memory on CUDA for 'output'
@@ -117,7 +154,7 @@ Users can thus consume the *ONNX Runtime* allocated memory for the output as an
ort_output = io_binding.get_outputs()[0]
-Scenario 5:
+In addition, *ONNX Runtime* supports directly working with *OrtValue* (s) while inferencing a model if provided as part of the input feed.
Users can bind *OrtValue* (s) directly.
@@ -127,39 +164,52 @@ Users can bind *OrtValue* (s) directly.
#X is numpy array on cpu
X_ortvalue = onnxruntime.OrtValue.ortvalue_from_numpy(X, 'cuda', 0)
Y_ortvalue = onnxruntime.OrtValue.ortvalue_from_shape_and_type([3, 2], np.float32, 'cuda', 0) # Change the shape to the actual shape of the output being bound
- session = onnxruntime.InferenceSession('model.onnx')
+ session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
io_binding = session.io_binding()
io_binding.bind_ortvalue_input('input', X_ortvalue)
io_binding.bind_ortvalue_output('output', Y_ortvalue)
session.run_with_iobinding(io_binding)
-Device
-======
-
-The package is compiled for a specific device, GPU or CPU.
-The CPU implementation includes optimizations
-such as MKL (Math Kernel Libary). The following function
-indicates the chosen option:
-.. autofunction:: onnxruntime.get_device
+You can also bind inputs and outputs directly to a PyTorch tensor.
-Examples and datasets
-=====================
-
-The package contains a few models stored in ONNX format
-used in the documentation. These don't need to be downloaded
-as they are installed with the package.
-
-.. autofunction:: onnxruntime.datasets.get_example
+.. code-block:: python
-Load and run a model
-====================
+ # X is a PyTorch tensor on device
+ session = onnxruntime.InferenceSession('model.onnx', providers=['CUDAExecutionProvider', 'CPUExecutionProvider']))
+ binding = session.io_binding()
+
+ X_tensor = X.contiguous()
+
+ binding.bind_input(
+ name='X',
+ device_type='cuda',
+ device_id=0,
+ element_type=np.float32,
+ shape=tuple(x_tensor.shape),
+ buffer_ptr=x_tensor.data_ptr(),
+ )
+
+ ## Allocate the PyTorch tensor for the model output
+ Y_shape = ... # You need to specify the output PyTorch tensor shape
+ Y_tensor = torch.empty(Y_shape, dtype=torch.float32, device='cuda:0').contiguous()
+ binding.bind_output(
+ name='Y',
+ device_type='cuda',
+ device_id=0,
+ element_type=np.float32,
+ shape=tuple(Y_tensor.shape),
+ buffer_ptr=Y_tensor.data_ptr(),
+ )
+
+ session.run_with_iobinding(binding)
+
+
+API Details
+===========
-*ONNX Runtime* reads a model saved in ONNX format.
-The main class *InferenceSession* wraps these functionalities
-in a single place.
-Main class
+InferenceSession
----------
.. autoclass:: onnxruntime.InferenceSession
diff --git a/docs/api/python/sources/auto_examples/index.rst.txt b/docs/api/python/sources/auto_examples/index.rst.txt
index 30fa6cc39cbc1..7a082c95e7201 100644
--- a/docs/api/python/sources/auto_examples/index.rst.txt
+++ b/docs/api/python/sources/auto_examples/index.rst.txt
@@ -1,9 +1,5 @@
:orphan:
-
-
-.. _sphx_glr_auto_examples:
-
Gallery of examples
===================
@@ -12,194 +8,176 @@ Gallery of examples
+.. raw:: html
+
+
+
+
.. raw:: html
.. only:: html
- .. figure:: /auto_examples/images/thumb/sphx_glr_plot_pipeline_thumb.png
- :alt: Draw a pipeline
+ .. image:: /auto_examples/images/thumb/sphx_glr_plot_pipeline_thumb.png
+ :alt: Draw a pipeline
- :ref:`sphx_glr_auto_examples_plot_pipeline.py`
+ :ref:`sphx_glr_auto_examples_plot_pipeline.py`
.. raw:: html
+ Draw a pipeline
-.. toctree::
- :hidden:
-
- /auto_examples/plot_pipeline
-
.. raw:: html
.. only:: html
- .. figure:: /auto_examples/images/thumb/sphx_glr_plot_load_and_predict_thumb.png
- :alt: Load and predict with ONNX Runtime and a very simple model
+ .. image:: /auto_examples/images/thumb/sphx_glr_plot_load_and_predict_thumb.png
+ :alt: Load and predict with ONNX Runtime and a very simple model
- :ref:`sphx_glr_auto_examples_plot_load_and_predict.py`
+ :ref:`sphx_glr_auto_examples_plot_load_and_predict.py`
.. raw:: html
+ Load and predict with ONNX Runtime and a very simple model
-.. toctree::
- :hidden:
-
- /auto_examples/plot_load_and_predict
-
.. raw:: html
.. only:: html
- .. figure:: /auto_examples/images/thumb/sphx_glr_plot_backend_thumb.png
- :alt: ONNX Runtime Backend for ONNX
+ .. image:: /auto_examples/images/thumb/sphx_glr_plot_backend_thumb.png
+ :alt: ONNX Runtime Backend for ONNX
- :ref:`sphx_glr_auto_examples_plot_backend.py`
+ :ref:`sphx_glr_auto_examples_plot_backend.py`
.. raw:: html
+ ONNX Runtime Backend for ONNX
-.. toctree::
- :hidden:
-
- /auto_examples/plot_backend
-
.. raw:: html
.. only:: html
- .. figure:: /auto_examples/images/thumb/sphx_glr_plot_metadata_thumb.png
- :alt: Metadata
+ .. image:: /auto_examples/images/thumb/sphx_glr_plot_metadata_thumb.png
+ :alt: Metadata
- :ref:`sphx_glr_auto_examples_plot_metadata.py`
+ :ref:`sphx_glr_auto_examples_plot_metadata.py`
.. raw:: html
+ Metadata
-.. toctree::
- :hidden:
-
- /auto_examples/plot_metadata
-
.. raw:: html
.. only:: html
- .. figure:: /auto_examples/images/thumb/sphx_glr_plot_profiling_thumb.png
- :alt: Profile the execution of a simple model
+ .. image:: /auto_examples/images/thumb/sphx_glr_plot_profiling_thumb.png
+ :alt: Profile the execution of a simple model
- :ref:`sphx_glr_auto_examples_plot_profiling.py`
+ :ref:`sphx_glr_auto_examples_plot_profiling.py`
.. raw:: html
+ Profile the execution of a simple model
-.. toctree::
- :hidden:
-
- /auto_examples/plot_profiling
-
.. raw:: html
.. only:: html
- .. figure:: /auto_examples/images/thumb/sphx_glr_plot_convert_pipeline_vectorizer_thumb.png
- :alt: Train, convert and predict with ONNX Runtime
+ .. image:: /auto_examples/images/thumb/sphx_glr_plot_convert_pipeline_vectorizer_thumb.png
+ :alt: Train, convert and predict with ONNX Runtime
- :ref:`sphx_glr_auto_examples_plot_convert_pipeline_vectorizer.py`
+ :ref:`sphx_glr_auto_examples_plot_convert_pipeline_vectorizer.py`
.. raw:: html
+ Train, convert and predict with ONNX Runtime
-.. toctree::
- :hidden:
-
- /auto_examples/plot_convert_pipeline_vectorizer
-
.. raw:: html
.. only:: html
- .. figure:: /auto_examples/images/thumb/sphx_glr_plot_common_errors_thumb.png
- :alt: Common errors with onnxruntime
+ .. image:: /auto_examples/images/thumb/sphx_glr_plot_common_errors_thumb.png
+ :alt: Common errors with onnxruntime
- :ref:`sphx_glr_auto_examples_plot_common_errors.py`
+ :ref:`sphx_glr_auto_examples_plot_common_errors.py`
.. raw:: html
+ Common errors with onnxruntime
-.. toctree::
- :hidden:
-
- /auto_examples/plot_common_errors
-
.. raw:: html
.. only:: html
- .. figure:: /auto_examples/images/thumb/sphx_glr_plot_train_convert_predict_thumb.png
- :alt: Train, convert and predict with ONNX Runtime
+ .. image:: /auto_examples/images/thumb/sphx_glr_plot_train_convert_predict_thumb.png
+ :alt: Train, convert and predict with ONNX Runtime
- :ref:`sphx_glr_auto_examples_plot_train_convert_predict.py`
+ :ref:`sphx_glr_auto_examples_plot_train_convert_predict.py`
.. raw:: html
+ Train, convert and predict with ONNX Runtime
-.. toctree::
- :hidden:
-
- /auto_examples/plot_train_convert_predict
.. raw:: html
-
-
+
-.. only :: html
+.. toctree::
+ :hidden:
- .. container:: sphx-glr-footer
- :class: sphx-glr-footer-gallery
+ /auto_examples/plot_pipeline
+ /auto_examples/plot_load_and_predict
+ /auto_examples/plot_backend
+ /auto_examples/plot_metadata
+ /auto_examples/plot_profiling
+ /auto_examples/plot_convert_pipeline_vectorizer
+ /auto_examples/plot_common_errors
+ /auto_examples/plot_train_convert_predict
- .. container:: sphx-glr-download sphx-glr-download-python
+.. only:: html
- :download:`Download all examples in Python source code: auto_examples_python.zip `
+ .. container:: sphx-glr-footer sphx-glr-footer-gallery
+ .. container:: sphx-glr-download sphx-glr-download-python
+ :download:`Download all examples in Python source code: auto_examples_python.zip `
- .. container:: sphx-glr-download sphx-glr-download-jupyter
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip `
+ :download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip `
.. only:: html
diff --git a/docs/api/python/sources/auto_examples/plot_backend.rst.txt b/docs/api/python/sources/auto_examples/plot_backend.rst.txt
index b273b7902120b..59b3152211d70 100644
--- a/docs/api/python/sources/auto_examples/plot_backend.rst.txt
+++ b/docs/api/python/sources/auto_examples/plot_backend.rst.txt
@@ -29,16 +29,15 @@ to run predictions using this runtime.
Let's use the API to compute the prediction
of a simple logistic regression model.
-.. GENERATED FROM PYTHON SOURCE LINES 17-23
+.. GENERATED FROM PYTHON SOURCE LINES 17-22
.. code-block:: default
import numpy as np
- from onnxruntime import datasets
- from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument
- import onnxruntime.backend as backend
from onnx import load
+ import onnxruntime.backend as backend
+
@@ -46,16 +45,18 @@ of a simple logistic regression model.
-.. GENERATED FROM PYTHON SOURCE LINES 24-26
+.. GENERATED FROM PYTHON SOURCE LINES 23-25
The device depends on how the package was compiled,
GPU or CPU.
-.. GENERATED FROM PYTHON SOURCE LINES 26-41
+.. GENERATED FROM PYTHON SOURCE LINES 25-42
.. code-block:: default
- from onnxruntime import get_device
+ from onnxruntime import datasets, get_device
+ from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument
+
device = get_device()
name = datasets.get_example("logreg_iris.onnx")
@@ -76,8 +77,6 @@ GPU or CPU.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
[ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: float_input for the following indices
@@ -87,12 +86,12 @@ GPU or CPU.
-.. GENERATED FROM PYTHON SOURCE LINES 42-44
+.. GENERATED FROM PYTHON SOURCE LINES 43-45
The backend can also directly load the model
without using *onnx*.
-.. GENERATED FROM PYTHON SOURCE LINES 44-54
+.. GENERATED FROM PYTHON SOURCE LINES 45-55
.. code-block:: default
@@ -112,8 +111,6 @@ without using *onnx*.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
[ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: float_input for the following indices
@@ -123,7 +120,7 @@ without using *onnx*.
-.. GENERATED FROM PYTHON SOURCE LINES 55-58
+.. GENERATED FROM PYTHON SOURCE LINES 56-59
The backend API is implemented by other frameworks
and makes it easier to switch between multiple runtimes
@@ -137,23 +134,18 @@ with the same API.
.. _sphx_glr_download_auto_examples_plot_backend.py:
+.. only:: html
-.. only :: html
-
- .. container:: sphx-glr-footer
- :class: sphx-glr-footer-example
-
-
-
- .. container:: sphx-glr-download sphx-glr-download-python
+ .. container:: sphx-glr-footer sphx-glr-footer-example
- :download:`Download Python source code: plot_backend.py `
+ .. container:: sphx-glr-download sphx-glr-download-python
+ :download:`Download Python source code: plot_backend.py `
- .. container:: sphx-glr-download sphx-glr-download-jupyter
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download Jupyter notebook: plot_backend.ipynb `
+ :download:`Download Jupyter notebook: plot_backend.ipynb `
.. only:: html
diff --git a/docs/api/python/sources/auto_examples/plot_common_errors.rst.txt b/docs/api/python/sources/auto_examples/plot_common_errors.rst.txt
index 871563380fa54..c766c513d96ca 100644
--- a/docs/api/python/sources/auto_examples/plot_common_errors.rst.txt
+++ b/docs/api/python/sources/auto_examples/plot_common_errors.rst.txt
@@ -31,13 +31,14 @@ It starts by loading the model trained in example
trained on *Iris* datasets. The model takes
a vector of dimension 2 and returns a class among three.
-.. GENERATED FROM PYTHON SOURCE LINES 18-29
+.. GENERATED FROM PYTHON SOURCE LINES 18-30
.. code-block:: default
+ import numpy
+
import onnxruntime as rt
from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument
- import numpy
from onnxruntime.datasets import get_example
example2 = get_example("logreg_iris.onnx")
@@ -53,13 +54,13 @@ a vector of dimension 2 and returns a class among three.
-.. GENERATED FROM PYTHON SOURCE LINES 30-33
+.. GENERATED FROM PYTHON SOURCE LINES 31-34
The first example fails due to *bad types*.
*onnxruntime* only expects single floats (4 bytes)
and cannot handle any other kind of floats.
-.. GENERATED FROM PYTHON SOURCE LINES 33-41
+.. GENERATED FROM PYTHON SOURCE LINES 34-42
.. code-block:: default
@@ -70,14 +71,12 @@ and cannot handle any other kind of floats.
except Exception as e:
print("Unexpected type")
print("{0}: {1}".format(type(e), e))
-
-.. rst-class:: sphx-glr-script-out
- Out:
+.. rst-class:: sphx-glr-script-out
.. code-block:: none
@@ -87,12 +86,12 @@ and cannot handle any other kind of floats.
-.. GENERATED FROM PYTHON SOURCE LINES 42-44
+.. GENERATED FROM PYTHON SOURCE LINES 43-45
The model fails to return an output if the name
is misspelled.
-.. GENERATED FROM PYTHON SOURCE LINES 44-52
+.. GENERATED FROM PYTHON SOURCE LINES 45-53
.. code-block:: default
@@ -110,8 +109,6 @@ is misspelled.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
Misspelled output name
@@ -120,12 +117,12 @@ is misspelled.
-.. GENERATED FROM PYTHON SOURCE LINES 53-55
+.. GENERATED FROM PYTHON SOURCE LINES 54-56
The output name is optional, it can be replaced by *None*
and *onnxruntime* will then return all the outputs.
-.. GENERATED FROM PYTHON SOURCE LINES 55-64
+.. GENERATED FROM PYTHON SOURCE LINES 56-65
.. code-block:: default
@@ -144,8 +141,6 @@ and *onnxruntime* will then return all the outputs.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
All outputs
@@ -154,11 +149,11 @@ and *onnxruntime* will then return all the outputs.
-.. GENERATED FROM PYTHON SOURCE LINES 65-66
+.. GENERATED FROM PYTHON SOURCE LINES 66-67
The same goes if the input name is misspelled.
-.. GENERATED FROM PYTHON SOURCE LINES 66-74
+.. GENERATED FROM PYTHON SOURCE LINES 67-75
.. code-block:: default
@@ -176,8 +171,6 @@ The same goes if the input name is misspelled.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
Misspelled input name
@@ -186,23 +179,23 @@ The same goes if the input name is misspelled.
-.. GENERATED FROM PYTHON SOURCE LINES 75-77
+.. GENERATED FROM PYTHON SOURCE LINES 76-78
*onnxruntime* does not necessarily fail if the input
dimension is a multiple of the expected input dimension.
-.. GENERATED FROM PYTHON SOURCE LINES 77-104
+.. GENERATED FROM PYTHON SOURCE LINES 78-105
.. code-block:: default
for x in [
- numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
- numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
- numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
- ]:
+ numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
+ ]:
try:
r = sess.run([output_name], {input_name: x})
print("Shape={0} and predicted labels={1}".format(x.shape, r))
@@ -210,12 +203,12 @@ dimension is a multiple of the expected input dimension.
print("ERROR with Shape={0} - {1}".format(x.shape, e))
for x in [
- numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
- numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
- numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
- numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
- ]:
+ numpy.array([1.0, 2.0, 3.0, 4.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0], [3.0, 4.0]], dtype=numpy.float32),
+ numpy.array([1.0, 2.0, 3.0], dtype=numpy.float32),
+ numpy.array([[1.0, 2.0, 3.0]], dtype=numpy.float32),
+ ]:
try:
r = sess.run(None, {input_name: x})
print("Shape={0} and predicted probabilities={1}".format(x.shape, r[1]))
@@ -228,8 +221,6 @@ dimension is a multiple of the expected input dimension.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
ERROR with Shape=(4,) - [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid rank for input: float_input Got: 1 Expected: 2 Please fix either the inputs or the model.
@@ -262,21 +253,21 @@ dimension is a multiple of the expected input dimension.
-.. GENERATED FROM PYTHON SOURCE LINES 105-107
+.. GENERATED FROM PYTHON SOURCE LINES 106-108
It does not fail either if the number of dimension
is higher than expects but produces a warning.
-.. GENERATED FROM PYTHON SOURCE LINES 107-118
+.. GENERATED FROM PYTHON SOURCE LINES 108-119
.. code-block:: default
for x in [
- numpy.array([[[1.0, 2.0], [3.0, 4.0]]], dtype=numpy.float32),
- numpy.array([[[1.0, 2.0, 3.0]]], dtype=numpy.float32),
- numpy.array([[[1.0, 2.0]], [[3.0, 4.0]]], dtype=numpy.float32),
- ]:
+ numpy.array([[[1.0, 2.0], [3.0, 4.0]]], dtype=numpy.float32),
+ numpy.array([[[1.0, 2.0, 3.0]]], dtype=numpy.float32),
+ numpy.array([[[1.0, 2.0]], [[3.0, 4.0]]], dtype=numpy.float32),
+ ]:
try:
r = sess.run([output_name], {input_name: x})
print("Shape={0} and predicted labels={1}".format(x.shape, r))
@@ -288,8 +279,6 @@ is higher than expects but produces a warning.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
ERROR with Shape=(1, 2, 2) - [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid rank for input: float_input Got: 3 Expected: 2 Please fix either the inputs or the model.
@@ -307,23 +296,18 @@ is higher than expects but produces a warning.
.. _sphx_glr_download_auto_examples_plot_common_errors.py:
+.. only:: html
-.. only :: html
-
- .. container:: sphx-glr-footer
- :class: sphx-glr-footer-example
-
-
-
- .. container:: sphx-glr-download sphx-glr-download-python
+ .. container:: sphx-glr-footer sphx-glr-footer-example
- :download:`Download Python source code: plot_common_errors.py `
+ .. container:: sphx-glr-download sphx-glr-download-python
+ :download:`Download Python source code: plot_common_errors.py `
- .. container:: sphx-glr-download sphx-glr-download-jupyter
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download Jupyter notebook: plot_common_errors.ipynb `
+ :download:`Download Jupyter notebook: plot_common_errors.ipynb `
.. only:: html
diff --git a/docs/api/python/sources/auto_examples/plot_convert_pipeline_vectorizer.rst.txt b/docs/api/python/sources/auto_examples/plot_convert_pipeline_vectorizer.rst.txt
index 8aaf14206515b..41ce8b2ad4b7a 100644
--- a/docs/api/python/sources/auto_examples/plot_convert_pipeline_vectorizer.rst.txt
+++ b/docs/api/python/sources/auto_examples/plot_convert_pipeline_vectorizer.rst.txt
@@ -35,19 +35,21 @@ Train a pipeline
The first step consists in retrieving the boston datset.
-.. GENERATED FROM PYTHON SOURCE LINES 22-32
+.. GENERATED FROM PYTHON SOURCE LINES 22-34
.. code-block:: default
import pandas
from sklearn.datasets import load_boston
+
boston = load_boston()
X, y = boston.data, boston.target
from sklearn.model_selection import train_test_split
+
X_train, X_test, y_train, y_test = train_test_split(X, y)
- X_train_dict = pandas.DataFrame(X_train[:,1:]).T.to_dict().values()
- X_test_dict = pandas.DataFrame(X_test[:,1:]).T.to_dict().values()
+ X_train_dict = pandas.DataFrame(X_train[:, 1:]).T.to_dict().values()
+ X_test_dict = pandas.DataFrame(X_test[:, 1:]).T.to_dict().values()
@@ -55,8 +57,6 @@ The first step consists in retrieving the boston datset.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
/home/runner/.local/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function load_boston is deprecated; `load_boston` is deprecated in 1.0 and will be removed in 1.2.
@@ -74,7 +74,6 @@ The first step consists in retrieving the boston datset.
import pandas as pd
import numpy as np
-
data_url = "http://lib.stat.cmu.edu/datasets/boston"
raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None)
data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
@@ -93,52 +92,49 @@ The first step consists in retrieving the boston datset.
housing = fetch_openml(name="house_prices", as_frame=True)
for the Ames housing dataset.
-
warnings.warn(msg, category=FutureWarning)
-.. GENERATED FROM PYTHON SOURCE LINES 33-34
+.. GENERATED FROM PYTHON SOURCE LINES 35-36
We create a pipeline.
-.. GENERATED FROM PYTHON SOURCE LINES 34-44
+.. GENERATED FROM PYTHON SOURCE LINES 36-45
.. code-block:: default
- from sklearn.pipeline import make_pipeline
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.feature_extraction import DictVectorizer
- pipe = make_pipeline(
- DictVectorizer(sparse=False),
- GradientBoostingRegressor())
-
- pipe.fit(X_train_dict, y_train)
-
-
+ from sklearn.pipeline import make_pipeline
+ pipe = make_pipeline(DictVectorizer(sparse=False), GradientBoostingRegressor())
+ pipe.fit(X_train_dict, y_train)
-.. rst-class:: sphx-glr-script-out
- Out:
- .. code-block:: none
- Pipeline(steps=[('dictvectorizer', DictVectorizer(sparse=False)),
- ('gradientboostingregressor', GradientBoostingRegressor())])
+.. raw:: html
+
+
+
-.. GENERATED FROM PYTHON SOURCE LINES 45-47
+.. GENERATED FROM PYTHON SOURCE LINES 46-48
We compute the prediction on the test set
and we show the confusion matrix.
-.. GENERATED FROM PYTHON SOURCE LINES 47-52
+.. GENERATED FROM PYTHON SOURCE LINES 48-53
.. code-block:: default
@@ -153,34 +149,32 @@ and we show the confusion matrix.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
- 0.9209977605173356
+ 0.8843586896936388
-.. GENERATED FROM PYTHON SOURCE LINES 53-59
+.. GENERATED FROM PYTHON SOURCE LINES 54-60
Conversion to ONNX format
+++++++++++++++++++++++++
-We use module
+We use module
`sklearn-onnx `_
to convert the model into ONNX format.
-.. GENERATED FROM PYTHON SOURCE LINES 59-69
+.. GENERATED FROM PYTHON SOURCE LINES 60-70
.. code-block:: default
from skl2onnx import convert_sklearn
- from skl2onnx.common.data_types import FloatTensorType, Int64TensorType, DictionaryType, SequenceType
+ from skl2onnx.common.data_types import DictionaryType, FloatTensorType, Int64TensorType, SequenceType
# initial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))]
- initial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))]
+ initial_type = [("float_input", DictionaryType(Int64TensorType([1]), FloatTensorType([])))]
onx = convert_sklearn(pipe, initial_types=initial_type)
with open("pipeline_vectorize.onnx", "wb") as f:
f.write(onx.SerializeToString())
@@ -192,12 +186,12 @@ to convert the model into ONNX format.
-.. GENERATED FROM PYTHON SOURCE LINES 70-72
+.. GENERATED FROM PYTHON SOURCE LINES 71-73
We load the model with ONNX Runtime and look at
its input and output.
-.. GENERATED FROM PYTHON SOURCE LINES 72-82
+.. GENERATED FROM PYTHON SOURCE LINES 73-84
.. code-block:: default
@@ -207,6 +201,7 @@ its input and output.
sess = rt.InferenceSession("pipeline_vectorize.onnx", providers=rt.get_available_providers())
import numpy
+
inp, out = sess.get_inputs()[0], sess.get_outputs()[0]
print("input name='{}' and shape={} and type={}".format(inp.name, inp.shape, inp.type))
print("output name='{}' and shape={} and type={}".format(out.name, out.shape, out.type))
@@ -217,8 +212,6 @@ its input and output.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
input name='float_input' and shape=[] and type=map(int64,tensor(float))
@@ -227,12 +220,12 @@ its input and output.
-.. GENERATED FROM PYTHON SOURCE LINES 83-85
+.. GENERATED FROM PYTHON SOURCE LINES 85-87
We compute the predictions.
We could do that in one call:
-.. GENERATED FROM PYTHON SOURCE LINES 85-91
+.. GENERATED FROM PYTHON SOURCE LINES 87-93
.. code-block:: default
@@ -248,8 +241,6 @@ We could do that in one call:
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
[ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Unexpected input data type. Actual: ((seq(map(int64,tensor(float))))) , expected: ((map(int64,tensor(float))))
@@ -257,12 +248,12 @@ We could do that in one call:
-.. GENERATED FROM PYTHON SOURCE LINES 92-94
+.. GENERATED FROM PYTHON SOURCE LINES 94-96
But it fails because, in case of a DictVectorizer,
ONNX Runtime expects one observation at a time.
-.. GENERATED FROM PYTHON SOURCE LINES 94-96
+.. GENERATED FROM PYTHON SOURCE LINES 96-98
.. code-block:: default
@@ -275,11 +266,11 @@ ONNX Runtime expects one observation at a time.
-.. GENERATED FROM PYTHON SOURCE LINES 97-98
+.. GENERATED FROM PYTHON SOURCE LINES 99-100
We compare them to the model's ones.
-.. GENERATED FROM PYTHON SOURCE LINES 98-100
+.. GENERATED FROM PYTHON SOURCE LINES 100-102
.. code-block:: default
@@ -291,16 +282,14 @@ We compare them to the model's ones.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
- 0.9999999999999366
+ 0.9999999999999561
-.. GENERATED FROM PYTHON SOURCE LINES 101-103
+.. GENERATED FROM PYTHON SOURCE LINES 103-105
Very similar. *ONNX Runtime* uses floats instead of doubles,
that explains the small discrepencies.
@@ -308,28 +297,23 @@ that explains the small discrepencies.
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 0 minutes 0.966 seconds)
+ **Total running time of the script:** ( 0 minutes 0.956 seconds)
.. _sphx_glr_download_auto_examples_plot_convert_pipeline_vectorizer.py:
+.. only:: html
-.. only :: html
-
- .. container:: sphx-glr-footer
- :class: sphx-glr-footer-example
-
-
-
- .. container:: sphx-glr-download sphx-glr-download-python
+ .. container:: sphx-glr-footer sphx-glr-footer-example
- :download:`Download Python source code: plot_convert_pipeline_vectorizer.py `
+ .. container:: sphx-glr-download sphx-glr-download-python
+ :download:`Download Python source code: plot_convert_pipeline_vectorizer.py `
- .. container:: sphx-glr-download sphx-glr-download-jupyter
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download Jupyter notebook: plot_convert_pipeline_vectorizer.ipynb `
+ :download:`Download Jupyter notebook: plot_convert_pipeline_vectorizer.ipynb `
.. only:: html
diff --git a/docs/api/python/sources/auto_examples/plot_load_and_predict.rst.txt b/docs/api/python/sources/auto_examples/plot_load_and_predict.rst.txt
index 880209ef5fb5b..801638534aaed 100644
--- a/docs/api/python/sources/auto_examples/plot_load_and_predict.rst.txt
+++ b/docs/api/python/sources/auto_examples/plot_load_and_predict.rst.txt
@@ -27,13 +27,14 @@ This example demonstrates how to load a model and compute
the output for an input vector. It also shows how to
retrieve the definition of its inputs and outputs.
-.. GENERATED FROM PYTHON SOURCE LINES 14-19
+.. GENERATED FROM PYTHON SOURCE LINES 14-20
.. code-block:: default
- import onnxruntime as rt
import numpy
+
+ import onnxruntime as rt
from onnxruntime.datasets import get_example
@@ -43,12 +44,12 @@ retrieve the definition of its inputs and outputs.
-.. GENERATED FROM PYTHON SOURCE LINES 20-22
+.. GENERATED FROM PYTHON SOURCE LINES 21-23
Let's load a very simple model.
The model is available on github `onnx...test_sigmoid `_.
-.. GENERATED FROM PYTHON SOURCE LINES 22-26
+.. GENERATED FROM PYTHON SOURCE LINES 23-27
.. code-block:: default
@@ -63,11 +64,11 @@ The model is available on github `onnx...test_sigmoid `
+ .. container:: sphx-glr-download sphx-glr-download-python
+ :download:`Download Python source code: plot_load_and_predict.py `
- .. container:: sphx-glr-download sphx-glr-download-jupyter
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download Jupyter notebook: plot_load_and_predict.ipynb `
+ :download:`Download Jupyter notebook: plot_load_and_predict.ipynb `
.. only:: html
diff --git a/docs/api/python/sources/auto_examples/plot_metadata.rst.txt b/docs/api/python/sources/auto_examples/plot_metadata.rst.txt
index 8dd7067d02914..52e8201fc7122 100644
--- a/docs/api/python/sources/auto_examples/plot_metadata.rst.txt
+++ b/docs/api/python/sources/auto_examples/plot_metadata.rst.txt
@@ -29,15 +29,17 @@ Let's see how to do that with a simple
logistic regression model trained with
*scikit-learn* and converted with *sklearn-onnx*.
-.. GENERATED FROM PYTHON SOURCE LINES 16-31
+.. GENERATED FROM PYTHON SOURCE LINES 16-33
.. code-block:: default
from onnxruntime.datasets import get_example
+
example = get_example("logreg_iris.onnx")
import onnx
+
model = onnx.load(example)
print("doc_string={}".format(model.doc_string))
@@ -54,8 +56,6 @@ logistic regression model trained with
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
doc_string=
@@ -69,16 +69,17 @@ logistic regression model trained with
-.. GENERATED FROM PYTHON SOURCE LINES 32-33
+.. GENERATED FROM PYTHON SOURCE LINES 34-35
With *ONNX Runtime*:
-.. GENERATED FROM PYTHON SOURCE LINES 33-44
+.. GENERATED FROM PYTHON SOURCE LINES 35-47
.. code-block:: default
import onnxruntime as rt
+
sess = rt.InferenceSession(example, providers=rt.get_available_providers())
meta = sess.get_modelmeta()
@@ -94,8 +95,6 @@ With *ONNX Runtime*:
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
custom_metadata_map={}
@@ -111,28 +110,23 @@ With *ONNX Runtime*:
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 0 minutes 0.005 seconds)
+ **Total running time of the script:** ( 0 minutes 0.003 seconds)
.. _sphx_glr_download_auto_examples_plot_metadata.py:
+.. only:: html
-.. only :: html
-
- .. container:: sphx-glr-footer
- :class: sphx-glr-footer-example
-
-
-
- .. container:: sphx-glr-download sphx-glr-download-python
+ .. container:: sphx-glr-footer sphx-glr-footer-example
- :download:`Download Python source code: plot_metadata.py `
+ .. container:: sphx-glr-download sphx-glr-download-python
+ :download:`Download Python source code: plot_metadata.py `
- .. container:: sphx-glr-download sphx-glr-download-jupyter
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download Jupyter notebook: plot_metadata.ipynb `
+ :download:`Download Jupyter notebook: plot_metadata.ipynb `
.. only:: html
diff --git a/docs/api/python/sources/auto_examples/plot_pipeline.rst.txt b/docs/api/python/sources/auto_examples/plot_pipeline.rst.txt
index c71429c4141c0..d0e0bb5627078 100644
--- a/docs/api/python/sources/auto_examples/plot_pipeline.rst.txt
+++ b/docs/api/python/sources/auto_examples/plot_pipeline.rst.txt
@@ -35,18 +35,20 @@ Retrieve a model in JSON format
That's the most simple way.
-.. GENERATED FROM PYTHON SOURCE LINES 22-32
+.. GENERATED FROM PYTHON SOURCE LINES 22-34
.. code-block:: default
from onnxruntime.datasets import get_example
+
example1 = get_example("mul_1.onnx")
import onnx
+
model = onnx.load(example1) # model is a ModelProto protobuf message
- print(model)
+ print(model)
@@ -55,8 +57,6 @@ That's the most simple way.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
ir_version: 3
@@ -124,7 +124,7 @@ That's the most simple way.
-.. GENERATED FROM PYTHON SOURCE LINES 33-39
+.. GENERATED FROM PYTHON SOURCE LINES 35-41
Draw a model with ONNX
++++++++++++++++++++++
@@ -133,15 +133,16 @@ included in *onnx* package.
We use *onnx* to load the model
in a different way than before.
-.. GENERATED FROM PYTHON SOURCE LINES 39-47
+.. GENERATED FROM PYTHON SOURCE LINES 41-50
.. code-block:: default
from onnx import ModelProto
+
model = ModelProto()
- with open(example1, 'rb') as fid:
+ with open(example1, "rb") as fid:
content = fid.read()
model.ParseFromString(content)
@@ -152,17 +153,19 @@ in a different way than before.
-.. GENERATED FROM PYTHON SOURCE LINES 48-49
+.. GENERATED FROM PYTHON SOURCE LINES 51-52
We convert it into a graph.
-.. GENERATED FROM PYTHON SOURCE LINES 49-54
+.. GENERATED FROM PYTHON SOURCE LINES 52-59
.. code-block:: default
- from onnx.tools.net_drawer import GetPydotGraph, GetOpNodeProducer
- pydot_graph = GetPydotGraph(model.graph, name=model.graph.name, rankdir="LR",
- node_producer=GetOpNodeProducer("docstring"))
+ from onnx.tools.net_drawer import GetOpNodeProducer, GetPydotGraph
+
+ pydot_graph = GetPydotGraph(
+ model.graph, name=model.graph.name, rankdir="LR", node_producer=GetOpNodeProducer("docstring")
+ )
pydot_graph.write_dot("graph.dot")
@@ -172,24 +175,23 @@ We convert it into a graph.
-.. GENERATED FROM PYTHON SOURCE LINES 55-56
+.. GENERATED FROM PYTHON SOURCE LINES 60-61
Then into an image
-.. GENERATED FROM PYTHON SOURCE LINES 56-59
+.. GENERATED FROM PYTHON SOURCE LINES 61-65
.. code-block:: default
import os
- os.system('dot -O -Tpng graph.dot')
+ os.system("dot -O -Tpng graph.dot")
-.. rst-class:: sphx-glr-script-out
- Out:
+.. rst-class:: sphx-glr-script-out
.. code-block:: none
@@ -198,26 +200,21 @@ Then into an image
-.. GENERATED FROM PYTHON SOURCE LINES 60-61
+.. GENERATED FROM PYTHON SOURCE LINES 66-67
Which we display...
-.. GENERATED FROM PYTHON SOURCE LINES 61-70
+.. GENERATED FROM PYTHON SOURCE LINES 67-71
.. code-block:: default
import matplotlib.pyplot as plt
+
image = plt.imread("graph.dot.png")
plt.imshow(image)
-
-
-
-
-
-
.. image-sg:: /auto_examples/images/sphx_glr_plot_pipeline_001.png
:alt: plot pipeline
:srcset: /auto_examples/images/sphx_glr_plot_pipeline_001.png
@@ -226,40 +223,33 @@ Which we display...
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
-
+
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 0 minutes 0.196 seconds)
+ **Total running time of the script:** ( 0 minutes 0.218 seconds)
.. _sphx_glr_download_auto_examples_plot_pipeline.py:
+.. only:: html
-.. only :: html
-
- .. container:: sphx-glr-footer
- :class: sphx-glr-footer-example
-
-
-
- .. container:: sphx-glr-download sphx-glr-download-python
+ .. container:: sphx-glr-footer sphx-glr-footer-example
- :download:`Download Python source code: plot_pipeline.py `
+ .. container:: sphx-glr-download sphx-glr-download-python
+ :download:`Download Python source code: plot_pipeline.py `
- .. container:: sphx-glr-download sphx-glr-download-jupyter
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download Jupyter notebook: plot_pipeline.ipynb `
+ :download:`Download Jupyter notebook: plot_pipeline.ipynb `
.. only:: html
diff --git a/docs/api/python/sources/auto_examples/plot_profiling.rst.txt b/docs/api/python/sources/auto_examples/plot_profiling.rst.txt
index b5042b610ddd2..5bfc305bd1a55 100644
--- a/docs/api/python/sources/auto_examples/plot_profiling.rst.txt
+++ b/docs/api/python/sources/auto_examples/plot_profiling.rst.txt
@@ -26,13 +26,14 @@ Profile the execution of a simple model
*ONNX Runtime* can profile the execution of the model.
This example shows how to interpret the results.
-.. GENERATED FROM PYTHON SOURCE LINES 14-32
+.. GENERATED FROM PYTHON SOURCE LINES 14-31
.. code-block:: default
+ import numpy
import onnx
+
import onnxruntime as rt
- import numpy
from onnxruntime.datasets import get_example
@@ -53,13 +54,11 @@ This example shows how to interpret the results.
-
-
-.. GENERATED FROM PYTHON SOURCE LINES 33-34
+.. GENERATED FROM PYTHON SOURCE LINES 32-33
Let's load a very simple model and compute some prediction.
-.. GENERATED FROM PYTHON SOURCE LINES 34-45
+.. GENERATED FROM PYTHON SOURCE LINES 33-44
.. code-block:: default
@@ -80,8 +79,6 @@ Let's load a very simple model and compute some prediction.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
[array([[ 1., 4.],
@@ -91,12 +88,12 @@ Let's load a very simple model and compute some prediction.
-.. GENERATED FROM PYTHON SOURCE LINES 46-48
+.. GENERATED FROM PYTHON SOURCE LINES 45-47
We need to enable to profiling
before running the predictions.
-.. GENERATED FROM PYTHON SOURCE LINES 48-60
+.. GENERATED FROM PYTHON SOURCE LINES 47-59
.. code-block:: default
@@ -118,58 +115,53 @@ before running the predictions.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
- onnxruntime_profile__2022-01-04_17-09-55.json
+ onnxruntime_profile__2022-08-16_04-44-08.json
-.. GENERATED FROM PYTHON SOURCE LINES 61-63
+.. GENERATED FROM PYTHON SOURCE LINES 60-62
The results are stored un a file in JSON format.
Let's see what it contains.
-.. GENERATED FROM PYTHON SOURCE LINES 63-71
+.. GENERATED FROM PYTHON SOURCE LINES 62-69
.. code-block:: default
import json
+
with open(prof_file, "r") as f:
sess_time = json.load(f)
import pprint
- pprint.pprint(sess_time)
-
-
+ pprint.pprint(sess_time)
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
[{'args': {},
'cat': 'Session',
- 'dur': 56,
+ 'dur': 67,
'name': 'model_loading_array',
'ph': 'X',
- 'pid': 3089,
- 'tid': 3089,
+ 'pid': 3111,
+ 'tid': 3111,
'ts': 1},
{'args': {},
'cat': 'Session',
- 'dur': 240,
+ 'dur': 236,
'name': 'session_initialization',
'ph': 'X',
- 'pid': 3089,
- 'tid': 3089,
- 'ts': 71}]
+ 'pid': 3111,
+ 'tid': 3111,
+ 'ts': 85}]
@@ -177,28 +169,23 @@ Let's see what it contains.
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 0 minutes 0.007 seconds)
+ **Total running time of the script:** ( 0 minutes 0.005 seconds)
.. _sphx_glr_download_auto_examples_plot_profiling.py:
+.. only:: html
-.. only :: html
-
- .. container:: sphx-glr-footer
- :class: sphx-glr-footer-example
-
-
-
- .. container:: sphx-glr-download sphx-glr-download-python
+ .. container:: sphx-glr-footer sphx-glr-footer-example
- :download:`Download Python source code: plot_profiling.py `
+ .. container:: sphx-glr-download sphx-glr-download-python
+ :download:`Download Python source code: plot_profiling.py `
- .. container:: sphx-glr-download sphx-glr-download-jupyter
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download Jupyter notebook: plot_profiling.ipynb `
+ :download:`Download Jupyter notebook: plot_profiling.ipynb `
.. only:: html
diff --git a/docs/api/python/sources/auto_examples/plot_train_convert_predict.rst.txt b/docs/api/python/sources/auto_examples/plot_train_convert_predict.rst.txt
index 1eee02ac44ada..92eba06dd1d1d 100644
--- a/docs/api/python/sources/auto_examples/plot_train_convert_predict.rst.txt
+++ b/docs/api/python/sources/auto_examples/plot_train_convert_predict.rst.txt
@@ -35,16 +35,18 @@ Train a logistic regression
The first step consists in retrieving the iris datset.
-.. GENERATED FROM PYTHON SOURCE LINES 23-31
+.. GENERATED FROM PYTHON SOURCE LINES 23-33
.. code-block:: default
from sklearn.datasets import load_iris
+
iris = load_iris()
X, y = iris.data, iris.target
from sklearn.model_selection import train_test_split
+
X_train, X_test, y_train, y_test = train_test_split(X, y)
@@ -54,16 +56,17 @@ The first step consists in retrieving the iris datset.
-.. GENERATED FROM PYTHON SOURCE LINES 32-33
+.. GENERATED FROM PYTHON SOURCE LINES 34-35
Then we fit a model.
-.. GENERATED FROM PYTHON SOURCE LINES 33-38
+.. GENERATED FROM PYTHON SOURCE LINES 35-41
.. code-block:: default
from sklearn.linear_model import LogisticRegression
+
clr = LogisticRegression()
clr.fit(X_train, y_train)
@@ -71,23 +74,21 @@ Then we fit a model.
-.. rst-class:: sphx-glr-script-out
-
- Out:
- .. code-block:: none
+.. raw:: html
+
+
+
- LogisticRegression()
-
-
-
-.. GENERATED FROM PYTHON SOURCE LINES 39-41
+.. GENERATED FROM PYTHON SOURCE LINES 42-44
We compute the prediction on the test set
and we show the confusion matrix.
-.. GENERATED FROM PYTHON SOURCE LINES 41-46
+.. GENERATED FROM PYTHON SOURCE LINES 44-49
.. code-block:: default
@@ -102,27 +103,25 @@ and we show the confusion matrix.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
- [[13 0 0]
+ [[17 0 0]
[ 0 10 1]
- [ 0 0 14]]
+ [ 0 0 10]]
-.. GENERATED FROM PYTHON SOURCE LINES 47-53
+.. GENERATED FROM PYTHON SOURCE LINES 50-56
Conversion to ONNX format
+++++++++++++++++++++++++
-We use module
+We use module
`sklearn-onnx `_
to convert the model into ONNX format.
-.. GENERATED FROM PYTHON SOURCE LINES 53-62
+.. GENERATED FROM PYTHON SOURCE LINES 56-65
.. code-block:: default
@@ -130,7 +129,7 @@ to convert the model into ONNX format.
from skl2onnx import convert_sklearn
from skl2onnx.common.data_types import FloatTensorType
- initial_type = [('float_input', FloatTensorType([None, 4]))]
+ initial_type = [("float_input", FloatTensorType([None, 4]))]
onx = convert_sklearn(clr, initial_types=initial_type)
with open("logreg_iris.onnx", "wb") as f:
f.write(onx.SerializeToString())
@@ -142,23 +141,22 @@ to convert the model into ONNX format.
-.. GENERATED FROM PYTHON SOURCE LINES 63-65
+.. GENERATED FROM PYTHON SOURCE LINES 66-68
We load the model with ONNX Runtime and look at
its input and output.
-.. GENERATED FROM PYTHON SOURCE LINES 65-74
+.. GENERATED FROM PYTHON SOURCE LINES 68-76
.. code-block:: default
import onnxruntime as rt
+
sess = rt.InferenceSession("logreg_iris.onnx", providers=rt.get_available_providers())
- print("input name='{}' and shape={}".format(
- sess.get_inputs()[0].name, sess.get_inputs()[0].shape))
- print("output name='{}' and shape={}".format(
- sess.get_outputs()[0].name, sess.get_outputs()[0].shape))
+ print("input name='{}' and shape={}".format(sess.get_inputs()[0].name, sess.get_inputs()[0].shape))
+ print("output name='{}' and shape={}".format(sess.get_outputs()[0].name, sess.get_outputs()[0].shape))
@@ -166,8 +164,6 @@ its input and output.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
input name='float_input' and shape=[None, 4]
@@ -176,11 +172,11 @@ its input and output.
-.. GENERATED FROM PYTHON SOURCE LINES 75-76
+.. GENERATED FROM PYTHON SOURCE LINES 77-78
We compute the predictions.
-.. GENERATED FROM PYTHON SOURCE LINES 76-84
+.. GENERATED FROM PYTHON SOURCE LINES 78-87
.. code-block:: default
@@ -189,6 +185,7 @@ We compute the predictions.
label_name = sess.get_outputs()[0].name
import numpy
+
pred_onx = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]
print(confusion_matrix(pred, pred_onx))
@@ -198,18 +195,16 @@ We compute the predictions.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
- [[13 0 0]
+ [[17 0 0]
[ 0 10 0]
- [ 0 0 15]]
+ [ 0 0 11]]
-.. GENERATED FROM PYTHON SOURCE LINES 85-94
+.. GENERATED FROM PYTHON SOURCE LINES 88-97
The prediction are perfectly identical.
@@ -221,7 +216,7 @@ relevant metrics such as the ROC Curve.
Let's see how to get them first with
scikit-learn.
-.. GENERATED FROM PYTHON SOURCE LINES 94-98
+.. GENERATED FROM PYTHON SOURCE LINES 97-101
.. code-block:: default
@@ -235,23 +230,21 @@ scikit-learn.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
- [[2.95951945e-05 5.69800366e-02 9.42990368e-01]
- [1.84923705e-05 3.93636566e-02 9.60617851e-01]
- [1.30004554e-02 8.03678159e-01 1.83321386e-01]]
+ [[1.82164782e-01 8.13598178e-01 4.23703980e-03]
+ [8.12021102e-04 3.37134524e-01 6.62053455e-01]
+ [1.20249493e-06 1.74038501e-02 9.82594947e-01]]
-.. GENERATED FROM PYTHON SOURCE LINES 99-101
+.. GENERATED FROM PYTHON SOURCE LINES 102-104
And then with ONNX Runtime.
-The probabilies appear to be
+The probabilies appear to be
-.. GENERATED FROM PYTHON SOURCE LINES 101-108
+.. GENERATED FROM PYTHON SOURCE LINES 104-112
.. code-block:: default
@@ -260,6 +253,7 @@ The probabilies appear to be
prob_rt = sess.run([prob_name], {input_name: X_test.astype(numpy.float32)})[0]
import pprint
+
pprint.pprint(prob_rt[0:3])
@@ -268,27 +262,26 @@ The probabilies appear to be
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
- [{0: 2.9595235901069827e-05, 1: 0.05698008090257645, 2: 0.9429903030395508},
- {0: 1.8492364688427188e-05, 1: 0.03936365991830826, 2: 0.9606178402900696},
- {0: 0.013000461272895336, 1: 0.8036782741546631, 2: 0.1833212822675705}]
+ [{0: 0.18216472864151, 1: 0.8135982751846313, 2: 0.0042370399460196495},
+ {0: 0.0008120210259221494, 1: 0.3371346592903137, 2: 0.6620532870292664},
+ {0: 1.2024959232803667e-06, 1: 0.01740385964512825, 2: 0.9825949668884277}]
-.. GENERATED FROM PYTHON SOURCE LINES 109-110
+.. GENERATED FROM PYTHON SOURCE LINES 113-114
Let's benchmark.
-.. GENERATED FROM PYTHON SOURCE LINES 110-126
+.. GENERATED FROM PYTHON SOURCE LINES 114-132
.. code-block:: default
from timeit import Timer
+
def speed(inst, number=10, repeat=20):
timer = Timer(inst, globals=globals())
raw = numpy.array(timer.repeat(repeat, number=number))
@@ -297,6 +290,7 @@ Let's benchmark.
print("Average %1.3g min=%1.3g max=%1.3g" % (ave, mi, ma))
return ave
+
print("Execution time for clr.predict")
speed("clr.predict(X_test)")
@@ -309,44 +303,46 @@ Let's benchmark.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
Execution time for clr.predict
- Average 4.38e-05 min=4.25e-05 max=6.07e-05
+ Average 4.46e-05 min=4.3e-05 max=5.6e-05
Execution time for ONNX Runtime
- Average 1.97e-05 min=1.92e-05 max=2.46e-05
+ Average 1.84e-05 min=1.78e-05 max=2.5e-05
- 1.9671264999914226e-05
+ 1.838059500016698e-05
-.. GENERATED FROM PYTHON SOURCE LINES 127-130
+.. GENERATED FROM PYTHON SOURCE LINES 133-136
Let's benchmark a scenario similar to what a webservice
experiences: the model has to do one prediction at a time
as opposed to a batch of prediction.
-.. GENERATED FROM PYTHON SOURCE LINES 130-148
+.. GENERATED FROM PYTHON SOURCE LINES 136-158
.. code-block:: default
+
def loop(X_test, fct, n=None):
nrow = X_test.shape[0]
if n is None:
n = nrow
for i in range(0, n):
im = i % nrow
- fct(X_test[im: im+1])
+ fct(X_test[im : im + 1])
+
print("Execution time for clr.predict")
speed("loop(X_test, clr.predict, 100)")
+
def sess_predict(x):
return sess.run([label_name], {input_name: x.astype(numpy.float32)})[0]
+
print("Execution time for sess_predict")
speed("loop(X_test, sess_predict, 100)")
@@ -356,24 +352,22 @@ as opposed to a batch of prediction.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
Execution time for clr.predict
- Average 0.00404 min=0.00402 max=0.00409
+ Average 0.0042 min=0.00418 max=0.00428
Execution time for sess_predict
- Average 0.000881 min=0.000874 max=0.000912
+ Average 0.000862 min=0.000856 max=0.000878
- 0.0008813192099997735
+ 0.0008617829299998903
-.. GENERATED FROM PYTHON SOURCE LINES 149-150
+.. GENERATED FROM PYTHON SOURCE LINES 159-160
Let's do the same for the probabilities.
-.. GENERATED FROM PYTHON SOURCE LINES 150-160
+.. GENERATED FROM PYTHON SOURCE LINES 160-172
.. code-block:: default
@@ -381,9 +375,11 @@ Let's do the same for the probabilities.
print("Execution time for predict_proba")
speed("loop(X_test, clr.predict_proba, 100)")
+
def sess_predict_proba(x):
return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]
+
print("Execution time for sess_predict_proba")
speed("loop(X_test, sess_predict_proba, 100)")
@@ -393,42 +389,41 @@ Let's do the same for the probabilities.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
Execution time for predict_proba
- Average 0.00599 min=0.00597 max=0.00606
+ Average 0.00617 min=0.00615 max=0.0062
Execution time for sess_predict_proba
- Average 0.000883 min=0.000876 max=0.000916
+ Average 0.000887 min=0.00088 max=0.000915
- 0.0008830492349999729
+ 0.0008867338849996997
-.. GENERATED FROM PYTHON SOURCE LINES 161-165
+.. GENERATED FROM PYTHON SOURCE LINES 173-177
-This second comparison is better as
+This second comparison is better as
ONNX Runtime, in this experience,
computes the label and the probabilities
in every case.
-.. GENERATED FROM PYTHON SOURCE LINES 167-171
+.. GENERATED FROM PYTHON SOURCE LINES 179-183
Benchmark with RandomForest
+++++++++++++++++++++++++++
We first train and save a model in ONNX format.
-.. GENERATED FROM PYTHON SOURCE LINES 171-180
+.. GENERATED FROM PYTHON SOURCE LINES 183-193
.. code-block:: default
from sklearn.ensemble import RandomForestClassifier
+
rf = RandomForestClassifier()
rf.fit(X_train, y_train)
- initial_type = [('float_input', FloatTensorType([1, 4]))]
+ initial_type = [("float_input", FloatTensorType([1, 4]))]
onx = convert_sklearn(rf, initial_types=initial_type)
with open("rf_iris.onnx", "wb") as f:
f.write(onx.SerializeToString())
@@ -440,20 +435,22 @@ We first train and save a model in ONNX format.
-.. GENERATED FROM PYTHON SOURCE LINES 181-182
+.. GENERATED FROM PYTHON SOURCE LINES 194-195
We compare.
-.. GENERATED FROM PYTHON SOURCE LINES 182-194
+.. GENERATED FROM PYTHON SOURCE LINES 195-209
.. code-block:: default
sess = rt.InferenceSession("rf_iris.onnx", providers=rt.get_available_providers())
+
def sess_predict_proba_rf(x):
return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]
+
print("Execution time for predict_proba")
speed("loop(X_test, rf.predict_proba, 100)")
@@ -466,50 +463,50 @@ We compare.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
Execution time for predict_proba
- Average 0.717 min=0.715 max=0.72
+ Average 0.723 min=0.721 max=0.729
Execution time for sess_predict_proba
- Average 0.00108 min=0.00107 max=0.00111
+ Average 0.00103 min=0.00102 max=0.00106
- 0.0010817126199989956
+ 0.0010315913400006592
-.. GENERATED FROM PYTHON SOURCE LINES 195-196
+.. GENERATED FROM PYTHON SOURCE LINES 210-211
Let's see with different number of trees.
-.. GENERATED FROM PYTHON SOURCE LINES 196-223
+.. GENERATED FROM PYTHON SOURCE LINES 211-240
.. code-block:: default
measures = []
- for n_trees in range(5, 51, 5):
+ for n_trees in range(5, 51, 5):
print(n_trees)
rf = RandomForestClassifier(n_estimators=n_trees)
rf.fit(X_train, y_train)
- initial_type = [('float_input', FloatTensorType([1, 4]))]
+ initial_type = [("float_input", FloatTensorType([1, 4]))]
onx = convert_sklearn(rf, initial_types=initial_type)
with open("rf_iris_%d.onnx" % n_trees, "wb") as f:
f.write(onx.SerializeToString())
sess = rt.InferenceSession("rf_iris_%d.onnx" % n_trees, providers=rt.get_available_providers())
+
def sess_predict_proba_loop(x):
return sess.run([prob_name], {input_name: x.astype(numpy.float32)})[0]
+
tsk = speed("loop(X_test, rf.predict_proba, 100)", number=5, repeat=5)
trt = speed("loop(X_test, sess_predict_proba_loop, 100)", number=5, repeat=5)
- measures.append({'n_trees': n_trees, 'sklearn': tsk, 'rt': trt})
+ measures.append({"n_trees": n_trees, "sklearn": tsk, "rt": trt})
from pandas import DataFrame
+
df = DataFrame(measures)
ax = df.plot(x="n_trees", y="sklearn", label="scikit-learn", c="blue", logy=True)
- df.plot(x="n_trees", y="rt", label="onnxruntime",
- ax=ax, c="green", logy=True)
+ df.plot(x="n_trees", y="rt", label="onnxruntime", ax=ax, c="green", logy=True)
ax.set_xlabel("Number of trees")
ax.set_ylabel("Prediction time (s)")
ax.set_title("Speed comparison between scikit-learn and ONNX Runtime\nFor a random forest on Iris dataset")
@@ -525,70 +522,63 @@ Let's see with different number of trees.
.. rst-class:: sphx-glr-script-out
- Out:
-
.. code-block:: none
5
- Average 0.0637 min=0.0636 max=0.0639
- Average 0.000869 min=0.000857 max=0.000899
+ Average 0.0519 min=0.0519 max=0.0521
+ Average 0.000867 min=0.000856 max=0.000898
10
- Average 0.0982 min=0.098 max=0.0987
- Average 0.000884 min=0.000873 max=0.00091
+ Average 0.0872 min=0.0871 max=0.0875
+ Average 0.000881 min=0.000877 max=0.000893
15
- Average 0.133 min=0.133 max=0.133
- Average 0.000895 min=0.000885 max=0.000921
+ Average 0.123 min=0.122 max=0.123
+ Average 0.000908 min=0.000896 max=0.000938
20
- Average 0.168 min=0.167 max=0.168
- Average 0.000915 min=0.000907 max=0.00094
+ Average 0.158 min=0.158 max=0.158
+ Average 0.000902 min=0.000896 max=0.000918
25
- Average 0.202 min=0.201 max=0.203
- Average 0.000921 min=0.000913 max=0.000948
+ Average 0.193 min=0.193 max=0.193
+ Average 0.000929 min=0.000914 max=0.000961
30
- Average 0.236 min=0.236 max=0.237
- Average 0.000922 min=0.000914 max=0.000948
+ Average 0.228 min=0.228 max=0.229
+ Average 0.000927 min=0.000915 max=0.000948
35
- Average 0.271 min=0.271 max=0.271
- Average 0.000941 min=0.000928 max=0.000967
+ Average 0.263 min=0.263 max=0.264
+ Average 0.000946 min=0.000935 max=0.000978
40
- Average 0.305 min=0.305 max=0.305
- Average 0.000948 min=0.000934 max=0.000977
+ Average 0.298 min=0.298 max=0.299
+ Average 0.000952 min=0.000943 max=0.000972
45
- Average 0.34 min=0.339 max=0.34
- Average 0.000983 min=0.000972 max=0.00101
+ Average 0.334 min=0.333 max=0.335
+ Average 0.000953 min=0.000943 max=0.000985
50
- Average 0.375 min=0.374 max=0.375
- Average 0.000972 min=0.000966 max=0.000992
+ Average 0.369 min=0.369 max=0.371
+ Average 0.000981 min=0.000973 max=0.00101
-
+
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 3 minutes 22.159 seconds)
+ **Total running time of the script:** ( 3 minutes 21.167 seconds)
.. _sphx_glr_download_auto_examples_plot_train_convert_predict.py:
+.. only:: html
-.. only :: html
-
- .. container:: sphx-glr-footer
- :class: sphx-glr-footer-example
-
-
-
- .. container:: sphx-glr-download sphx-glr-download-python
+ .. container:: sphx-glr-footer sphx-glr-footer-example
- :download:`Download Python source code: plot_train_convert_predict.py `
+ .. container:: sphx-glr-download sphx-glr-download-python
+ :download:`Download Python source code: plot_train_convert_predict.py `
- .. container:: sphx-glr-download sphx-glr-download-jupyter
+ .. container:: sphx-glr-download sphx-glr-download-jupyter
- :download:`Download Jupyter notebook: plot_train_convert_predict.ipynb `
+ :download:`Download Jupyter notebook: plot_train_convert_predict.ipynb `
.. only:: html
diff --git a/docs/api/python/sources/auto_examples/sg_execution_times.rst.txt b/docs/api/python/sources/auto_examples/sg_execution_times.rst.txt
index 12734e94e72c0..05223095e6584 100644
--- a/docs/api/python/sources/auto_examples/sg_execution_times.rst.txt
+++ b/docs/api/python/sources/auto_examples/sg_execution_times.rst.txt
@@ -5,22 +5,22 @@
Computation times
=================
-**03:23.370** total execution time for **auto_examples** files:
+**03:22.379** total execution time for **auto_examples** files:
+-------------------------------------------------------------------------------------------------------------+-----------+--------+
-| :ref:`sphx_glr_auto_examples_plot_train_convert_predict.py` (``plot_train_convert_predict.py``) | 03:22.159 | 0.0 MB |
+| :ref:`sphx_glr_auto_examples_plot_train_convert_predict.py` (``plot_train_convert_predict.py``) | 03:21.167 | 0.0 MB |
+-------------------------------------------------------------------------------------------------------------+-----------+--------+
-| :ref:`sphx_glr_auto_examples_plot_convert_pipeline_vectorizer.py` (``plot_convert_pipeline_vectorizer.py``) | 00:00.966 | 0.0 MB |
+| :ref:`sphx_glr_auto_examples_plot_convert_pipeline_vectorizer.py` (``plot_convert_pipeline_vectorizer.py``) | 00:00.956 | 0.0 MB |
+-------------------------------------------------------------------------------------------------------------+-----------+--------+
-| :ref:`sphx_glr_auto_examples_plot_pipeline.py` (``plot_pipeline.py``) | 00:00.196 | 0.0 MB |
+| :ref:`sphx_glr_auto_examples_plot_pipeline.py` (``plot_pipeline.py``) | 00:00.218 | 0.0 MB |
+-------------------------------------------------------------------------------------------------------------+-----------+--------+
| :ref:`sphx_glr_auto_examples_plot_backend.py` (``plot_backend.py``) | 00:00.014 | 0.0 MB |
+-------------------------------------------------------------------------------------------------------------+-----------+--------+
-| :ref:`sphx_glr_auto_examples_plot_load_and_predict.py` (``plot_load_and_predict.py``) | 00:00.013 | 0.0 MB |
-+-------------------------------------------------------------------------------------------------------------+-----------+--------+
| :ref:`sphx_glr_auto_examples_plot_common_errors.py` (``plot_common_errors.py``) | 00:00.009 | 0.0 MB |
+-------------------------------------------------------------------------------------------------------------+-----------+--------+
-| :ref:`sphx_glr_auto_examples_plot_profiling.py` (``plot_profiling.py``) | 00:00.007 | 0.0 MB |
+| :ref:`sphx_glr_auto_examples_plot_load_and_predict.py` (``plot_load_and_predict.py``) | 00:00.007 | 0.0 MB |
++-------------------------------------------------------------------------------------------------------------+-----------+--------+
+| :ref:`sphx_glr_auto_examples_plot_profiling.py` (``plot_profiling.py``) | 00:00.005 | 0.0 MB |
+-------------------------------------------------------------------------------------------------------------+-----------+--------+
-| :ref:`sphx_glr_auto_examples_plot_metadata.py` (``plot_metadata.py``) | 00:00.005 | 0.0 MB |
+| :ref:`sphx_glr_auto_examples_plot_metadata.py` (``plot_metadata.py``) | 00:00.003 | 0.0 MB |
+-------------------------------------------------------------------------------------------------------------+-----------+--------+
diff --git a/docs/api/python/static/_sphinx_javascript_frameworks_compat.js b/docs/api/python/static/_sphinx_javascript_frameworks_compat.js
new file mode 100644
index 0000000000000..8549469dc29fa
--- /dev/null
+++ b/docs/api/python/static/_sphinx_javascript_frameworks_compat.js
@@ -0,0 +1,134 @@
+/*
+ * _sphinx_javascript_frameworks_compat.js
+ * ~~~~~~~~~~
+ *
+ * Compatability shim for jQuery and underscores.js.
+ *
+ * WILL BE REMOVED IN Sphinx 6.0
+ * xref RemovedInSphinx60Warning
+ *
+ */
+
+/**
+ * select a different prefix for underscore
+ */
+$u = _.noConflict();
+
+
+/**
+ * small helper function to urldecode strings
+ *
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
+ */
+jQuery.urldecode = function(x) {
+ if (!x) {
+ return x
+ }
+ return decodeURIComponent(x.replace(/\+/g, ' '));
+};
+
+/**
+ * small helper function to urlencode strings
+ */
+jQuery.urlencode = encodeURIComponent;
+
+/**
+ * This function returns the parsed url parameters of the
+ * current request. Multiple values per key are supported,
+ * it will always return arrays of strings for the value parts.
+ */
+jQuery.getQueryParameters = function(s) {
+ if (typeof s === 'undefined')
+ s = document.location.search;
+ var parts = s.substr(s.indexOf('?') + 1).split('&');
+ var result = {};
+ for (var i = 0; i < parts.length; i++) {
+ var tmp = parts[i].split('=', 2);
+ var key = jQuery.urldecode(tmp[0]);
+ var value = jQuery.urldecode(tmp[1]);
+ if (key in result)
+ result[key].push(value);
+ else
+ result[key] = [value];
+ }
+ return result;
+};
+
+/**
+ * highlight a given string on a jquery object by wrapping it in
+ * span elements with the given class name.
+ */
+jQuery.fn.highlightText = function(text, className) {
+ function highlight(node, addItems) {
+ if (node.nodeType === 3) {
+ var val = node.nodeValue;
+ var pos = val.toLowerCase().indexOf(text);
+ if (pos >= 0 &&
+ !jQuery(node.parentNode).hasClass(className) &&
+ !jQuery(node.parentNode).hasClass("nohighlight")) {
+ var span;
+ var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
+ if (isInSVG) {
+ span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
+ } else {
+ span = document.createElement("span");
+ span.className = className;
+ }
+ span.appendChild(document.createTextNode(val.substr(pos, text.length)));
+ node.parentNode.insertBefore(span, node.parentNode.insertBefore(
+ document.createTextNode(val.substr(pos + text.length)),
+ node.nextSibling));
+ node.nodeValue = val.substr(0, pos);
+ if (isInSVG) {
+ var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
+ var bbox = node.parentElement.getBBox();
+ rect.x.baseVal.value = bbox.x;
+ rect.y.baseVal.value = bbox.y;
+ rect.width.baseVal.value = bbox.width;
+ rect.height.baseVal.value = bbox.height;
+ rect.setAttribute('class', className);
+ addItems.push({
+ "parent": node.parentNode,
+ "target": rect});
+ }
+ }
+ }
+ else if (!jQuery(node).is("button, select, textarea")) {
+ jQuery.each(node.childNodes, function() {
+ highlight(this, addItems);
+ });
+ }
+ }
+ var addItems = [];
+ var result = this.each(function() {
+ highlight(this, addItems);
+ });
+ for (var i = 0; i < addItems.length; ++i) {
+ jQuery(addItems[i].parent).before(addItems[i].target);
+ }
+ return result;
+};
+
+/*
+ * backward compatibility for jQuery.browser
+ * This will be supported until firefox bug is fixed.
+ */
+if (!jQuery.browser) {
+ jQuery.uaMatch = function(ua) {
+ ua = ua.toLowerCase();
+
+ var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
+ /(webkit)[ \/]([\w.]+)/.exec(ua) ||
+ /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
+ /(msie) ([\w.]+)/.exec(ua) ||
+ ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
+ [];
+
+ return {
+ browser: match[ 1 ] || "",
+ version: match[ 2 ] || "0"
+ };
+ };
+ jQuery.browser = {};
+ jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
+}
diff --git a/docs/api/python/static/basic.css b/docs/api/python/static/basic.css
index 603f6a8798e7f..eeb0519a69bac 100644
--- a/docs/api/python/static/basic.css
+++ b/docs/api/python/static/basic.css
@@ -4,7 +4,7 @@
*
* Sphinx stylesheet -- basic theme.
*
- * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@@ -222,7 +222,7 @@ table.modindextable td {
/* -- general body styles --------------------------------------------------- */
div.body {
- min-width: 450px;
+ min-width: 360px;
max-width: 800px;
}
@@ -236,7 +236,6 @@ div.body p, div.body dd, div.body li, div.body blockquote {
a.headerlink {
visibility: hidden;
}
-
a.brackets:before,
span.brackets > a:before{
content: "[";
@@ -247,6 +246,7 @@ span.brackets > a:after {
content: "]";
}
+
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
@@ -334,13 +334,11 @@ aside.sidebar {
p.sidebar-title {
font-weight: bold;
}
-
div.admonition, div.topic, blockquote {
clear: left;
}
/* -- topics ---------------------------------------------------------------- */
-
div.topic {
border: 1px solid #ccc;
padding: 7px;
@@ -428,10 +426,6 @@ table.docutils td, table.docutils th {
border-bottom: 1px solid #aaa;
}
-table.footnote td, table.footnote th {
- border: 0 !important;
-}
-
th {
text-align: left;
padding-right: 5px;
@@ -614,7 +608,6 @@ ol.simple p,
ul.simple p {
margin-bottom: 0;
}
-
dl.footnote > dt,
dl.citation > dt {
float: left;
@@ -643,11 +636,11 @@ dl.field-list > dt {
padding-left: 0.5em;
padding-right: 5px;
}
-
dl.field-list > dt:after {
content: ":";
}
+
dl.field-list > dd {
padding-left: 0.5em;
margin-top: 0em;
@@ -757,6 +750,7 @@ span.pre {
-ms-hyphens: none;
-webkit-hyphens: none;
hyphens: none;
+ white-space: nowrap;
}
div[class*="highlight-"] {
diff --git a/docs/api/python/static/doctools.js b/docs/api/python/static/doctools.js
index 8cbf1b161a652..c3db08d1c3896 100644
--- a/docs/api/python/static/doctools.js
+++ b/docs/api/python/static/doctools.js
@@ -2,322 +2,263 @@
* doctools.js
* ~~~~~~~~~~~
*
- * Sphinx JavaScript utilities for all documentation.
+ * Base JavaScript utilities for all Sphinx HTML documentation.
*
- * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
+"use strict";
-/**
- * select a different prefix for underscore
- */
-$u = _.noConflict();
-
-/**
- * make the code below compatible with browsers without
- * an installed firebug like debugger
-if (!window.console || !console.firebug) {
- var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
- "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
- "profile", "profileEnd"];
- window.console = {};
- for (var i = 0; i < names.length; ++i)
- window.console[names[i]] = function() {};
-}
- */
-
-/**
- * small helper function to urldecode strings
- *
- * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
- */
-jQuery.urldecode = function(x) {
- if (!x) {
- return x
+const _ready = (callback) => {
+ if (document.readyState !== "loading") {
+ callback();
+ } else {
+ document.addEventListener("DOMContentLoaded", callback);
}
- return decodeURIComponent(x.replace(/\+/g, ' '));
};
/**
- * small helper function to urlencode strings
+ * highlight a given string on a node by wrapping it in
+ * span elements with the given class name.
*/
-jQuery.urlencode = encodeURIComponent;
+const _highlight = (node, addItems, text, className) => {
+ if (node.nodeType === Node.TEXT_NODE) {
+ const val = node.nodeValue;
+ const parent = node.parentNode;
+ const pos = val.toLowerCase().indexOf(text);
+ if (
+ pos >= 0 &&
+ !parent.classList.contains(className) &&
+ !parent.classList.contains("nohighlight")
+ ) {
+ let span;
-/**
- * This function returns the parsed url parameters of the
- * current request. Multiple values per key are supported,
- * it will always return arrays of strings for the value parts.
- */
-jQuery.getQueryParameters = function(s) {
- if (typeof s === 'undefined')
- s = document.location.search;
- var parts = s.substr(s.indexOf('?') + 1).split('&');
- var result = {};
- for (var i = 0; i < parts.length; i++) {
- var tmp = parts[i].split('=', 2);
- var key = jQuery.urldecode(tmp[0]);
- var value = jQuery.urldecode(tmp[1]);
- if (key in result)
- result[key].push(value);
- else
- result[key] = [value];
- }
- return result;
-};
+ const closestNode = parent.closest("body, svg, foreignObject");
+ const isInSVG = closestNode && closestNode.matches("svg");
+ if (isInSVG) {
+ span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
+ } else {
+ span = document.createElement("span");
+ span.classList.add(className);
+ }
-/**
- * highlight a given string on a jquery object by wrapping it in
- * span elements with the given class name.
- */
-jQuery.fn.highlightText = function(text, className) {
- function highlight(node, addItems) {
- if (node.nodeType === 3) {
- var val = node.nodeValue;
- var pos = val.toLowerCase().indexOf(text);
- if (pos >= 0 &&
- !jQuery(node.parentNode).hasClass(className) &&
- !jQuery(node.parentNode).hasClass("nohighlight")) {
- var span;
- var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
- if (isInSVG) {
- span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
- } else {
- span = document.createElement("span");
- span.className = className;
- }
- span.appendChild(document.createTextNode(val.substr(pos, text.length)));
- node.parentNode.insertBefore(span, node.parentNode.insertBefore(
+ span.appendChild(document.createTextNode(val.substr(pos, text.length)));
+ parent.insertBefore(
+ span,
+ parent.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
- node.nextSibling));
- node.nodeValue = val.substr(0, pos);
- if (isInSVG) {
- var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
- var bbox = node.parentElement.getBBox();
- rect.x.baseVal.value = bbox.x;
- rect.y.baseVal.value = bbox.y;
- rect.width.baseVal.value = bbox.width;
- rect.height.baseVal.value = bbox.height;
- rect.setAttribute('class', className);
- addItems.push({
- "parent": node.parentNode,
- "target": rect});
- }
+ node.nextSibling
+ )
+ );
+ node.nodeValue = val.substr(0, pos);
+
+ if (isInSVG) {
+ const rect = document.createElementNS(
+ "http://www.w3.org/2000/svg",
+ "rect"
+ );
+ const bbox = parent.getBBox();
+ rect.x.baseVal.value = bbox.x;
+ rect.y.baseVal.value = bbox.y;
+ rect.width.baseVal.value = bbox.width;
+ rect.height.baseVal.value = bbox.height;
+ rect.setAttribute("class", className);
+ addItems.push({ parent: parent, target: rect });
}
}
- else if (!jQuery(node).is("button, select, textarea")) {
- jQuery.each(node.childNodes, function() {
- highlight(this, addItems);
- });
- }
+ } else if (node.matches && !node.matches("button, select, textarea")) {
+ node.childNodes.forEach((el) => _highlight(el, addItems, text, className));
}
- var addItems = [];
- var result = this.each(function() {
- highlight(this, addItems);
- });
- for (var i = 0; i < addItems.length; ++i) {
- jQuery(addItems[i].parent).before(addItems[i].target);
- }
- return result;
};
-
-/*
- * backward compatibility for jQuery.browser
- * This will be supported until firefox bug is fixed.
- */
-if (!jQuery.browser) {
- jQuery.uaMatch = function(ua) {
- ua = ua.toLowerCase();
-
- var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
- /(webkit)[ \/]([\w.]+)/.exec(ua) ||
- /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
- /(msie) ([\w.]+)/.exec(ua) ||
- ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
- [];
-
- return {
- browser: match[ 1 ] || "",
- version: match[ 2 ] || "0"
- };
- };
- jQuery.browser = {};
- jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
-}
+const _highlightText = (thisNode, text, className) => {
+ let addItems = [];
+ _highlight(thisNode, addItems, text, className);
+ addItems.forEach((obj) =>
+ obj.parent.insertAdjacentElement("beforebegin", obj.target)
+ );
+};
/**
* Small JavaScript module for the documentation.
*/
-var Documentation = {
-
- init : function() {
- this.fixFirefoxAnchorBug();
- this.highlightSearchWords();
- this.initIndexTable();
- if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) {
- this.initOnKeyListeners();
- }
+const Documentation = {
+ init: () => {
+ Documentation.highlightSearchWords();
+ Documentation.initDomainIndexTable();
+ Documentation.initOnKeyListeners();
},
/**
* i18n support
*/
- TRANSLATIONS : {},
- PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; },
- LOCALE : 'unknown',
+ TRANSLATIONS: {},
+ PLURAL_EXPR: (n) => (n === 1 ? 0 : 1),
+ LOCALE: "unknown",
// gettext and ngettext don't access this so that the functions
// can safely bound to a different name (_ = Documentation.gettext)
- gettext : function(string) {
- var translated = Documentation.TRANSLATIONS[string];
- if (typeof translated === 'undefined')
- return string;
- return (typeof translated === 'string') ? translated : translated[0];
- },
-
- ngettext : function(singular, plural, n) {
- var translated = Documentation.TRANSLATIONS[singular];
- if (typeof translated === 'undefined')
- return (n == 1) ? singular : plural;
- return translated[Documentation.PLURALEXPR(n)];
- },
-
- addTranslations : function(catalog) {
- for (var key in catalog.messages)
- this.TRANSLATIONS[key] = catalog.messages[key];
- this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
- this.LOCALE = catalog.locale;
+ gettext: (string) => {
+ const translated = Documentation.TRANSLATIONS[string];
+ switch (typeof translated) {
+ case "undefined":
+ return string; // no translation
+ case "string":
+ return translated; // translation exists
+ default:
+ return translated[0]; // (singular, plural) translation tuple exists
+ }
},
- /**
- * add context elements like header anchor links
- */
- addContextElements : function() {
- $('div[id] > :header:first').each(function() {
- $('\u00B6').
- attr('href', '#' + this.id).
- attr('title', _('Permalink to this headline')).
- appendTo(this);
- });
- $('dt[id]').each(function() {
- $('\u00B6').
- attr('href', '#' + this.id).
- attr('title', _('Permalink to this definition')).
- appendTo(this);
- });
+ ngettext: (singular, plural, n) => {
+ const translated = Documentation.TRANSLATIONS[singular];
+ if (typeof translated !== "undefined")
+ return translated[Documentation.PLURAL_EXPR(n)];
+ return n === 1 ? singular : plural;
},
- /**
- * workaround a firefox stupidity
- * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075
- */
- fixFirefoxAnchorBug : function() {
- if (document.location.hash && $.browser.mozilla)
- window.setTimeout(function() {
- document.location.href += '';
- }, 10);
+ addTranslations: (catalog) => {
+ Object.assign(Documentation.TRANSLATIONS, catalog.messages);
+ Documentation.PLURAL_EXPR = new Function(
+ "n",
+ `return (${catalog.plural_expr})`
+ );
+ Documentation.LOCALE = catalog.locale;
},
/**
* highlight the search words provided in the url in the text
*/
- highlightSearchWords : function() {
- var params = $.getQueryParameters();
- var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
- if (terms.length) {
- var body = $('div.body');
- if (!body.length) {
- body = $('body');
- }
- window.setTimeout(function() {
- $.each(terms, function() {
- body.highlightText(this.toLowerCase(), 'highlighted');
- });
- }, 10);
- $('' + _('Hide Search Matches') + '
')
- .appendTo($('#searchbox'));
- }
- },
+ highlightSearchWords: () => {
+ const highlight =
+ new URLSearchParams(window.location.search).get("highlight") || "";
+ const terms = highlight.toLowerCase().split(/\s+/).filter(x => x);
+ if (terms.length === 0) return; // nothing to do
- /**
- * init the domain index toggle buttons
- */
- initIndexTable : function() {
- var togglers = $('img.toggler').click(function() {
- var src = $(this).attr('src');
- var idnum = $(this).attr('id').substr(7);
- $('tr.cg-' + idnum).toggle();
- if (src.substr(-9) === 'minus.png')
- $(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
- else
- $(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
- }).css('display', '');
- if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
- togglers.click();
- }
+ // There should never be more than one element matching "div.body"
+ const divBody = document.querySelectorAll("div.body");
+ const body = divBody.length ? divBody[0] : document.querySelector("body");
+ window.setTimeout(() => {
+ terms.forEach((term) => _highlightText(body, term, "highlighted"));
+ }, 10);
+
+ const searchBox = document.getElementById("searchbox");
+ if (searchBox === null) return;
+ searchBox.appendChild(
+ document
+ .createRange()
+ .createContextualFragment(
+ '' +
+ '' +
+ Documentation.gettext("Hide Search Matches") +
+ "
"
+ )
+ );
},
/**
* helper function to hide the search marks again
*/
- hideSearchWords : function() {
- $('#searchbox .highlight-link').fadeOut(300);
- $('span.highlighted').removeClass('highlighted');
+ hideSearchWords: () => {
+ document
+ .querySelectorAll("#searchbox .highlight-link")
+ .forEach((el) => el.remove());
+ document
+ .querySelectorAll("span.highlighted")
+ .forEach((el) => el.classList.remove("highlighted"));
+ const url = new URL(window.location);
+ url.searchParams.delete("highlight");
+ window.history.replaceState({}, "", url);
},
/**
- * make the url absolute
+ * helper function to focus on search bar
*/
- makeURL : function(relativeURL) {
- return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
+ focusSearchBar: () => {
+ document.querySelectorAll("input[name=q]")[0]?.focus();
},
/**
- * get the current relative url
+ * Initialise the domain index toggle buttons
*/
- getCurrentURL : function() {
- var path = document.location.pathname;
- var parts = path.split(/\//);
- $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
- if (this === '..')
- parts.pop();
- });
- var url = parts.join('/');
- return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
+ initDomainIndexTable: () => {
+ const toggler = (el) => {
+ const idNumber = el.id.substr(7);
+ const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`);
+ if (el.src.substr(-9) === "minus.png") {
+ el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`;
+ toggledRows.forEach((el) => (el.style.display = "none"));
+ } else {
+ el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`;
+ toggledRows.forEach((el) => (el.style.display = ""));
+ }
+ };
+
+ const togglerElements = document.querySelectorAll("img.toggler");
+ togglerElements.forEach((el) =>
+ el.addEventListener("click", (event) => toggler(event.currentTarget))
+ );
+ togglerElements.forEach((el) => (el.style.display = ""));
+ if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler);
},
- initOnKeyListeners: function() {
- $(document).keydown(function(event) {
- var activeElementType = document.activeElement.tagName;
- // don't navigate when in search box, textarea, dropdown or button
- if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT'
- && activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey
- && !event.shiftKey) {
- switch (event.keyCode) {
- case 37: // left
- var prevHref = $('link[rel="prev"]').prop('href');
- if (prevHref) {
- window.location.href = prevHref;
- return false;
+ initOnKeyListeners: () => {
+ // only install a listener if it is really needed
+ if (
+ !DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS &&
+ !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
+ )
+ return;
+
+ const blacklistedElements = new Set([
+ "TEXTAREA",
+ "INPUT",
+ "SELECT",
+ "BUTTON",
+ ]);
+ document.addEventListener("keydown", (event) => {
+ if (blacklistedElements.has(document.activeElement.tagName)) return; // bail for input elements
+ if (event.altKey || event.ctrlKey || event.metaKey) return; // bail with special keys
+
+ if (!event.shiftKey) {
+ switch (event.key) {
+ case "ArrowLeft":
+ if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break;
+
+ const prevLink = document.querySelector('link[rel="prev"]');
+ if (prevLink && prevLink.href) {
+ window.location.href = prevLink.href;
+ event.preventDefault();
}
break;
- case 39: // right
- var nextHref = $('link[rel="next"]').prop('href');
- if (nextHref) {
- window.location.href = nextHref;
- return false;
+ case "ArrowRight":
+ if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break;
+
+ const nextLink = document.querySelector('link[rel="next"]');
+ if (nextLink && nextLink.href) {
+ window.location.href = nextLink.href;
+ event.preventDefault();
}
break;
+ case "Escape":
+ if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break;
+ Documentation.hideSearchWords();
+ event.preventDefault();
}
}
+
+ // some keyboard layouts may need Shift to get /
+ switch (event.key) {
+ case "/":
+ if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break;
+ Documentation.focusSearchBar();
+ event.preventDefault();
+ }
});
- }
+ },
};
// quick alias for translations
-_ = Documentation.gettext;
+const _ = Documentation.gettext;
-$(document).ready(function() {
- Documentation.init();
-});
+_ready(Documentation.init);
diff --git a/docs/api/python/static/documentation_options.js b/docs/api/python/static/documentation_options.js
index b5bc969fa9035..52b4ddafe8d93 100644
--- a/docs/api/python/static/documentation_options.js
+++ b/docs/api/python/static/documentation_options.js
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
- VERSION: '1.11.0',
+ VERSION: '1.13.0',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
@@ -8,5 +8,7 @@ var DOCUMENTATION_OPTIONS = {
LINK_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt',
- NAVIGATION_WITH_KEYS: false
+ NAVIGATION_WITH_KEYS: false,
+ SHOW_SEARCH_SUMMARY: true,
+ ENABLE_SEARCH_SHORTCUTS: true,
};
\ No newline at end of file
diff --git a/docs/api/python/static/graphviz.css b/docs/api/python/static/graphviz.css
index b340734c742f5..19e7afd385bed 100644
--- a/docs/api/python/static/graphviz.css
+++ b/docs/api/python/static/graphviz.css
@@ -4,7 +4,7 @@
*
* Sphinx stylesheet -- graphviz extension.
*
- * :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
diff --git a/docs/api/python/static/jquery-3.5.1.js b/docs/api/python/static/jquery-3.6.0.js
similarity index 98%
rename from docs/api/python/static/jquery-3.5.1.js
rename to docs/api/python/static/jquery-3.6.0.js
index 50937333b99a5..fc6c299b73e79 100644
--- a/docs/api/python/static/jquery-3.5.1.js
+++ b/docs/api/python/static/jquery-3.6.0.js
@@ -1,15 +1,15 @@
/*!
- * jQuery JavaScript Library v3.5.1
+ * jQuery JavaScript Library v3.6.0
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
- * Copyright JS Foundation and other contributors
+ * Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
- * Date: 2020-05-04T22:49Z
+ * Date: 2021-03-02T17:08Z
*/
( function( global, factory ) {
@@ -76,12 +76,16 @@ var support = {};
var isFunction = function isFunction( obj ) {
- // Support: Chrome <=57, Firefox <=52
- // In some browsers, typeof returns "function" for HTML
-
-
-
-