Skip to content

Commit

Permalink
Docs: update docs for v0.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe5 committed Oct 10, 2024
1 parent 2c1d3c3 commit 92b6f99
Show file tree
Hide file tree
Showing 71 changed files with 5,008 additions and 3,552 deletions.
2 changes: 1 addition & 1 deletion docs/.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: d9a08019dec6882195fa0ef4f685a5cd
config: 029b3c75722303c51813ef033f4d07df
tags: 645f666f9bcd5a90fca523b33c5a78b7
6 changes: 3 additions & 3 deletions docs/_modules/brevitas/core/bit_width/const.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>brevitas.core.bit_width.const &#8212; Brevitas 0.10.2 documentation</title>
<title>brevitas.core.bit_width.const &#8212; Brevitas 0.11.0 documentation</title>



Expand Down Expand Up @@ -123,8 +123,8 @@



<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.10.2 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.10.2 documentation - Home"/>`);</script>
<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.11.0 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.11.0 documentation - Home"/>`);</script>


</a></div>
Expand Down
6 changes: 3 additions & 3 deletions docs/_modules/brevitas/core/bit_width/parameter.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>brevitas.core.bit_width.parameter &#8212; Brevitas 0.10.2 documentation</title>
<title>brevitas.core.bit_width.parameter &#8212; Brevitas 0.11.0 documentation</title>



Expand Down Expand Up @@ -123,8 +123,8 @@



<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.10.2 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.10.2 documentation - Home"/>`);</script>
<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.11.0 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.11.0 documentation - Home"/>`);</script>


</a></div>
Expand Down
94 changes: 91 additions & 3 deletions docs/_modules/brevitas/core/function_wrapper/clamp.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/_modules/brevitas/core/function_wrapper/misc.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>brevitas.core.function_wrapper.misc &#8212; Brevitas 0.10.2 documentation</title>
<title>brevitas.core.function_wrapper.misc &#8212; Brevitas 0.11.0 documentation</title>



Expand Down Expand Up @@ -123,8 +123,8 @@



<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.10.2 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.10.2 documentation - Home"/>`);</script>
<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.11.0 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.11.0 documentation - Home"/>`);</script>


</a></div>
Expand Down
6 changes: 3 additions & 3 deletions docs/_modules/brevitas/core/function_wrapper/ops_ste.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>brevitas.core.function_wrapper.ops_ste &#8212; Brevitas 0.10.2 documentation</title>
<title>brevitas.core.function_wrapper.ops_ste &#8212; Brevitas 0.11.0 documentation</title>



Expand Down Expand Up @@ -123,8 +123,8 @@



<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.10.2 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.10.2 documentation - Home"/>`);</script>
<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.11.0 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.11.0 documentation - Home"/>`);</script>


</a></div>
Expand Down
59 changes: 55 additions & 4 deletions docs/_modules/brevitas/core/function_wrapper/shape.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>brevitas.core.function_wrapper.shape &#8212; Brevitas 0.10.2 documentation</title>
<title>brevitas.core.function_wrapper.shape &#8212; Brevitas 0.11.0 documentation</title>



Expand Down Expand Up @@ -123,8 +123,8 @@



<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.10.2 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.10.2 documentation - Home"/>`);</script>
<img src="../../../../_static/brevitas_logo_black.svg" class="logo__image only-light" alt="Brevitas 0.11.0 documentation - Home"/>
<script>document.write(`<img src="../../../../_static/brevitas_logo_white.svg" class="logo__image only-dark" alt="Brevitas 0.11.0 documentation - Home"/>`);</script>


</a></div>
Expand Down Expand Up @@ -426,6 +426,7 @@ <h1>Source code for brevitas.core.function_wrapper.shape</h1><div class="highlig
<span class="kn">from</span> <span class="nn">brevitas.function.shape</span> <span class="kn">import</span> <span class="n">over_output_channels</span>
<span class="kn">from</span> <span class="nn">brevitas.function.shape</span> <span class="kn">import</span> <span class="n">over_output_features</span>
<span class="kn">from</span> <span class="nn">brevitas.function.shape</span> <span class="kn">import</span> <span class="n">over_tensor</span>
<span class="kn">from</span> <span class="nn">brevitas.utils.torch_utils</span> <span class="kn">import</span> <span class="n">padding</span>


