Skip to content

Commit

Permalink
rebuild docs based on latest repos (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: Jenkins <jenkins@neuralmagic.com>
  • Loading branch information
dhuangnm and jenkinsnm authored Mar 31, 2021
1 parent 9426515 commit c6dd356
Show file tree
Hide file tree
Showing 119 changed files with 8,977 additions and 9,278 deletions.
2 changes: 1 addition & 1 deletion deepsparse/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 09cf2dae090a5215faeb91fd805fe11e
config: c0e84c5bd7f1ae1547decebf78328f3b
tags: 645f666f9bcd5a90fca523b33c5a78b7
14 changes: 7 additions & 7 deletions deepsparse/_modules/deepsparse/engine.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,6 @@ <h1>Source code for deepsparse.engine</h1><div class="highlight"><pre>
<span class="sd"> Note 1: Engines are compiled for a specific batch size and</span>
<span class="sd"> for a specific number of CPU cores.</span>

<span class="sd"> Note 2: multi socket support is not yet built in to the Engine,</span>
<span class="sd"> all execution assumes single socket</span>

<span class="sd"> | Example:</span>
<span class="sd"> | # create an engine for batch size 1 on all available cores</span>
<span class="sd"> | engine = Engine(&quot;path/to/onnx&quot;, batch_size=1, num_cores=None)</span>
Expand Down Expand Up @@ -405,8 +402,7 @@ <h1>Source code for deepsparse.engine</h1><div class="highlight"><pre>
<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">num_sockets</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> :return: The number of sockets the engine is compiled to run on;</span>
<span class="sd"> only current support is 1</span>
<span class="sd"> :return: The number of sockets the engine is compiled to run on</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_num_sockets</span>

Expand Down Expand Up @@ -682,8 +678,8 @@ <h1>Source code for deepsparse.engine</h1><div class="highlight"><pre>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Convenience function to compile a model in the DeepSparse Engine</span>
<span class="sd"> from an ONNX file for inference.</span>
<span class="sd"> Gives defaults of batch_size == 1 and num_cores == None</span>
<span class="sd"> (will use all physical cores available on a single socket).</span>
<span class="sd"> Gives defaults of batch_size == 1, num_cores == None and num_sockets = None</span>
<span class="sd"> (will use all physical cores available on all available sockets).</span>

<span class="sd"> :param model: Either a path to the model&#39;s onnx file, a SparseZoo model stub</span>
<span class="sd"> prefixed by &#39;zoo:&#39;, a SparseZoo Model object, or a SparseZoo ONNX File</span>
Expand Down Expand Up @@ -718,6 +714,8 @@ <h1>Source code for deepsparse.engine</h1><div class="highlight"><pre>
<span class="sd"> Gives defaults of batch_size == 1 and num_cores == None</span>
<span class="sd"> (will use all physical cores available on a single socket).</span>

<span class="sd"> Note 1: Benchmarking is currently only supported on a single socket.</span>

<span class="sd"> :param model: Either a path to the model&#39;s onnx file, a SparseZoo model stub</span>
<span class="sd"> prefixed by &#39;zoo:&#39;, a SparseZoo Model object, or a SparseZoo ONNX File</span>
<span class="sd"> object that defines the neural network</span>
Expand Down Expand Up @@ -773,6 +771,8 @@ <h1>Source code for deepsparse.engine</h1><div class="highlight"><pre>
<span class="sd"> Gives defaults of batch_size == 1 and num_cores == None</span>
<span class="sd"> (will use all physical cores available on a single socket).</span>

<span class="sd"> Note 1: Analysis is currently only supported on a single socket.</span>

<span class="sd"> :param model: Either a path to the model&#39;s onnx file, a SparseZoo model stub</span>
<span class="sd"> prefixed by &#39;zoo:&#39;, a SparseZoo Model object, or a SparseZoo ONNX File</span>
<span class="sd"> object that defines the neural network graph definition to analyze</span>
Expand Down
45 changes: 44 additions & 1 deletion deepsparse/_modules/deepsparse/utils/data.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,54 @@ <h1>Source code for deepsparse.utils.data</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">deepsparse.utils.log</span> <span class="kn">import</span> <span class="n">log_init</span>


<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;verify_outputs&quot;</span><span class="p">]</span>
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span>
<span class="s2">&quot;arrays_to_bytes&quot;</span><span class="p">,</span>
<span class="s2">&quot;bytes_to_arrays&quot;</span><span class="p">,</span>
<span class="s2">&quot;verify_outputs&quot;</span><span class="p">,</span>
<span class="p">]</span>

