Skip to content

Commit e8bc730

Browse files
Refactor MCTWrapper documentation and comments for clarity
1 parent cf197fd commit e8bc730

File tree

3 files changed

+19
-27
lines changed

3 files changed

+19
-27
lines changed

docs/api/api_docs/classes/Wrapper.html

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,10 @@ <h3>Navigation</h3>
5252
<p>The wrapper manages the complete quantization pipeline from model input to
5353
quantized model export, handling framework-specific configurations and
5454
Target Platform Capabilities (TPC) setup.</p>
55-
<p>Initialize MCTWrapper with default parameters.</p>
5655
<dl class="py method">
5756
<dt class="sig sig-object py" id="model_compression_toolkit.wrapper.mct_wrapper.MCTWrapper.quantize_and_export">
5857
<span class="sig-name descname"><span class="pre">quantize_and_export</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">float_model</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">representative_dataset</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">framework</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'pytorch'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'PTQ'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_mixed_precision</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">param_items</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#model_compression_toolkit.wrapper.mct_wrapper.MCTWrapper.quantize_and_export" title="Link to this definition"></a></dt>
59-
<dd><p>Main function to perform model quantization and export.
60-
The wrapper manages the complete quantization pipeline from model input to quantized model export,
61-
handling framework-specific configurations and Target Platform Capabilities (TPC) setup.</p>
58+
<dd><p>Main function to perform model quantization and export.</p>
6259
<dl class="field-list simple">
6360
<dt class="field-odd">Return type<span class="colon">:</span></dt>
6461
<dd class="field-odd"><p><span class="sphinx_autodoc_typehints-type"><code class="xref py py-data docutils literal notranslate"><span class="pre">Tuple</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>, <code class="xref py py-data docutils literal notranslate"><span class="pre">Any</span></code>]</span></p>
@@ -82,7 +79,7 @@ <h3>Navigation</h3>
8279
</dd>
8380
</dl>
8481
<p class="rubric">Examples</p>
85-
<p>Import MCT:</p>
82+
<p>Import MCT</p>
8683
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span><span class="w"> </span><span class="nn">model_compression_toolkit</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">mct</span>
8784
</pre></div>
8885
</div>
@@ -95,13 +92,13 @@ <h3>Navigation</h3>
9592
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">wrapper</span> <span class="o">=</span> <span class="n">mct</span><span class="o">.</span><span class="n">MCTWrapper</span><span class="p">()</span>
9693
</pre></div>
9794
</div>
98-
<p>set framework, method, and other parameters</p>
95+
<p>Set framework, method, and other parameters</p>
9996
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">framework</span> <span class="o">=</span> <span class="s1">&#39;tensorflow&#39;</span>
10097
<span class="gp">&gt;&gt;&gt; </span><span class="n">method</span> <span class="o">=</span> <span class="s1">&#39;PTQ&#39;</span>
10198
<span class="gp">&gt;&gt;&gt; </span><span class="n">use_mixed_precision</span> <span class="o">=</span> <span class="kc">False</span>
10299
</pre></div>
103100
</div>
104-
<p>set parameters if needed</p>
101+
<p>Set parameters if needed</p>
105102
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">param_items</span> <span class="o">=</span> <span class="p">[[</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">]</span><span class="o">...</span><span class="p">]</span>
106103
</pre></div>
107104
</div>
@@ -116,7 +113,7 @@ <h3>Navigation</h3>
116113
<span class="gp">... </span><span class="p">)</span>
117114
</pre></div>
118115
</div>
119-
<p><strong>Parameters</strong></p>
116+
<p><strong>Initialize MCTWrapper with default parameters</strong></p>
120117
<p>Users can update the following parameters in param_items.</p>
121118
<div class="admonition note">
122119
<p class="admonition-title">Note</p>
@@ -139,7 +136,7 @@ <h3>Navigation</h3>
139136
<tbody>
140137
<tr class="row-even"><td><p>sdsp_version</p></td>
141138
<td><p>‘3.14’</p></td>
142-
<td><p>By specifying the SDSP converter version, you can select the optimal quantization settings for IMX500.Here, we use the settings for SDSP Converter 3.14. For other settings, please see <a class="reference external" href="https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities">here</a></p></td>
139+
<td><p>By specifying the SDSP converter version, you can select the <a class="reference external" href="https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities">optimal quantization settings</a> for IMX500.</p></td>
143140
</tr>
144141
<tr class="row-odd"><td><p>save_model_path</p></td>
145142
<td><p>‘./qmodel.keras’ / ‘./qmodel.onnx’</p></td>
@@ -183,7 +180,7 @@ <h3>Navigation</h3>
183180
<tbody>
184181
<tr class="row-even"><td><p>sdsp_version</p></td>
185182
<td><p>‘3.14’</p></td>
186-
<td><p>By specifying the SDSP converter version, you can select the optimal quantization settings for IMX500.Here, we use the settings for SDSP Converter 3.14. For other settings, please see <a class="reference external" href="https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities">here</a></p></td>
183+
<td><p>By specifying the SDSP converter version, you can select the <a class="reference external" href="https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities">optimal quantization settings</a> for IMX500.</p></td>
187184
</tr>
188185
<tr class="row-odd"><td><p>save_model_path</p></td>
189186
<td><p>‘./qmodel.keras’ / ‘./qmodel.onnx’</p></td>
@@ -243,7 +240,7 @@ <h3>Navigation</h3>
243240
<tbody>
244241
<tr class="row-even"><td><p>sdsp_version</p></td>
245242
<td><p>‘3.14’</p></td>
246-
<td><p>By specifying the SDSP converter version, you can select the optimal quantization settings for IMX500.Here, we use the settings for SDSP Converter 3.14. For other settings, please see <a class="reference external" href="https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities">here</a></p></td>
243+
<td><p>By specifying the SDSP converter version, you can select the <a class="reference external" href="https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities">optimal quantization settings</a> for IMX500.</p></td>
247244
</tr>
248245
<tr class="row-odd"><td><p>save_model_path</p></td>
249246
<td><p>‘./qmodel.keras’ / ‘./qmodel.onnx’</p></td>
@@ -295,7 +292,7 @@ <h3>Navigation</h3>
295292
<tbody>
296293
<tr class="row-even"><td><p>sdsp_version</p></td>
297294
<td><p>‘3.14’</p></td>
298-
<td><p>By specifying the SDSP converter version, you can select the optimal quantization settings for IMX500.Here, we use the settings for SDSP Converter 3.14. For other settings, please see <a class="reference external" href="https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities">here</a></p></td>
295+
<td><p>By specifying the SDSP converter version, you can select the <a class="reference external" href="https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities">optimal quantization settings</a> for IMX500.</p></td>
299296
</tr>
300297
<tr class="row-odd"><td><p>save_model_path</p></td>
301298
<td><p>‘./qmodel.keras’ / ‘./qmodel.onnx’</p></td>