<div class="viewcode-block" id="PermuteDims"><a class="viewcode-back" href="../../../../api_reference/brevitas.core.function_wrapper.html#brevitas.core.function_wrapper.shape.PermuteDims">[docs]</a><span class="k">class</span> <span class="nc">PermuteDims</span><span class="p">(</span><span class="n">brevitas</span><span class="o">.</span><span class="n">jit</span><span class="o">.</span><span class="n">ScriptModule</span><span class="p">):</span>
Expand Down Expand Up @@ -563,6 +564,54 @@ <h1>Source code for brevitas.core.function_wrapper.shape</h1><div class="highlig
<span class="k">return</span> <span class="n">y</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">shape</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="OverSubChannelBlockView"><a class="viewcode-back" href="../../../../api_reference/brevitas.core.function_wrapper.html#brevitas.core.function_wrapper.shape.OverSubChannelBlockView">[docs]</a><span class="k">class</span> <span class="nc">OverSubChannelBlockView</span><span class="p">(</span><span class="n">brevitas</span><span class="o">.</span><span class="n">jit</span><span class="o">.</span><span class="n">ScriptModule</span><span class="p">):</span>
<span class="n">__constants__</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;expanded_groupwise_shape&#39;</span><span class="p">,</span> <span class="s1">&#39;group_size&#39;</span><span class="p">,</span> <span class="s1">&#39;group_dim&#39;</span><span class="p">]</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expanded_groupwise_shape</span><span class="p">,</span> <span class="n">group_size</span><span class="p">,</span> <span class="n">group_dim</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="nb">super</span><span class="p">(</span><span class="n">OverSubChannelBlockView</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">expanded_groupwise_shape</span> <span class="o">=</span> <span class="n">expanded_groupwise_shape</span>
<span class="bp">self</span><span class="o">.</span><span class="n">group_dim</span> <span class="o">=</span> <span class="n">group_dim</span>
<span class="bp">self</span><span class="o">.</span><span class="n">group_size</span> <span class="o">=</span> <span class="n">group_size</span>

<div class="viewcode-block" id="OverSubChannelBlockView.forward"><a class="viewcode-back" href="../../../../api_reference/brevitas.core.function_wrapper.html#brevitas.core.function_wrapper.shape.OverSubChannelBlockView.forward">[docs]</a> <span class="nd">@brevitas</span><span class="o">.</span><span class="n">jit</span><span class="o">.</span><span class="n">script_method</span>
<span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">):</span>
<span class="c1"># This one is a bit tricky but we could end up here:</span>
<span class="c1"># - If we quantize the zero point, which will already have expanded shape matching the scale (although no padding, but we don&#39;t need the padding)</span>
<span class="c1"># - Groupwise HQO quantization, where weight will already have been padded and expanded</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expanded_groupwise_shape</span><span class="p">):</span>
<span class="k">return</span> <span class="n">x</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">functional</span><span class="o">.</span><span class="n">pad</span><span class="p">(</span>
<span class="n">x</span><span class="p">,</span> <span class="n">padding</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_size</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_dim</span><span class="p">),</span> <span class="n">mode</span><span class="o">=</span><span class="s1">&#39;constant&#39;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="mf">0.</span><span class="p">)</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">y</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expanded_groupwise_shape</span><span class="p">)</span>
<span class="k">return</span> <span class="n">y</span></div></div>


