mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-14 18:12:05 +00:00
471 lines
No EOL
31 KiB
HTML
471 lines
No EOL
31 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>API Summary — ONNX Runtime 1.4.0 documentation</title>
|
||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
<link rel="stylesheet" type="text/css" href="_static/graphviz.css" />
|
||
<link rel="stylesheet" type="text/css" href="_static/gallery.css" />
|
||
<link rel="stylesheet" type="text/css" href="_static/gallery-binder.css" />
|
||
<link rel="stylesheet" type="text/css" href="_static/gallery-dataframe.css" />
|
||
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||
<script src="_static/jquery.js"></script>
|
||
<script src="_static/underscore.js"></script>
|
||
<script src="_static/doctools.js"></script>
|
||
<script src="_static/language_data.js"></script>
|
||
<link rel="index" title="Index" href="genindex.html" />
|
||
<link rel="search" title="Search" href="search.html" />
|
||
<link rel="next" title="Gallery of examples" href="auto_examples/index.html" />
|
||
<link rel="prev" title="Tutorial" href="tutorial.html" />
|
||
|
||
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
|
||
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
|
||
|
||
</head><body>
|
||
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
|
||
|
||
<div class="body" role="main">
|
||
|
||
<div class="section" id="api-summary">
|
||
<h1>API Summary<a class="headerlink" href="#api-summary" title="Permalink to this headline">¶</a></h1>
|
||
<p>Summary of public functions and classes exposed
|
||
in <em>ONNX Runtime</em>.</p>
|
||
<div class="contents local topic" id="contents">
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="#iobinding" id="id1">IOBinding</a></p></li>
|
||
<li><p><a class="reference internal" href="#device" id="id2">Device</a></p></li>
|
||
<li><p><a class="reference internal" href="#examples-and-datasets" id="id3">Examples and datasets</a></p></li>
|
||
<li><p><a class="reference internal" href="#load-and-run-a-model" id="id4">Load and run a model</a></p></li>
|
||
<li><p><a class="reference internal" href="#backend" id="id5">Backend</a></p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="iobinding">
|
||
<h2><a class="toc-backref" href="#id1">IOBinding</a><a class="headerlink" href="#iobinding" title="Permalink to this headline">¶</a></h2>
|
||
<p>By default, <em>ONNX Runtime</em> 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.
|
||
<em>ONNX Runtime</em> provides a feature, <em>IO Binding</em>, 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.</p>
|
||
<p>(In the following code snippets, <em>model.onnx</em> is the model to execute,
|
||
<em>X</em> is the input data to feed, and <em>Y</em> is the output data.)</p>
|
||
<p>Scenario 1:</p>
|
||
<p>A graph is executed on a deivce other than CPU, for instance CUDA. Users can
|
||
use IOBinding to put input on CUDA as the follows.</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1">#X is numpy array on cpu</span>
|
||
<span class="n">session</span> <span class="o">=</span> <span class="n">onnxruntime</span><span class="o">.</span><span class="n">InferenceSession</span><span class="p">(</span><span class="s1">'model.onnx'</span><span class="p">)</span>
|
||
<span class="n">io_binding</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">io_binding</span><span class="p">()</span>
|
||
<span class="n">io_binding</span><span class="o">.</span><span class="n">bind_cpu_input</span><span class="p">(</span><span class="s1">'input'</span><span class="p">,</span> <span class="n">X</span><span class="p">)</span>
|
||
<span class="n">io_binding</span><span class="o">.</span><span class="n">bind_output</span><span class="p">(</span><span class="s1">'output'</span><span class="p">)</span>
|
||
<span class="n">session</span><span class="o">.</span><span class="n">run_with_iobinding</span><span class="p">(</span><span class="n">io_binding</span><span class="p">)</span>
|
||
<span class="n">Y</span> <span class="o">=</span> <span class="n">io_binding</span><span class="o">.</span><span class="n">copy_outputs_to_cpu</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Scenario 2:</p>
|
||
<p>The input data is on a device, users direclty use the input. The output data is on CPU.</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">session</span> <span class="o">=</span> <span class="n">onnxruntime</span><span class="o">.</span><span class="n">InferenceSession</span><span class="p">(</span><span class="s1">'model.onnx'</span><span class="p">)</span>
|
||
<span class="n">io_binding</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">io_binding</span><span class="p">()</span>
|
||
<span class="n">io_binding</span><span class="o">.</span><span class="n">bind_input</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'input'</span><span class="p">,</span> <span class="n">device_type</span><span class="o">=</span><span class="n">X</span><span class="o">.</span><span class="n">device</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">device_id</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">element_type</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="nb">list</span><span class="p">(</span><span class="n">X</span><span class="o">.</span><span class="n">size</span><span class="p">()),</span> <span class="n">buffer_ptr</span><span class="o">=</span><span class="n">X</span><span class="o">.</span><span class="n">data_ptr</span><span class="p">())</span>
|
||
<span class="n">io_binding</span><span class="o">.</span><span class="n">bind_output</span><span class="p">(</span><span class="s1">'output'</span><span class="p">)</span>
|
||
<span class="n">session</span><span class="o">.</span><span class="n">run_with_iobinding</span><span class="p">(</span><span class="n">io_binding</span><span class="p">)</span>
|
||
<span class="n">Y</span> <span class="o">=</span> <span class="n">io_binding</span><span class="o">.</span><span class="n">copy_outputs_to_cpu</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Scenario 3:</p>
|
||
<p>The input data on a dveice, users directly use the input and also place output on the device:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">session</span> <span class="o">=</span> <span class="n">onnxruntime</span><span class="o">.</span><span class="n">InferenceSession</span><span class="p">(</span><span class="s1">'model.onnx'</span><span class="p">)</span>
|
||
<span class="n">io_binding</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">io_binding</span><span class="p">()</span>
|
||
<span class="n">io_binding</span><span class="o">.</span><span class="n">bind_input</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'input'</span><span class="p">,</span> <span class="n">device_type</span><span class="o">=</span><span class="n">X</span><span class="o">.</span><span class="n">device</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">device_id</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">element_type</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="nb">list</span><span class="p">(</span><span class="n">X</span><span class="o">.</span><span class="n">size</span><span class="p">()),</span> <span class="n">buffer_ptr</span><span class="o">=</span><span class="n">X</span><span class="o">.</span><span class="n">data_ptr</span><span class="p">())</span>
|
||
<span class="n">io_binding</span><span class="o">.</span><span class="n">bind_output</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'output'</span><span class="p">,</span> <span class="n">device_type</span><span class="o">=</span><span class="n">Y</span><span class="o">.</span><span class="n">device</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">device_id</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">element_type</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="nb">list</span><span class="p">(</span><span class="n">Y</span><span class="o">.</span><span class="n">size</span><span class="p">()),</span> <span class="n">buffer_ptr</span><span class="o">=</span><span class="n">Y</span><span class="o">.</span><span class="n">data_ptr</span><span class="p">())</span>
|
||
<span class="n">session</span><span class="o">.</span><span class="n">run_with_iobinding</span><span class="p">(</span><span class="n">io_binding</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="device">
|
||
<h2><a class="toc-backref" href="#id2">Device</a><a class="headerlink" href="#device" title="Permalink to this headline">¶</a></h2>
|
||
<p>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:</p>
|
||
<dl class="py function">
|
||
<dt id="onnxruntime.get_device">
|
||
<code class="sig-prename descclassname">onnxruntime.</code><code class="sig-name descname">get_device</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)">str</a><a class="headerlink" href="#onnxruntime.get_device" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Return the device used to compute the prediction (CPU, MKL, …)</p>
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="examples-and-datasets">
|
||
<h2><a class="toc-backref" href="#id3">Examples and datasets</a><a class="headerlink" href="#examples-and-datasets" title="Permalink to this headline">¶</a></h2>
|
||
<p>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.</p>
|
||
<dl class="py function">
|
||
<dt id="onnxruntime.datasets.get_example">
|
||
<code class="sig-prename descclassname">onnxruntime.datasets.</code><code class="sig-name descname">get_example</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">name</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/onnxruntime/datasets.html#get_example"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#onnxruntime.datasets.get_example" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Retrieves the absolute file name of an example.</p>
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="load-and-run-a-model">
|
||
<h2><a class="toc-backref" href="#id4">Load and run a model</a><a class="headerlink" href="#load-and-run-a-model" title="Permalink to this headline">¶</a></h2>
|
||
<p><em>ONNX Runtime</em> reads a model saved in ONNX format.
|
||
The main class <em>InferenceSession</em> wraps these functionalities
|
||
in a single place.</p>
|
||
<dl class="py class">
|
||
<dt id="onnxruntime.ModelMetadata">
|
||
<em class="property">class </em><code class="sig-prename descclassname">onnxruntime.</code><code class="sig-name descname">ModelMetadata</code><a class="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
|
||
facilitate the comparison.</p>
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.ModelMetadata.custom_metadata_map">
|
||
<em class="property">property </em><code class="sig-name descname">custom_metadata_map</code><a class="headerlink" href="#onnxruntime.ModelMetadata.custom_metadata_map" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>additional metadata</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.ModelMetadata.description">
|
||
<em class="property">property </em><code class="sig-name descname">description</code><a class="headerlink" href="#onnxruntime.ModelMetadata.description" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>description of the model</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.ModelMetadata.domain">
|
||
<em class="property">property </em><code class="sig-name descname">domain</code><a class="headerlink" href="#onnxruntime.ModelMetadata.domain" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>ONNX domain</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.ModelMetadata.graph_name">
|
||
<em class="property">property </em><code class="sig-name descname">graph_name</code><a class="headerlink" href="#onnxruntime.ModelMetadata.graph_name" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>graph name</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.ModelMetadata.producer_name">
|
||
<em class="property">property </em><code class="sig-name descname">producer_name</code><a class="headerlink" href="#onnxruntime.ModelMetadata.producer_name" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>producer name</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.ModelMetadata.version">
|
||
<em class="property">property </em><code class="sig-name descname">version</code><a class="headerlink" href="#onnxruntime.ModelMetadata.version" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>version of the model</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="onnxruntime.InferenceSession">
|
||
<em class="property">class </em><code class="sig-prename descclassname">onnxruntime.</code><code class="sig-name descname">InferenceSession</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">path_or_bytes</span></em>, <em class="sig-param"><span class="n">sess_options</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">providers</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/onnxruntime/capi/session.html#InferenceSession"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#onnxruntime.InferenceSession" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>This is the main class used to run a model.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="onnxruntime.NodeArg">
|
||
<em class="property">class </em><code class="sig-prename descclassname">onnxruntime.</code><code class="sig-name descname">NodeArg</code><a class="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>
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.NodeArg.name">
|
||
<em class="property">property </em><code class="sig-name descname">name</code><a class="headerlink" href="#onnxruntime.NodeArg.name" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>node name</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.NodeArg.shape">
|
||
<em class="property">property </em><code class="sig-name descname">shape</code><a class="headerlink" href="#onnxruntime.NodeArg.shape" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>node shape (assuming the node holds a tensor)</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.NodeArg.type">
|
||
<em class="property">property </em><code class="sig-name descname">type</code><a class="headerlink" href="#onnxruntime.NodeArg.type" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>node type</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="onnxruntime.RunOptions">
|
||
<em class="property">class </em><code class="sig-prename descclassname">onnxruntime.</code><code class="sig-name descname">RunOptions</code><a class="headerlink" href="#onnxruntime.RunOptions" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Configuration information for a single Run.</p>
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.RunOptions.log_severity_level">
|
||
<em class="property">property </em><code class="sig-name descname">log_severity_level</code><a class="headerlink" href="#onnxruntime.RunOptions.log_severity_level" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Log severity level for a particular Run() invocation. 0:Verbose, 1:Info, 2:Warning. 3:Error, 4:Fatal. Default is 2.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.RunOptions.log_verbosity_level">
|
||
<em class="property">property </em><code class="sig-name descname">log_verbosity_level</code><a class="headerlink" href="#onnxruntime.RunOptions.log_verbosity_level" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>VLOG level if DEBUG build and run_log_severity_level is 0.
|
||
Applies to a particular Run() invocation. Default is 0.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.RunOptions.logid">
|
||
<em class="property">property </em><code class="sig-name descname">logid</code><a class="headerlink" href="#onnxruntime.RunOptions.logid" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>To identify logs generated by a particular Run() invocation.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.RunOptions.only_execute_path_to_fetches">
|
||
<em class="property">property </em><code class="sig-name descname">only_execute_path_to_fetches</code><a class="headerlink" href="#onnxruntime.RunOptions.only_execute_path_to_fetches" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Only execute the nodes needed by fetch list</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.RunOptions.terminate">
|
||
<em class="property">property </em><code class="sig-name descname">terminate</code><a class="headerlink" href="#onnxruntime.RunOptions.terminate" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Set to True to terminate any currently executing calls that are using this
|
||
RunOptions instance. The individual calls will exit gracefully and return an error status.</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="onnxruntime.SessionOptions">
|
||
<em class="property">class </em><code class="sig-prename descclassname">onnxruntime.</code><code class="sig-name descname">SessionOptions</code><a class="headerlink" href="#onnxruntime.SessionOptions" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Configuration information for a session.</p>
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.enable_cpu_mem_arena">
|
||
<em class="property">property </em><code class="sig-name descname">enable_cpu_mem_arena</code><a class="headerlink" href="#onnxruntime.SessionOptions.enable_cpu_mem_arena" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Enables the memory arena on CPU. Arena may pre-allocate memory for future usage.
|
||
Set this option to false if you don’t want it. Default is True.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.enable_mem_pattern">
|
||
<em class="property">property </em><code class="sig-name descname">enable_mem_pattern</code><a class="headerlink" href="#onnxruntime.SessionOptions.enable_mem_pattern" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Enable the memory pattern optimization. Default is true.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.enable_profiling">
|
||
<em class="property">property </em><code class="sig-name descname">enable_profiling</code><a class="headerlink" href="#onnxruntime.SessionOptions.enable_profiling" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Enable profiling for this session. Default is false.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.execution_mode">
|
||
<em class="property">property </em><code class="sig-name descname">execution_mode</code><a class="headerlink" href="#onnxruntime.SessionOptions.execution_mode" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Sets the execution mode. Default is sequential.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.graph_optimization_level">
|
||
<em class="property">property </em><code class="sig-name descname">graph_optimization_level</code><a class="headerlink" href="#onnxruntime.SessionOptions.graph_optimization_level" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Graph optimization level for this session.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.inter_op_num_threads">
|
||
<em class="property">property </em><code class="sig-name descname">inter_op_num_threads</code><a class="headerlink" href="#onnxruntime.SessionOptions.inter_op_num_threads" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Sets the number of threads used to parallelize the execution of the graph (across nodes). Default is 0 to let onnxruntime choose.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.intra_op_num_threads">
|
||
<em class="property">property </em><code class="sig-name descname">intra_op_num_threads</code><a class="headerlink" href="#onnxruntime.SessionOptions.intra_op_num_threads" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Sets the number of threads used to parallelize the execution within nodes. Default is 0 to let onnxruntime choose.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.log_severity_level">
|
||
<em class="property">property </em><code class="sig-name descname">log_severity_level</code><a class="headerlink" href="#onnxruntime.SessionOptions.log_severity_level" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Log severity level. Applies to session load, initialization, etc.
|
||
0:Verbose, 1:Info, 2:Warning. 3:Error, 4:Fatal. Default is 2.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.log_verbosity_level">
|
||
<em class="property">property </em><code class="sig-name descname">log_verbosity_level</code><a class="headerlink" href="#onnxruntime.SessionOptions.log_verbosity_level" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>VLOG level if DEBUG build and session_log_verbosity_level is 0.
|
||
Applies to session load, initialization, etc. Default is 0.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.logid">
|
||
<em class="property">property </em><code class="sig-name descname">logid</code><a class="headerlink" href="#onnxruntime.SessionOptions.logid" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Logger id to use for session output.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.optimized_model_filepath">
|
||
<em class="property">property </em><code class="sig-name descname">optimized_model_filepath</code><a class="headerlink" href="#onnxruntime.SessionOptions.optimized_model_filepath" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>File path to serialize optimized model. By default, optimized model is not serialized if optimized_model_filepath is not provided.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="onnxruntime.SessionOptions.use_deterministic_compute">
|
||
<em class="property">property </em><code class="sig-name descname">use_deterministic_compute</code><a class="headerlink" href="#onnxruntime.SessionOptions.use_deterministic_compute" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Whether to use deterministic compute. Default is false.</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="backend">
|
||
<h2><a class="toc-backref" href="#id5">Backend</a><a class="headerlink" href="#backend" title="Permalink to this headline">¶</a></h2>
|
||
<p>In addition to the regular API which is optimized for performance and usability,
|
||
<em>ONNX Runtime</em> also implements the
|
||
<a class="reference external" href="https://github.com/onnx/onnx/blob/master/docs/ImplementingAnOnnxBackend.md">ONNX backend API</a>
|
||
for verification of <em>ONNX</em> specification conformance.
|
||
The following functions are supported:</p>
|
||
<dl class="py function">
|
||
<dt id="onnxruntime.backend.is_compatible">
|
||
<code class="sig-prename descclassname">onnxruntime.backend.</code><code class="sig-name descname">is_compatible</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">model</span></em>, <em class="sig-param"><span class="n">device</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="headerlink" href="#onnxruntime.backend.is_compatible" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Return whether the model is compatible with the backend.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>model</strong> – unused</p></li>
|
||
<li><p><strong>device</strong> – None to use the default device or a string (ex: <cite>‘CPU’</cite>)</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>boolean</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt id="onnxruntime.backend.prepare">
|
||
<code class="sig-prename descclassname">onnxruntime.backend.</code><code class="sig-name descname">prepare</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">model</span></em>, <em class="sig-param"><span class="n">device</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="headerlink" href="#onnxruntime.backend.prepare" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Load the model and creates a <a class="reference internal" href="#onnxruntime.InferenceSession" title="onnxruntime.InferenceSession"><code class="xref py py-class docutils literal notranslate"><span class="pre">onnxruntime.InferenceSession</span></code></a>
|
||
ready to be used as a backend.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>model</strong> – ModelProto (returned by <cite>onnx.load</cite>),
|
||
string for a filename or bytes for a serialized model</p></li>
|
||
<li><p><strong>device</strong> – requested device for the computation,
|
||
None means the default one which depends on
|
||
the compilation settings</p></li>
|
||
<li><p><strong>kwargs</strong> – see <a class="reference internal" href="#onnxruntime.SessionOptions" title="onnxruntime.SessionOptions"><code class="xref py py-class docutils literal notranslate"><span class="pre">onnxruntime.SessionOptions</span></code></a></p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><a class="reference internal" href="#onnxruntime.InferenceSession" title="onnxruntime.InferenceSession"><code class="xref py py-class docutils literal notranslate"><span class="pre">onnxruntime.InferenceSession</span></code></a></p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt id="onnxruntime.backend.run">
|
||
<code class="sig-prename descclassname">onnxruntime.backend.</code><code class="sig-name descname">run</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">model</span></em>, <em class="sig-param"><span class="n">inputs</span></em>, <em class="sig-param"><span class="n">device</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="headerlink" href="#onnxruntime.backend.run" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Compute the prediction.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>model</strong> – <a class="reference internal" href="#onnxruntime.InferenceSession" title="onnxruntime.InferenceSession"><code class="xref py py-class docutils literal notranslate"><span class="pre">onnxruntime.InferenceSession</span></code></a> returned
|
||
by function <em>prepare</em></p></li>
|
||
<li><p><strong>inputs</strong> – inputs</p></li>
|
||
<li><p><strong>device</strong> – requested device for the computation,
|
||
None means the default one which depends on
|
||
the compilation settings</p></li>
|
||
<li><p><strong>kwargs</strong> – see <a class="reference internal" href="#onnxruntime.RunOptions" title="onnxruntime.RunOptions"><code class="xref py py-class docutils literal notranslate"><span class="pre">onnxruntime.RunOptions</span></code></a></p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>predictions</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt id="onnxruntime.backend.supports_device">
|
||
<code class="sig-prename descclassname">onnxruntime.backend.</code><code class="sig-name descname">supports_device</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">device</span></em><span class="sig-paren">)</span><a class="headerlink" href="#onnxruntime.backend.supports_device" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Check whether the backend is compiled with particular device support.
|
||
In particular it’s used in the testing suite.</p>
|
||
</dd></dl>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="index.html">
|
||
<img class="logo" src="_static/ONNX_Runtime_icon.png" alt="Logo"/>
|
||
</a></p>
|
||
<h1 class="logo"><a href="index.html">ONNX Runtime</a></h1>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3>Navigation</h3>
|
||
<ul class="current">
|
||
<li class="toctree-l1"><a class="reference internal" href="tutorial.html">Tutorial</a></li>
|
||
<li class="toctree-l1 current"><a class="current reference internal" href="#">API Summary</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="auto_examples/index.html">Gallery of examples</a></li>
|
||
</ul>
|
||
|
||
<div class="relations">
|
||
<h3>Related Topics</h3>
|
||
<ul>
|
||
<li><a href="index.html">Documentation overview</a><ul>
|
||
<li>Previous: <a href="tutorial.html" title="previous chapter">Tutorial</a></li>
|
||
<li>Next: <a href="auto_examples/index.html" title="next chapter">Gallery of examples</a></li>
|
||
</ul></li>
|
||
</ul>
|
||
</div>
|
||
<div id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>$('#searchbox').show(0);</script>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="footer">
|
||
©2018-2019, Microsoft.
|
||
|
||
|
|
||
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.1.2</a>
|
||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
||
|
||
|
|
||
<a href="_sources/api_summary.rst.txt"
|
||
rel="nofollow">Page source</a>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
</body>
|
||
</html> |