docs/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

model_compression_toolkit/wrapper/mct_wrapper.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ class MCTWrapper:
4141
quantized model export, handling framework-specific configurations and
4242
Target Platform Capabilities (TPC) setup.
4343
"""
44-
44+
4545
def __init__(self):
46-
"""Initialize MCTWrapper with default parameters."""
4746
self.params: Dict[str, Any] = {
4847
# TPC
4948
FW_NAME: 'pytorch',
@@ -474,8 +473,6 @@ def quantize_and_export(self, float_model: Any,
474473
) -> Tuple[bool, Any]:
475474
"""
476475
Main function to perform model quantization and export.
477-
The wrapper manages the complete quantization pipeline from model input to quantized model export,
478-
handling framework-specific configurations and Target Platform Capabilities (TPC) setup.
479476
480477
Args:
481478
float_model: The float model to be quantized.
@@ -495,7 +492,7 @@ def quantize_and_export(self, float_model: Any,
495492
496493
Examples:
497494
498-
Import MCT:
495+
Import MCT
499496
500497
>>> import model_compression_toolkit as mct
501498
@@ -508,13 +505,13 @@ def quantize_and_export(self, float_model: Any,
508505
509506
>>> wrapper = mct.MCTWrapper()
510507
511-
set framework, method, and other parameters
508+
Set framework, method, and other parameters
512509
513510
>>> framework = 'tensorflow'
514511
>>> method = 'PTQ'
515512
>>> use_mixed_precision = False
516513
517-
set parameters if needed
514+
Set parameters if needed
518515
519516
>>> param_items = [[key, value]...]
520517
@@ -529,10 +526,8 @@ def quantize_and_export(self, float_model: Any,
529526
... param_items=param_items
530527
... )
531528
529+
**Initialize MCTWrapper with default parameters**
532530
533-
534-
**Parameters**
535-
536531
Users can update the following parameters in param_items.
537532
538533
.. note::
@@ -545,7 +540,7 @@ def quantize_and_export(self, float_model: Any,
545540
:header: "Parameter Key", "Default Value", "Description"
546541
:widths: 30, 30, 40
547542
548-
"sdsp_version", "'3.14'", "By specifying the SDSP converter version, you can select the optimal quantization settings for IMX500.Here, we use the settings for SDSP Converter 3.14. For other settings, please see `here <https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities>`_"
543+
"sdsp_version", "'3.14'", "By specifying the SDSP converter version, you can select the `optimal quantization settings <https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities>`_ for IMX500."
549544
"save_model_path", "'./qmodel.keras' / './qmodel.onnx'", "Path to save quantized model (Keras/Pytorch)"
550545
"activation_error_method", "mct.core.QuantizationErrorMethod.MSE", "Activation quantization error method **(low priority)**"
551546
"weights_bias_correction", "True", "Enable weights bias correction **(low priority)**"
@@ -559,7 +554,7 @@ def quantize_and_export(self, float_model: Any,
559554
:header: "Parameter Key", "Default Value", "Description"
560555
:widths: 30, 30, 40
561556
562-
"sdsp_version", "'3.14'", "By specifying the SDSP converter version, you can select the optimal quantization settings for IMX500.Here, we use the settings for SDSP Converter 3.14. For other settings, please see `here <https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities>`_"
557+
"sdsp_version", "'3.14'", "By specifying the SDSP converter version, you can select the `optimal quantization settings <https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities>`_ for IMX500."
563558
"save_model_path", "'./qmodel.keras' / './qmodel.onnx'", "Path to save quantized model (Keras/Pytorch)"
564559
"num_of_images", "32", "Number of images for mixed precision"
565560
"weights_compression_ratio", "0.75", "Weights compression ratio for mixed precision for resource util (0.0~1.0)"
@@ -577,7 +572,7 @@ def quantize_and_export(self, float_model: Any,
577572
:header: "Parameter Key", "Default Value", "Description"
578573
:widths: 30, 30, 40
579574
580-
"sdsp_version", "'3.14'", "By specifying the SDSP converter version, you can select the optimal quantization settings for IMX500.Here, we use the settings for SDSP Converter 3.14. For other settings, please see `here <https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities>`_"
575+
"sdsp_version", "'3.14'", "By specifying the SDSP converter version, you can select the `optimal quantization settings <https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities>`_ for IMX500."
581576
"save_model_path", "'./qmodel.keras' / './qmodel.onnx'", "Path to save quantized model (Keras/Pytorch)"
582577
"n_epochs", "5", "Number of training epochs for GPTQ"
583578
"activation_error_method", "mct.core.QuantizationErrorMethod.MSE", "Activation quantization error method **(low priority)**"
@@ -593,7 +588,7 @@ def quantize_and_export(self, float_model: Any,
593588
:header: "Parameter Key", "Default Value", "Description"
594589
:widths: 30, 30, 40
595590
596-
"sdsp_version", "'3.14'", "By specifying the SDSP converter version, you can select the optimal quantization settings for IMX500.Here, we use the settings for SDSP Converter 3.14. For other settings, please see `here <https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities>`_"
591+
"sdsp_version", "'3.14'", "By specifying the SDSP converter version, you can select the `optimal quantization settings <https://sonysemiconductorsolutions.github.io/mct-model-optimization/api/api_docs/modules/target_platform_capabilities.html#ug-target-platform-capabilities>`_ for IMX500."
597592
"save_model_path", "'./qmodel.keras' / './qmodel.onnx'", "Path to save quantized model (Keras/Pytorch)"
598593
"num_of_images", "32", "Number of images for mixed precision"
599594
"weights_compression_ratio", "0.75", "Weights compression ratio for mixed precision for resource util (0.0~1.0)"

0 commit comments

Comments
 (0)