<div class="viewcode-block" id="DynamicOverSubChannelBlockView"><a class="viewcode-back" href="../../../../api_reference/brevitas.core.function_wrapper.html#brevitas.core.function_wrapper.shape.DynamicOverSubChannelBlockView">[docs]</a><span class="k">class</span> <span class="nc">DynamicOverSubChannelBlockView</span><span class="p">(</span><span class="n">brevitas</span><span class="o">.</span><span class="n">jit</span><span class="o">.</span><span class="n">ScriptModule</span><span class="p">):</span>
<span class="n">__constants__</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;group_size&#39;</span><span class="p">,</span> <span class="s1">&#39;group_dim&#39;</span><span class="p">]</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">group_size</span><span class="p">,</span> <span class="n">group_dim</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="nb">super</span><span class="p">(</span><span class="n">DynamicOverSubChannelBlockView</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">group_size</span> <span class="o">=</span> <span class="n">group_size</span>
<span class="bp">self</span><span class="o">.</span><span class="n">group_dim</span> <span class="o">=</span> <span class="n">group_dim</span>

<div class="viewcode-block" id="DynamicOverSubChannelBlockView.forward"><a class="viewcode-back" href="../../../../api_reference/brevitas.core.function_wrapper.html#brevitas.core.function_wrapper.shape.DynamicOverSubChannelBlockView.forward">[docs]</a> <span class="nd">@brevitas</span><span class="o">.</span><span class="n">jit</span><span class="o">.</span><span class="n">script_method</span>
<span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>

<span class="n">tensor_shape</span> <span class="o">=</span> <span class="n">x</span><span class="o">.</span><span class="n">shape</span>
<span class="n">tensor_shape_list</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">tensor_shape</span><span class="p">)</span>
<span class="n">pad</span> <span class="o">=</span> <span class="n">padding</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_size</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_dim</span><span class="p">)</span>

<span class="n">x</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">functional</span><span class="o">.</span><span class="n">pad</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">pad</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s1">&#39;constant&#39;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="mf">0.</span><span class="p">)</span>

<span class="n">tensor_shape</span> <span class="o">=</span> <span class="n">x</span><span class="o">.</span><span class="n">shape</span>
<span class="n">tensor_shape_list</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">tensor_shape</span><span class="p">)</span>
<span class="n">tensor_shape_list</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">group_dim</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">tensor_shape_list</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">group_dim</span><span class="p">]</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_size</span><span class="p">)</span>
<span class="n">block_dim</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_dim</span> <span class="o">+</span> <span class="mi">1</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_dim</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span> <span class="k">else</span> <span class="o">-</span><span class="mi">1</span>
<span class="n">tensor_shape_list</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">block_dim</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_size</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="n">tensor_shape_list</span><span class="p">)</span>
<span class="k">return</span> <span class="n">x</span></div></div>


<div class="viewcode-block" id="StatsInputViewShapeImpl"><a class="viewcode-back" href="../../../../api_reference/brevitas.core.function_wrapper.html#brevitas.core.function_wrapper.shape.StatsInputViewShapeImpl">[docs]</a><span class="k">class</span> <span class="nc">StatsInputViewShapeImpl</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Enum-like object to collect pointers to variants of ScriptModules that perform a view on a tensor.</span>
Expand All @@ -572,7 +621,9 @@ <h1>Source code for brevitas.core.function_wrapper.shape</h1><div class="highlig
<span class="n">OVER_OUTPUT_CHANNELS</span> <span class="o">=</span> <span class="n">OverOutputChannelView</span>
<span class="n">OVER_BATCH_OVER_TENSOR</span> <span class="o">=</span> <span class="n">OverBatchOverTensorView</span>
<span class="n">OVER_BATCH_OVER_OUTPUT_CHANNELS</span> <span class="o">=</span> <span class="n">OverBatchOverOutputChannelView</span>
<span class="n">OVER_OUTPUT_FEATURES</span> <span class="o">=</span> <span class="n">OverOutputFeaturesView</span></div>
<span class="n">OVER_OUTPUT_FEATURES</span> <span class="o">=</span> <span class="n">OverOutputFeaturesView</span>
<span class="n">OVER_SUBCHANNEL_BLOCK</span> <span class="o">=</span> <span class="n">OverSubChannelBlockView</span>
<span class="n">DYNAMIC_OVER_SUBCHANNEL_BLOCK</span> <span class="o">=</span> <span class="n">DynamicOverSubChannelBlockView</span></div>
</pre></div>

</article>
Expand Down
Loading

0 comments on commit 92b6f99

Please sign in to comment.