<span class="n">log</span> <span class="o">=</span> <span class="n">log_init</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="vm">__file__</span><span class="p">))</span>


<div class="viewcode-block" id="arrays_to_bytes"><a class="viewcode-back" href="../../../api/deepsparse.utils.html#deepsparse.utils.data.arrays_to_bytes">[docs]</a><span class="k">def</span> <span class="nf">arrays_to_bytes</span><span class="p">(</span><span class="n">arrays</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="nb">bytearray</span><span class="p">:</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> :param arrays: List of numpy arrays to serialize as bytes</span>
<span class="sd"> :return: bytearray representation of list of numpy arrays</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">to_return</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">()</span>
<span class="k">for</span> <span class="n">arr</span> <span class="ow">in</span> <span class="n">arrays</span><span class="p">:</span>
<span class="n">arr_dtype</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">arr</span><span class="o">.</span><span class="n">dtype</span><span class="p">),</span> <span class="s2">&quot;utf-8&quot;</span><span class="p">)</span>
<span class="n">arr_shape</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="s2">&quot;,&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="nb">str</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">arr</span><span class="o">.</span><span class="n">shape</span><span class="p">]),</span> <span class="s2">&quot;utf-8&quot;</span><span class="p">)</span>
<span class="n">sep</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="s2">&quot;|&quot;</span><span class="p">,</span> <span class="s2">&quot;utf-8&quot;</span><span class="p">)</span>
<span class="n">arr_bytes</span> <span class="o">=</span> <span class="n">arr</span><span class="o">.</span><span class="n">ravel</span><span class="p">()</span><span class="o">.</span><span class="n">tobytes</span><span class="p">()</span>
<span class="n">to_return</span> <span class="o">+=</span> <span class="n">arr_dtype</span> <span class="o">+</span> <span class="n">sep</span> <span class="o">+</span> <span class="n">arr_shape</span> <span class="o">+</span> <span class="n">sep</span> <span class="o">+</span> <span class="n">arr_bytes</span>
<span class="k">return</span> <span class="n">to_return</span></div>


