<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># X is numpy array on cpu, create an OrtValue and place it on cuda device id = 0</span>
<spanclass="n">ortvalue</span><spanclass="o">.</span><spanclass="n">shape</span><spanclass="p">()</span><spanclass="c1"># shape of the numpy array X</span>
<spanclass="n">Y_ortvalue</span><spanclass="o">=</span><spanclass="n">onnxruntime</span><spanclass="o">.</span><spanclass="n">OrtValue</span><spanclass="o">.</span><spanclass="n">ortvalue_from_shape_and_type</span><spanclass="p">([</span><spanclass="mi">3</span><spanclass="p">,</span><spanclass="mi">2</span><spanclass="p">],</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">float32</span><spanclass="p">,</span><spanclass="s1">'cuda'</span><spanclass="p">,</span><spanclass="mi">0</span><spanclass="p">)</span><spanclass="c1"># Change the shape to the actual shape of the output being bound</span>
<spanclass="n">Y_ortvalue</span><spanclass="o">=</span><spanclass="n">onnxruntime</span><spanclass="o">.</span><spanclass="n">OrtValue</span><spanclass="o">.</span><spanclass="n">ortvalue_from_shape_and_type</span><spanclass="p">([</span><spanclass="mi">3</span><spanclass="p">,</span><spanclass="mi">2</span><spanclass="p">],</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">float32</span><spanclass="p">,</span><spanclass="s1">'cuda'</span><spanclass="p">,</span><spanclass="mi">0</span><spanclass="p">)</span><spanclass="c1"># Change the shape to the actual shape of the output being bound</span>
<spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.</span></span><spanclass="sig-name descname"><spanclass="pre">get_device</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><spanclass="sig-return"><spanclass="sig-return-icon">→</span><spanclass="sig-return-typehint"><aclass="reference external"href="https://docs.python.org/3/library/stdtypes.html#str"title="(in Python v3.10)"><spanclass="pre">str</span></a></span></span><aclass="headerlink"href="#onnxruntime.get_device"title="Permalink to this definition">¶</a></dt>
<h2><aclass="toc-backref"href="#id6">Examples and datasets</a><aclass="headerlink"href="#examples-and-datasets"title="Permalink to this headline">¶</a></h2>
<spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.datasets.</span></span><spanclass="sig-name descname"><spanclass="pre">get_example</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">name</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/datasets.html#get_example"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.datasets.get_example"title="Permalink to this definition">¶</a></dt>
<h2><aclass="toc-backref"href="#id7">Load and run a model</a><aclass="headerlink"href="#load-and-run-a-model"title="Permalink to this headline">¶</a></h2>
<spanclass="sig-name descname"><spanclass="pre">disable_fallback</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.disable_fallback"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">enable_fallback</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.enable_fallback"title="Permalink to this definition">¶</a></dt>
<dd><p>Enable session.Run() fallback mechanism. If session.Run() fails due to an internal Execution Provider failure,
reset the Execution Providers enabled for this session.
If GPU is enabled, fall back to CUDAExecutionProvider.
<spanclass="sig-name descname"><spanclass="pre">end_profiling</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.end_profiling"title="Permalink to this definition">¶</a></dt>
<dd><p>End profiling and return results in a file.</p>
<p>The results are stored in a filename if the option
<spanclass="sig-name descname"><spanclass="pre">get_inputs</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.get_inputs"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the inputs metadata as a list of <aclass="reference internal"href="#onnxruntime.NodeArg"title="onnxruntime.NodeArg"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">onnxruntime.NodeArg</span></code></a>.</p>
<spanclass="sig-name descname"><spanclass="pre">get_modelmeta</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.get_modelmeta"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the metadata. See <aclass="reference internal"href="#onnxruntime.ModelMetadata"title="onnxruntime.ModelMetadata"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">onnxruntime.ModelMetadata</span></code></a>.</p>
<spanclass="sig-name descname"><spanclass="pre">get_outputs</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.get_outputs"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the outputs metadata as a list of <aclass="reference internal"href="#onnxruntime.NodeArg"title="onnxruntime.NodeArg"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">onnxruntime.NodeArg</span></code></a>.</p>
<spanclass="sig-name descname"><spanclass="pre">get_overridable_initializers</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.get_overridable_initializers"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the inputs (including initializers) metadata as a list of <aclass="reference internal"href="#onnxruntime.NodeArg"title="onnxruntime.NodeArg"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">onnxruntime.NodeArg</span></code></a>.</p>
<spanclass="sig-name descname"><spanclass="pre">get_profiling_start_time_ns</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.get_profiling_start_time_ns"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the nanoseconds of profiling’s start time
Comparable to time.monotonic_ns() after Python 3.3
On some platforms, this timer may not be as precise as nanoseconds
For instance, on Windows and MacOS, the precision will be ~100ns</p>
<spanclass="sig-name descname"><spanclass="pre">get_provider_options</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.get_provider_options"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">get_providers</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.get_providers"title="Permalink to this definition">¶</a></dt>
<dd><p>Return list of registered execution providers.</p>
<spanclass="sig-name descname"><spanclass="pre">get_session_options</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.get_session_options"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the session options. See <aclass="reference internal"href="#onnxruntime.SessionOptions"title="onnxruntime.SessionOptions"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">onnxruntime.SessionOptions</span></code></a>.</p>
<spanclass="sig-name descname"><spanclass="pre">io_binding</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.io_binding"title="Permalink to this definition">¶</a></dt>
<dd><p>Return an onnxruntime.IOBinding object`.</p>
<spanclass="sig-name descname"><spanclass="pre">run</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">output_names</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">input_feed</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">run_options</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.run"title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the predictions.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>output_names</strong>– name of the outputs</p></li>
<spanclass="sig-name descname"><spanclass="pre">run_with_iobinding</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">iobinding</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">run_options</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.run_with_iobinding"title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the predictions.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>iobinding</strong>– the iobinding object that has graph inputs/outputs bind.</p></li>
<li><p><strong>run_options</strong>– See <aclass="reference internal"href="#onnxruntime.RunOptions"title="onnxruntime.RunOptions"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">onnxruntime.RunOptions</span></code></a>.</p></li>
<spanclass="sig-name descname"><spanclass="pre">run_with_ort_values</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">output_names</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">input_dict_ort_values</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">run_options</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.run_with_ort_values"title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the predictions.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>output_names</strong>– name of the outputs</p></li>
<spanclass="sig-name descname"><spanclass="pre">set_providers</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">providers</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">provider_options</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.InferenceSession.set_providers"title="Permalink to this definition">¶</a></dt>
<dd><p>Register the input list of execution providers. The underlying session is re-created.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>providers</strong>– Optional sequence of providers in order of decreasing
precedence. Values can either be provider names or tuples of
(provider name, options dict). If not provided, then all available
providers are used with the default precedence.</p></li>
<li><p><strong>provider_options</strong>– Optional sequence of options dicts corresponding
to the providers listed in ‘providers’.</p></li>
</ul>
</dd>
</dl>
<p>‘providers’ can contain either names or names and options. When any options
are given in ‘providers’, ‘provider_options’ should not be used.</p>
<p>The list of providers is ordered by precedence. For example
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.</span></span><spanclass="sig-name descname"><spanclass="pre">RunOptions</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">self</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><aclass="reference internal"href="#onnxruntime.RunOptions"title="onnxruntime.capi.onnxruntime_pybind11_state.RunOptions"><spanclass="pre">onnxruntime.capi.onnxruntime_pybind11_state.RunOptions</span></a></span></em><spanclass="sig-paren">)</span><spanclass="sig-return"><spanclass="sig-return-icon">→</span><spanclass="sig-return-typehint"><aclass="reference external"href="https://docs.python.org/3/library/constants.html#None"title="(in Python v3.10)"><spanclass="pre">None</span></a></span></span><aclass="headerlink"href="#onnxruntime.RunOptions"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">log_severity_level</span></span><aclass="headerlink"href="#onnxruntime.RunOptions.log_severity_level"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">log_verbosity_level</span></span><aclass="headerlink"href="#onnxruntime.RunOptions.log_verbosity_level"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">logid</span></span><aclass="headerlink"href="#onnxruntime.RunOptions.logid"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">only_execute_path_to_fetches</span></span><aclass="headerlink"href="#onnxruntime.RunOptions.only_execute_path_to_fetches"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">terminate</span></span><aclass="headerlink"href="#onnxruntime.RunOptions.terminate"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.</span></span><spanclass="sig-name descname"><spanclass="pre">SessionOptions</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">self</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><aclass="reference internal"href="#onnxruntime.SessionOptions"title="onnxruntime.capi.onnxruntime_pybind11_state.SessionOptions"><spanclass="pre">onnxruntime.capi.onnxruntime_pybind11_state.SessionOptions</span></a></span></em><spanclass="sig-paren">)</span><spanclass="sig-return"><spanclass="sig-return-icon">→</span><spanclass="sig-return-typehint"><aclass="reference external"href="https://docs.python.org/3/library/constants.html#None"title="(in Python v3.10)"><spanclass="pre">None</span></a></span></span><aclass="headerlink"href="#onnxruntime.SessionOptions"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">enable_cpu_mem_arena</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.enable_cpu_mem_arena"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">enable_mem_pattern</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.enable_mem_pattern"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">enable_mem_reuse</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.enable_mem_reuse"title="Permalink to this definition">¶</a></dt>
<dd><p>Enable the memory reuse optimization. Default is true.</p>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">enable_profiling</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.enable_profiling"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">execution_mode</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.execution_mode"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">execution_order</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.execution_order"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">graph_optimization_level</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.graph_optimization_level"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">inter_op_num_threads</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.inter_op_num_threads"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">intra_op_num_threads</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.intra_op_num_threads"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">log_severity_level</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.log_severity_level"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">log_verbosity_level</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.log_verbosity_level"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">logid</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.logid"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">optimized_model_filepath</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.optimized_model_filepath"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">profile_file_prefix</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.profile_file_prefix"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">use_deterministic_compute</span></span><aclass="headerlink"href="#onnxruntime.SessionOptions.use_deterministic_compute"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.</span></span><spanclass="sig-name descname"><spanclass="pre">OrtValue</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">ortvalue</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">numpy_obj</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue"title="Permalink to this definition">¶</a></dt>
<dd><p>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.</p>
<spanclass="sig-name descname"><spanclass="pre">as_sparse_tensor</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.as_sparse_tensor"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.as_sparse_tensor"title="Permalink to this definition">¶</a></dt>
<dd><p>The function will return SparseTensor contained in this OrtValue</p>
<spanclass="sig-name descname"><spanclass="pre">data_ptr</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.data_ptr"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.data_ptr"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the address of the first element in the OrtValue’s data buffer</p>
<spanclass="sig-name descname"><spanclass="pre">data_type</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.data_type"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.data_type"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the data type of the data in the OrtValue</p>
<spanclass="sig-name descname"><spanclass="pre">device_name</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.device_name"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.device_name"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the name of the device where the OrtValue’s data buffer resides e.g. cpu, cuda</p>
<spanclass="sig-name descname"><spanclass="pre">has_value</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.has_value"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.has_value"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if the OrtValue corresponding to an
optional type contains data, else returns False</p>
<spanclass="sig-name descname"><spanclass="pre">is_sparse_tensor</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.is_sparse_tensor"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.is_sparse_tensor"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if the OrtValue contains a SparseTensor, else returns False</p>
<spanclass="sig-name descname"><spanclass="pre">is_tensor</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.is_tensor"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.is_tensor"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if the OrtValue contains a Tensor, else returns False</p>
<spanclass="sig-name descname"><spanclass="pre">is_tensor_sequence</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.is_tensor_sequence"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.is_tensor_sequence"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if the OrtValue contains a Tensor Sequence, else returns False</p>
<spanclass="sig-name descname"><spanclass="pre">numpy</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.numpy"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.numpy"title="Permalink to this definition">¶</a></dt>
<dd><p>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</p>
<emclass="property"><spanclass="pre">static</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">ort_value_from_sparse_tensor</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">sparse_tensor</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.ort_value_from_sparse_tensor"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.ort_value_from_sparse_tensor"title="Permalink to this definition">¶</a></dt>
<dd><p>The function will construct an OrtValue instance from a valid SparseTensor
The new instance of OrtValue will assume the ownership of sparse_tensor</p>
<emclass="property"><spanclass="pre">static</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">ortvalue_from_numpy</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">numpy_obj</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">device_type</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">'cpu'</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">device_id</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">0</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.ortvalue_from_numpy"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.ortvalue_from_numpy"title="Permalink to this definition">¶</a></dt>
<dd><p>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</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>numpy_obj</strong>– The Numpy object to construct the OrtValue from</p></li>
<li><p><strong>device_type</strong>– e.g. cpu, cuda, cpu by default</p></li>
<li><p><strong>device_id</strong>– device id, e.g. 0</p></li>
<emclass="property"><spanclass="pre">static</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">ortvalue_from_shape_and_type</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">shape</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">element_type</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">device_type</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">'cpu'</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">device_id</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">0</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.ortvalue_from_shape_and_type"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.ortvalue_from_shape_and_type"title="Permalink to this definition">¶</a></dt>
<dd><p>Factory method to construct an OrtValue (which holds a Tensor) from given shape and element_type</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>shape</strong>– List of integers indicating the shape of the OrtValue</p></li>
<li><p><strong>element_type</strong>– The data type of the elements in the OrtValue (numpy type)</p></li>
<li><p><strong>device_type</strong>– e.g. cpu, cuda, cpu by default</p></li>
<li><p><strong>device_id</strong>– device id, e.g. 0</p></li>
<spanclass="sig-name descname"><spanclass="pre">shape</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtValue.shape"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtValue.shape"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the shape of the data in the OrtValue</p>
</dd></dl>
</dd></dl>
</section>
<sectionid="sparsetensor">
<h4><aclass="toc-backref"href="#id14">SparseTensor</a><aclass="headerlink"href="#sparsetensor"title="Permalink to this headline">¶</a></h4>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.</span></span><spanclass="sig-name descname"><spanclass="pre">SparseTensor</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">sparse_tensor</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor"title="Permalink to this definition">¶</a></dt>
<dd><p>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
<spanclass="sig-name descname"><spanclass="pre">as_blocksparse_view</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.as_blocksparse_view"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.as_blocksparse_view"title="Permalink to this definition">¶</a></dt>
<dd><p>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.
<spanclass="sig-name descname"><spanclass="pre">as_coo_view</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.as_coo_view"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.as_coo_view"title="Permalink to this definition">¶</a></dt>
<dd><p>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.
<spanclass="sig-name descname"><spanclass="pre">as_csrc_view</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.as_csrc_view"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.as_csrc_view"title="Permalink to this definition">¶</a></dt>
<dd><p>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.
<spanclass="sig-name descname"><spanclass="pre">data_type</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.data_type"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.data_type"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a string data type of the data in the OrtValue</p>
<spanclass="sig-name descname"><spanclass="pre">dense_shape</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.dense_shape"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.dense_shape"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a numpy array(int64) containing a dense shape of a sparse tensor</p>
<spanclass="sig-name descname"><spanclass="pre">device_name</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.device_name"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.device_name"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the name of the device where the SparseTensor data buffers reside e.g. cpu, cuda</p>
<spanclass="sig-name descname"><spanclass="pre">format</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.format"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.format"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">static</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">sparse_coo_from_numpy</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">dense_shape</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">values</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">coo_indices</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">ort_device</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.sparse_coo_from_numpy"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.sparse_coo_from_numpy"title="Permalink to this definition">¶</a></dt>
<dd><p>Factory method to construct a SparseTensor in COO format from given arguments</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>dense_shape</strong>– 1-D numpy array(int64) or a python list that contains a dense_shape of the sparse tensor
must be on cpu memory</p></li>
<li><p><strong>values</strong>– a homogeneous, contiguous 1-D numpy array that contains non-zero elements of the tensor
of a type.</p></li>
<li><p><strong>coo_indices</strong>– contiguous numpy array(int64) that contains COO indices for the tensor. coo_indices may
have a 1-D shape when it contains a linear index of non-zero values and its length must be equal to
that of the values. It can also be of 2-D shape, in which has it contains pairs of coordinates for
each of the nnz values and its length must be exactly twice of the values length.</p></li>
<li><p><strong>ort_device</strong>–<ul>
<li><p>describes the backing memory owned by the supplied nummpy arrays. Only CPU memory is</p></li>
</ul>
<p>suppored for non-numeric data types.</p>
</p></li>
</ul>
</dd>
</dl>
<p>For primitive types, the method will map values and coo_indices arrays into native memory and will use
them as backing storage. It will increment the reference count for numpy arrays and it will decrement it
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.</p>
<emclass="property"><spanclass="pre">static</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">sparse_csr_from_numpy</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">dense_shape</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">values</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">inner_indices</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">outer_indices</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">ort_device</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.sparse_csr_from_numpy"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.sparse_csr_from_numpy"title="Permalink to this definition">¶</a></dt>
<dd><p>Factory method to construct a SparseTensor in CSR format from given arguments</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>dense_shape</strong>– 1-D numpy array(int64) or a python list that contains a dense_shape of the
sparse tensor (rows, cols) must be on cpu memory</p></li>
<li><p><strong>values</strong>– a contiguous, homogeneous 1-D numpy array that contains non-zero elements of the tensor
of a type.</p></li>
<li><p><strong>inner_indices</strong>– contiguous 1-D numpy array(int64) that contains CSR inner indices for the tensor.
Its length must be equal to that of the values.</p></li>
<li><p><strong>outer_indices</strong>– contiguous 1-D numpy array(int64) that contains CSR outer indices for the tensor.
Its length must be equal to the number of rows + 1.</p></li>
<li><p><strong>ort_device</strong>–<ul>
<li><p>describes the backing memory owned by the supplied nummpy arrays. Only CPU memory is</p></li>
</ul>
<p>suppored for non-numeric data types.</p>
</p></li>
</ul>
</dd>
</dl>
<p>For primitive types, the method will map values and indices arrays into native memory and will use them as
backing storage. It will increment the reference count and it will decrement then count when it is GCed.
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.</p>
<spanclass="sig-name descname"><spanclass="pre">to_cuda</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">ort_device</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.to_cuda"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.to_cuda"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a copy of this instance on the specified cuda device</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>ort_device</strong>– with name ‘cuda’ and valid gpu device id</p>
</dd>
</dl>
<p>The method will throw if:</p>
<ulclass="simple">
<li><p>this instance contains strings</p></li>
<li><p>this instance is already on GPU. Cross GPU copy is not supported</p></li>
<li><p>CUDA is not present in this build</p></li>
<li><p>if the specified device is not valid</p></li>
<spanclass="sig-name descname"><spanclass="pre">values</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#SparseTensor.values"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.SparseTensor.values"title="Permalink to this definition">¶</a></dt>
<dd><p>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.</p>
</dd></dl>
</dd></dl>
</section>
</section>
<sectionid="devices">
<h3><aclass="toc-backref"href="#id15">Devices</a><aclass="headerlink"href="#devices"title="Permalink to this headline">¶</a></h3>
<sectionid="id2">
<h4><aclass="toc-backref"href="#id16">IOBinding</a><aclass="headerlink"href="#id2"title="Permalink to this headline">¶</a></h4>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.</span></span><spanclass="sig-name descname"><spanclass="pre">IOBinding</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">session</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#IOBinding"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.IOBinding"title="Permalink to this definition">¶</a></dt>
<dd><p>This class provides API to bind input/output to a specified device, e.g. GPU.</p>
<spanclass="sig-name descname"><spanclass="pre">bind_cpu_input</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">name</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">arr_on_cpu</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#IOBinding.bind_cpu_input"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.IOBinding.bind_cpu_input"title="Permalink to this definition">¶</a></dt>
<dd><p>bind an input to array on CPU
:param name: input name
:param arr_on_cpu: input values as a python array on CPU</p>
<spanclass="sig-name descname"><spanclass="pre">bind_ortvalue_input</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">name</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">ortvalue</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#IOBinding.bind_ortvalue_input"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.IOBinding.bind_ortvalue_input"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>name</strong>– input name</p></li>
<li><p><strong>ortvalue</strong>– OrtValue instance to bind</p></li>
<spanclass="sig-name descname"><spanclass="pre">bind_ortvalue_output</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">name</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">ortvalue</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#IOBinding.bind_ortvalue_output"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.IOBinding.bind_ortvalue_output"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">copy_outputs_to_cpu</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#IOBinding.copy_outputs_to_cpu"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.IOBinding.copy_outputs_to_cpu"title="Permalink to this definition">¶</a></dt>
<dd><p>Copy output contents to CPU (if on another device). No-op if already on the CPU.</p>
<spanclass="sig-name descname"><spanclass="pre">get_outputs</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#IOBinding.get_outputs"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.IOBinding.get_outputs"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the output OrtValues from the Run() that preceded the call.
The data buffer of the obtained OrtValues may not reside on CPU memory</p>
</dd></dl>
</dd></dl>
</section>
<sectionid="ortdevice">
<h4><aclass="toc-backref"href="#id17">OrtDevice</a><aclass="headerlink"href="#ortdevice"title="Permalink to this headline">¶</a></h4>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.</span></span><spanclass="sig-name descname"><spanclass="pre">OrtDevice</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">c_ort_device</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="modules/onnxruntime/capi/onnxruntime_inference_collection.html#OrtDevice"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#onnxruntime.OrtDevice"title="Permalink to this definition">¶</a></dt>
<dd><p>A data structure that exposes the underlying C++ OrtDevice</p>
<p>Internal constructor</p>
</dd></dl>
</section>
</section>
<sectionid="internal-classes">
<h3><aclass="toc-backref"href="#id18">Internal classes</a><aclass="headerlink"href="#internal-classes"title="Permalink to this headline">¶</a></h3>
<p>These classes cannot be instantiated by users but they are returned
by methods or functions of this libary.</p>
<sectionid="modelmetadata">
<h4><aclass="toc-backref"href="#id19">ModelMetadata</a><aclass="headerlink"href="#modelmetadata"title="Permalink to this headline">¶</a></h4>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.</span></span><spanclass="sig-name descname"><spanclass="pre">ModelMetadata</span></span><aclass="headerlink"href="#onnxruntime.ModelMetadata"title="Permalink to this definition">¶</a></dt>
<dd><p>Pre-defined and custom metadata about the model.
It is usually used to identify the model used to run the prediction and
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">custom_metadata_map</span></span><aclass="headerlink"href="#onnxruntime.ModelMetadata.custom_metadata_map"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">description</span></span><aclass="headerlink"href="#onnxruntime.ModelMetadata.description"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">domain</span></span><aclass="headerlink"href="#onnxruntime.ModelMetadata.domain"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">graph_description</span></span><aclass="headerlink"href="#onnxruntime.ModelMetadata.graph_description"title="Permalink to this definition">¶</a></dt>
<dd><p>description of the graph hosted in the model</p>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">graph_name</span></span><aclass="headerlink"href="#onnxruntime.ModelMetadata.graph_name"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">producer_name</span></span><aclass="headerlink"href="#onnxruntime.ModelMetadata.producer_name"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">version</span></span><aclass="headerlink"href="#onnxruntime.ModelMetadata.version"title="Permalink to this definition">¶</a></dt>
<dd><p>version of the model</p>
</dd></dl>
</dd></dl>
</section>
<sectionid="nodearg">
<h4><aclass="toc-backref"href="#id20">NodeArg</a><aclass="headerlink"href="#nodearg"title="Permalink to this headline">¶</a></h4>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.</span></span><spanclass="sig-name descname"><spanclass="pre">NodeArg</span></span><aclass="headerlink"href="#onnxruntime.NodeArg"title="Permalink to this definition">¶</a></dt>
<dd><p>Node argument definition, for both input and output,
including arg name, arg type (contains both type and shape).</p>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">name</span></span><aclass="headerlink"href="#onnxruntime.NodeArg.name"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">shape</span></span><aclass="headerlink"href="#onnxruntime.NodeArg.shape"title="Permalink to this definition">¶</a></dt>
<dd><p>node shape (assuming the node holds a tensor)</p>
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">type</span></span><aclass="headerlink"href="#onnxruntime.NodeArg.type"title="Permalink to this definition">¶</a></dt>
<dd><p>node type</p>
</dd></dl>
</dd></dl>
</section>
</section>
</section>
<sectionid="backend">
<h2><aclass="toc-backref"href="#id21">Backend</a><aclass="headerlink"href="#backend"title="Permalink to this headline">¶</a></h2>
<spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.backend.</span></span><spanclass="sig-name descname"><spanclass="pre">is_compatible</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">model</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">device</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.backend.is_compatible"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.backend.</span></span><spanclass="sig-name descname"><spanclass="pre">prepare</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">model</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">device</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.backend.prepare"title="Permalink to this definition">¶</a></dt>
<dd><p>Load the model and creates a <aclass="reference internal"href="#onnxruntime.InferenceSession"title="onnxruntime.InferenceSession"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">onnxruntime.InferenceSession</span></code></a>
<spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.backend.</span></span><spanclass="sig-name descname"><spanclass="pre">run</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">model</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">inputs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">device</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.backend.run"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">onnxruntime.backend.</span></span><spanclass="sig-name descname"><spanclass="pre">supports_device</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">device</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#onnxruntime.backend.supports_device"title="Permalink to this definition">¶</a></dt>