|
749 | 749 | </tbody> |
750 | 750 | </table> |
751 | 751 | </div> |
752 | | -<section id="module-dpctl.program.utils"> |
753 | | -<span id="dpctl-program-utils"></span><h2><a class="reference internal" href="#module-dpctl.program.utils" title="dpctl.program.utils"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dpctl.program.utils</span></code></a><a class="headerlink" href="#module-dpctl.program.utils" title="Permalink to this heading">¶</a></h2> |
| 752 | +<section id="dpctl-compiler-utils"> |
| 753 | +<h2><a class="reference internal" href="#module-dpctl.compiler.utils" title="dpctl.compiler.utils"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dpctl.compiler.utils</span></code></a><a class="headerlink" href="#dpctl-compiler-utils" title="Permalink to this heading">¶</a></h2> |
| 754 | +<span class="target" id="module-dpctl.compiler.utils"></span><dl class="py function"> |
| 755 | +<dt class="sig sig-object py" id="dpctl.compiler.utils.parse_spirv_specializations"> |
| 756 | +<span class="sig-prename descclassname"><span class="pre">dpctl.compiler.utils.</span></span><span class="sig-name descname"><span class="pre">parse_spirv_specializations</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">spv_bytes</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytes" title="(in Python v3.14)"><span class="pre">bytes</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytearray" title="(in Python v3.14)"><span class="pre">bytearray</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#memoryview" title="(in Python v3.14)"><span class="pre">memoryview</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.14)"><span class="pre">tuple</span></a><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#dpctl.compiler.utils.SpecializationConstantInfo" title="dpctl.compiler.utils._utils.SpecializationConstantInfo"><span class="pre">dpctl.compiler.utils._utils.SpecializationConstantInfo</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../../_modules/dpctl/compiler/utils/_utils.html#parse_spirv_specializations"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dpctl.compiler.utils.parse_spirv_specializations" title="Permalink to this definition">¶</a></dt> |
| 757 | +<dd><p>Parses SPIR-V byte stream to extract information about specializations, |
| 758 | +including the specialization IDs, types, names, and default values.</p> |
| 759 | +<p>Note that the dtype information may be imprecise, as the compiler may |
| 760 | +choose to, for example, represent a bool as char, or may represent both |
| 761 | +signed and unsigned integers as unsigned integer bit buckets of the same |
| 762 | +length.</p> |
| 763 | +<dl class="field-list simple"> |
| 764 | +<dt class="field-odd">Parameters<span class="colon">:</span></dt> |
| 765 | +<dd class="field-odd"><p><strong>spv_bytes</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytes" title="(in Python v3.14)"><em>bytes</em></a><em> | </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytearray" title="(in Python v3.14)"><em>bytearray</em></a><em> | </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#memoryview" title="(in Python v3.14)"><em>memoryview</em></a>) – the SPIR-V byte stream.</p> |
| 766 | +</dd> |
| 767 | +<dt class="field-even">Returns<span class="colon">:</span></dt> |
| 768 | +<dd class="field-even"><p><p>a tuple of parsed constants and their information represented by |
| 769 | +<cite>SpecializationConstantInfo</cite> objects, sorted by their |
| 770 | +specialization IDs. The length of the tuple is equal to the number |
| 771 | +of specialization constants found. Each |
| 772 | +<cite>SpecializationConstantInfo</cite> object contains the following |
| 773 | +attributes:</p> |
| 774 | +<ul class="simple"> |
| 775 | +<li><p><cite>spec_id</cite> (int): The specialization ID.</p></li> |
| 776 | +<li><p><cite>dtype</cite> (str): A NumPy style string representing the data type.</p></li> |
| 777 | +<li><dl class="simple"> |
| 778 | +<dt><cite>itemsize</cite> (int): The size of the specialization constant in</dt><dd><p>bytes.</p> |
| 779 | +</dd> |
| 780 | +</dl> |
| 781 | +</li> |
| 782 | +<li><dl class="simple"> |
| 783 | +<dt><cite>name</cite> (str): The variable name. If not preserved in the binary,</dt><dd><p>a default name in the format <cite>unnamed_spec_const_{spec_id}</cite> is |
| 784 | +used.</p> |
| 785 | +</dd> |
| 786 | +</dl> |
| 787 | +</li> |
| 788 | +<li><dl class="simple"> |
| 789 | +<dt><cite>default_value</cite> (int | float | bool | None): The default value of</dt><dd><p>the specialization constant. If not specified, <cite>None</cite> is used.</p> |
| 790 | +</dd> |
| 791 | +</dl> |
| 792 | +</li> |
| 793 | +</ul> |
| 794 | +</p> |
| 795 | +</dd> |
| 796 | +<dt class="field-odd">Return type<span class="colon">:</span></dt> |
| 797 | +<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.14)">tuple</a>[<a class="reference internal" href="#dpctl.compiler.utils.SpecializationConstantInfo" title="dpctl.compiler.utils.SpecializationConstantInfo">SpecializationConstantInfo</a>]</p> |
| 798 | +</dd> |
| 799 | +</dl> |
| 800 | +</dd></dl> |
| 801 | + |
| 802 | +<dl class="py class"> |
| 803 | +<dt class="sig sig-object py" id="dpctl.compiler.utils.SpecializationConstantInfo"> |
| 804 | +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">dpctl.compiler.utils.</span></span><span class="sig-name descname"><span class="pre">SpecializationConstantInfo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">spec_id</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.14)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">dtype</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.14)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.14)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">itemsize</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.14)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">default_value</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.14)"><span class="pre">int</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.14)"><span class="pre">float</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.14)"><span class="pre">bool</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.14)"><span class="pre">None</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/dpctl/compiler/utils/_utils.html#SpecializationConstantInfo"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dpctl.compiler.utils.SpecializationConstantInfo" title="Permalink to this definition">¶</a></dt> |
| 805 | +<dd><p>Data class representing specialization constant information.</p> |
| 806 | +</dd></dl> |
| 807 | + |
754 | 808 | </section> |
755 | 809 | </section> |
756 | 810 |
|
|
810 | 864 | <div class="toc-tree"> |
811 | 865 | <ul> |
812 | 866 | <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dpctl.compiler</span></code></a><ul> |
813 | | -<li><a class="reference internal" href="#module-dpctl.program.utils"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dpctl.program.utils</span></code></a></li> |
| 867 | +<li><a class="reference internal" href="#dpctl-compiler-utils"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dpctl.compiler.utils</span></code></a><ul> |
| 868 | +<li><a class="reference internal" href="#dpctl.compiler.utils.parse_spirv_specializations"><code class="docutils literal notranslate"><span class="pre">parse_spirv_specializations()</span></code></a></li> |
| 869 | +<li><a class="reference internal" href="#dpctl.compiler.utils.SpecializationConstantInfo"><code class="docutils literal notranslate"><span class="pre">SpecializationConstantInfo</span></code></a></li> |
| 870 | +</ul> |
| 871 | +</li> |
814 | 872 | </ul> |
815 | 873 | </li> |
816 | 874 | </ul> |
|
0 commit comments