<div class="viewcode-block" id="bytes_to_arrays"><a class="viewcode-back" href="../../../api/deepsparse.utils.html#deepsparse.utils.data.bytes_to_arrays">[docs]</a><span class="k">def</span> <span class="nf">bytes_to_arrays</span><span class="p">(</span><span class="n">serialized_arr</span><span class="p">:</span> <span class="nb">bytearray</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">]:</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> :param serialized_arr: bytearray representation of list of numpy arrays</span>
<span class="sd"> :return: List of numpy arrays decoded from input</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">sep</span> <span class="o">=</span> <span class="s2">&quot;|&quot;</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">&quot;utf-8&quot;</span><span class="p">)</span>
<span class="n">arrays</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">i_start</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">while</span> <span class="n">i_start</span> <span class="o">&lt;</span> <span class="nb">len</span><span class="p">(</span><span class="n">serialized_arr</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">i_0</span> <span class="o">=</span> <span class="n">serialized_arr</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">sep</span><span class="p">,</span> <span class="n">i_start</span><span class="p">)</span>
<span class="n">i_1</span> <span class="o">=</span> <span class="n">serialized_arr</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">sep</span><span class="p">,</span> <span class="n">i_0</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">arr_dtype</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="n">serialized_arr</span><span class="p">[</span><span class="n">i_start</span><span class="p">:</span><span class="n">i_0</span><span class="p">]</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">&quot;utf-8&quot;</span><span class="p">))</span>
<span class="n">arr_shape</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span>
<span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">serialized_arr</span><span class="p">[</span><span class="n">i_0</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">:</span> <span class="n">i_1</span><span class="p">]</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">&quot;utf-8&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;,&quot;</span><span class="p">)]</span>
<span class="p">)</span>
<span class="n">arr_num_bytes</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">prod</span><span class="p">(</span><span class="n">arr_shape</span><span class="p">)</span> <span class="o">*</span> <span class="n">arr_dtype</span><span class="o">.</span><span class="n">itemsize</span>
<span class="n">arr_str</span> <span class="o">=</span> <span class="n">serialized_arr</span><span class="p">[</span><span class="n">i_1</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">:</span> <span class="n">arr_num_bytes</span> <span class="o">+</span> <span class="p">(</span><span class="n">i_1</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)]</span>
<span class="n">arr</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">frombuffer</span><span class="p">(</span><span class="n">arr_str</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">arr_dtype</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">arr_shape</span><span class="p">)</span>
<span class="n">arrays</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arr</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span>

<span class="n">i_start</span> <span class="o">=</span> <span class="n">i_1</span> <span class="o">+</span> <span class="n">arr_num_bytes</span> <span class="o">+</span> <span class="mi">1</span>
<span class="k">return</span> <span class="n">arrays</span></div>


<div class="viewcode-block" id="verify_outputs"><a class="viewcode-back" href="../../../api/deepsparse.utils.html#deepsparse.utils.data.verify_outputs">[docs]</a><span class="k">def</span> <span class="nf">verify_outputs</span><span class="p">(</span>
<span class="n">outputs</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">],</span>
<span class="n">gt_outputs</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">],</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Given the architecture above, to run the DeepSparse Engine on the first four CPU

Appending `--preferred 1` is needed here since the DeepSparse Engine is being bound to CPUs on the second socket.

Note that using more than two sockets may not offer improvements over two sockets; if you have options, try different scenarios to see which setup is ideal for your use case. For batch size considerations, use an amount that is evenly divisible by the number of sockets you intend to use.
Note: When running on multiple sockets using a batch size that is evenly divisible by the number of sockets will yield the best performance.


## DeepSparse Engine and Thread Pinning
Expand Down
7 changes: 1 addition & 6 deletions deepsparse/_static/doctools.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@ if (!window.console || !console.firebug) {

/**
* 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, ' '));
return decodeURIComponent(x).replace(/\+/g, ' ');
};

/**
Expand Down
4 changes: 2 additions & 2 deletions deepsparse/_static/language_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];


/* Non-minified version is copied as a separate JS file, is available */

/* Non-minified version JS is _stemmer.js if file is provided */
/**
* Porter Stemmer
*/
Expand Down Expand Up @@ -200,6 +199,7 @@ var Stemmer = function() {




var splitChars = (function() {
var result = {};
var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,
Expand Down
7 changes: 1 addition & 6 deletions deepsparse/_static/pygments.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #eeffcc; }
.highlight { background: #eeffcc; }
.highlight .c { color: #408090; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
Expand Down
26 changes: 9 additions & 17 deletions deepsparse/_static/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ var Search = {
// results left, load the summary and display it
if (results.length) {
var item = results.pop();
var listItem = $('<li></li>');
var listItem = $('<li style="display:none"></li>');
var requestUrl = "";
var linkUrl = "";
if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') {
Expand All @@ -273,9 +273,9 @@ var Search = {
if (item[3]) {
listItem.append($('<span> (' + item[3] + ')</span>'));
Search.output.append(listItem);
setTimeout(function() {
listItem.slideDown(5, function() {
displayNextItem();
}, 5);
});
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
$.ajax({url: requestUrl,
dataType: "text",
Expand All @@ -285,16 +285,16 @@ var Search = {
listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
}
Search.output.append(listItem);
setTimeout(function() {
listItem.slideDown(5, function() {
displayNextItem();
}, 5);
});
}});
} else {
// no source available, just display title
Search.output.append(listItem);
setTimeout(function() {
listItem.slideDown(5, function() {
displayNextItem();
}, 5);
});
}
}
// search finished, update title and status message
Expand Down Expand Up @@ -379,13 +379,6 @@ var Search = {
return results;
},

/**
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
*/
escapeRegExp : function(string) {
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
},

/**
* search for full-text terms in the index
*/
Expand All @@ -409,14 +402,13 @@ var Search = {
];
// add support for partial matches
if (word.length > 2) {
var word_regex = this.escapeRegExp(word);
for (var w in terms) {
if (w.match(word_regex) && !terms[word]) {
if (w.match(word) && !terms[word]) {
_o.push({files: terms[w], score: Scorer.partialTerm})
}
}
for (var w in titleterms) {
if (w.match(word_regex) && !titleterms[word]) {
if (w.match(word) && !titleterms[word]) {
_o.push({files: titleterms[w], score: Scorer.partialTitle})
}
}
Expand Down
37 changes: 31 additions & 6 deletions deepsparse/_static/underscore.js

Large diffs are not rendered by default.

Loading

0 comments on commit c6dd356

Please sign in to comment.