Skip to content

Commit

Permalink
Update docsrc (sony#989)
Browse files Browse the repository at this point in the history
* Automate manual parts of creating pages in docsrc Makefile.
* Remove the old API dir and use the experimental old dir as the current API in docsrs.
* Update documentation in classes that are auto-generated.
* Adapt docsrc to new API.

---------

Co-authored-by: reuvenp <reuvenp@altair-semi.com>
  • Loading branch information
reuvenperetz and reuvenp authored Mar 17, 2024
1 parent eceb70b commit 78f2f4d
Show file tree
Hide file tree
Showing 76 changed files with 760 additions and 736 deletions.
10 changes: 6 additions & 4 deletions docsrc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ github:
@cp -a ../docs/html/. ../docs
@rm -rf ../docs/html/
@rm -rf ../docs/doctrees/
@find ../docs -type f -exec sed -i 's|_images/|images/|g' {} +
@find ../docs -type f -exec sed -i 's|_static/|static/|g' {} +
@rm -rf ../docs/images
@rm -rf ../docs/static
@mv ../docs/_images/ ../docs/images
@mv ../docs/_static/ ../docs/static

# rm -rf ../docs/images/
# rm -rf ../docs/statis/
# mv ../docs/_images/ ../docs/images
# mv ../docs/_static/ ../docs/static


# You can set these variables from the command line, and also
Expand Down
68 changes: 68 additions & 0 deletions docsrc/source/api/api_docs/classes/DataGenerationConfig.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
:orphan:

.. _ug-DataGenerationConfig:

================================================
Data Generation Configuration
================================================

.. autoclass:: model_compression_toolkit.data_generation.DataGenerationConfig
:members:


ImageGranularity
================================================

.. autoclass:: model_compression_toolkit.data_generation.ImageGranularity
:members:


SchedulerType
================================================

.. autoclass:: model_compression_toolkit.data_generation.SchedulerType
:members:



BatchNormAlignemntLossType
================================================

.. autoclass:: model_compression_toolkit.data_generation.BatchNormAlignemntLossType
:members:


OutputLossType
================================================

.. autoclass:: model_compression_toolkit.data_generation.OutputLossType
:members:


DataInitType
================================================

.. autoclass:: model_compression_toolkit.data_generation.DataInitType
:members:


BNLayerWeightingType
================================================

.. autoclass:: model_compression_toolkit.data_generation.BNLayerWeightingType
:members:


ImagePipelineType
================================================

.. autoclass:: model_compression_toolkit.data_generation.ImagePipelineType
:members:


ImageNormalizationType
================================================

.. autoclass:: model_compression_toolkit.data_generation.ImageNormalizationType
:members:

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Folder Image Loader API

**The following API can be used to load a folder of images to create a representative dataset for PTQ calibration**

.. autoclass:: model_compression_toolkit.FolderImageLoader
.. autoclass:: model_compression_toolkit.core.FolderImageLoader
:members:


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FrameworkInfo Class

**The following API can be used to pass MCT framework-related information to use when optimizing the network**

.. autoclass:: model_compression_toolkit.FrameworkInfo
.. autoclass:: model_compression_toolkit.core.FrameworkInfo


|
Expand All @@ -19,5 +19,5 @@ ChannelAxis
==========================
**Enum to select the output channels format in the model:**

.. autoclass:: model_compression_toolkit.ChannelAxis
.. autoclass:: model_compression_toolkit.core.ChannelAxis

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

.. _ug-GradientPTQConfig:

=================================
GradientPTQConfigV2 Class
=================================

**The following API can be used to create a GradientPTQConfigV2 instance which can be used for post training quantization using knowledge distillation from a teacher (float model) to a student (the quantized model). This is experimental and subject to future changes.**

.. autoclass:: model_compression_toolkit.gptq.GradientPTQConfigV2
:members:


=================================
GradientPTQConfig Class
Expand All @@ -31,3 +22,11 @@ GPTQHessianScoresConfig Class

.. autoclass:: model_compression_toolkit.gptq.GPTQHessianScoresConfig
:members:


=================================
RoundingType
=================================

.. autoclass:: model_compression_toolkit.gptq.RoundingType
:members:
11 changes: 11 additions & 0 deletions docsrc/source/api/api_docs/classes/KPI.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:orphan:

.. _ug-KPI:


KPI
================================
**Object to configure resources to use when searching for a configuration for the optimized model (such as in mixed-precision, pruning, etc.):**

.. autoclass:: model_compression_toolkit.core.KPI

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:orphan:

.. _ug-MixedPrecisionQuantizationConfig:


MixedPrecisionQuantizationConfig
===================================
**Class to configure the quantization process of the model when quantizing in mixed-precision:**

.. autoclass:: model_compression_toolkit.core.MixedPrecisionQuantizationConfig

12 changes: 12 additions & 0 deletions docsrc/source/api/api_docs/classes/MpDistanceWeighting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:orphan:

.. _ug-MpDistanceWeighting:


=================================
MpDistanceWeighting
=================================

.. autoclass:: model_compression_toolkit.core.MpDistanceWeighting
:members:

30 changes: 30 additions & 0 deletions docsrc/source/api/api_docs/classes/PruningConfig.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
:orphan:

.. _ug-PruningConfig:

================================================
Pruning Configuration
================================================

.. autoclass:: model_compression_toolkit.pruning.PruningConfig
:members:


ImportanceMetric
================================================

.. autoclass:: model_compression_toolkit.pruning.ImportanceMetric
:members:


ChannelsFilteringStrategy
================================================

.. autoclass:: model_compression_toolkit.pruning.ChannelsFilteringStrategy
:members:






11 changes: 11 additions & 0 deletions docsrc/source/api/api_docs/classes/PruningInfo.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:orphan:

.. _ug-PruningInfo:

================================================
Pruning Information
================================================

.. autoclass:: model_compression_toolkit.pruning.PruningInfo
:members:

10 changes: 10 additions & 0 deletions docsrc/source/api/api_docs/classes/QuantizationConfig.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:orphan:

.. _ug-QuantizationConfig:


QuantizationConfig
==========================
**Class to configure the quantization process of the model:**

.. autoclass:: model_compression_toolkit.core.QuantizationConfig
11 changes: 11 additions & 0 deletions docsrc/source/api/api_docs/classes/QuantizationErrorMethod.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:orphan:

.. _ug-QuantizationErrorMethod:


QuantizationErrorMethod
==========================
**Enum to select a method for quantization parameters' selection:**

.. autoclass:: model_compression_toolkit.core.QuantizationErrorMethod

106 changes: 85 additions & 21 deletions docsrc/source/api/api_docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
API Docs
=========

.. note:: This API will be removed in future releases. Please switch to the :ref:`new API<ug-experimental_api_docs>`

**Init module for MCT API.**

.. code-block:: python
Expand All @@ -17,30 +15,96 @@ API Docs
|
Functions
=========
- :ref:`pytorch_post_training_quantization<ug-pytorch_post_training_quantization>`: Function to use for post training quantization of Pytorch models.
- :ref:`pytorch_post_training_quantization_mixed_precision<ug-pytorch_post_training_quantization_mixed_precision>`: Function to use for mixed-precision post training quantization of Pytorch models (experimental).
- :ref:`keras_post_training_quantization<ug-keras_post_training_quantization>`: Function to use for post training quantization of Keras models.
- :ref:`keras_post_training_quantization_mixed_precision<ug-keras_post_training_quantization_mixed_precision>`: Function to use for mixed-precision post training quantization of Keras models (experimental).
- :ref:`get_keras_gptq_config<ug-get_keras_gptq_config>`: Function to create a GradientPTQConfig instance to use for Keras models when using GPTQ (experimental).
- :ref:`get_target_platform_capabilities<ug-get_target_platform_capabilities>`: Function to get a target platform model for Tensorflow and Pytorch.
- :ref:`keras_kpi_data<ug-keras_kpi_data>`: Function to compute KPI data that can be used to calculate the desired target KPI for mixed-precision quantization of Keras models.
- :ref:`pytorch_kpi_data<ug-pytorch_kpi_data>`: Function to compute KPI data that can be used to calculate the desired target KPI for mixed-precision quantization of PyTorch models.

ptq
====

- :ref:`pytorch_post_training_quantization<ug-pytorch_post_training_quantization>`: A function to use for post training quantization of PyTorch models.
- :ref:`keras_post_training_quantization<ug-keras_post_training_quantization>`: A function to use for post training quantization of Keras models.

gptq
====

- :ref:`pytorch_gradient_post_training_quantization<ug-pytorch_gradient_post_training_quantization>`: A function to use for gradient-based post training quantization of Pytorch models.
- :ref:`get_pytorch_gptq_config<ug-get_pytorch_gptq_config>`: A function to create a GradientPTQConfig instance to use for Pytorch models when using GPTQ.

- :ref:`keras_gradient_post_training_quantization<ug-keras_gradient_post_training_quantization>`: A function to use for gradient-based post training quantization of Keras models.
- :ref:`get_keras_gptq_config<ug-get_keras_gptq_config>`: A function to create a GradientPTQConfig instance to use for Keras models when using GPTQ.

- :ref:`GradientPTQConfig<ug-GradientPTQConfig>`: Class to configure GradientPTQ options for gradient based post training quantization.

qat
====

- :ref:`pytorch_quantization_aware_training_init_experimental<ug-pytorch_quantization_aware_training_init_experimental>`: A function to use for preparing a Pytorch model for Quantization Aware Training (experimental).
- :ref:`pytorch_quantization_aware_training_finalize_experimental<ug-pytorch_quantization_aware_training_finalize_experimental>`: A function to finalize a Pytorch model after Quantization Aware Training to a model without QuantizeWrappers (experimental).
- :ref:`keras_quantization_aware_training_init_experimental<ug-keras_quantization_aware_training_init_experimental>`: A function to use for preparing a Keras model for Quantization Aware Training (experimental).
- :ref:`keras_quantization_aware_training_finalize_experimental<ug-keras_quantization_aware_training_finalize_experimental>`: A function to finalize a Keras model after Quantization Aware Training to a model without QuantizeWrappers (experimental).
- :ref:`qat_config<ug-qat_config>`: Module to create quantization configuration for Quantization-aware Training (experimental).

core
=====

- :ref:`CoreConfig<ug-CoreConfig>`: Module to contain configurations of the entire optimization process.
- :ref:`QuantizationConfig<ug-QuantizationConfig>`: Module to configure the quantization process.
- :ref:`QuantizationErrorMethod<ug-QuantizationErrorMethod>`: Select a method for quantization parameters' selection.
- :ref:`MixedPrecisionQuantizationConfig<ug-MixedPrecisionQuantizationConfig>`: Module to configure the quantization process when using mixed-precision PTQ.
- :ref:`KPI<ug-KPI>`: Module to configure resources to use when searching for a configuration for the optimized model.
- :ref:`MpDistanceWeighting<ug-MpDistanceWeighting>`: Mixed precision distance metric weighting methods.
- :ref:`network_editor<ug-network_editor>`: Module to modify the optimization process for troubleshooting.
- :ref:`FolderImageLoader<ug-FolderImageLoader>`: Class to use an images directory as a representative dataset.
- :ref:`pytorch_kpi_data<ug-pytorch_kpi_data>`: A function to compute KPI data that can be used to calculate the desired target KPI for PyTorch models.
- :ref:`keras_kpi_data<ug-keras_kpi_data>`: A function to compute KPI data that can be used to calculate the desired target KPI for Keras models.


data_generation
=================

- :ref:`pytorch_data_generation_experimental<ug-pytorch_data_generation_experimental>`: A function to generate data for a Pytorch model (experimental).
- :ref:`get_pytorch_data_generation_config<ug-get_pytorch_data_generation_config>`: A function to load a DataGenerationConfig for Pytorch data generation (experimental).
- :ref:`keras_data_generation_experimental<ug-keras_data_generation_experimental>`: A function to generate data for a Keras model (experimental).
- :ref:`get_keras_data_generation_config<ug-get_keras_data_generation_config>`: A function to generate a DataGenerationConfig for Tensorflow data generation (experimental).
- :ref:`DataGenerationConfig<ug-DataGenerationConfig>`: A configuration class for the data generation process (experimental).


Modules
pruning
===========

- :ref:`pytorch_pruning_experimental<ug-pytorch_pruning_experimental>`: A function to apply structured pruning for Pytorch models (experimental).
- :ref:`keras_pruning_experimental<ug-keras_pruning_experimental>`: A function to apply structured pruning for Keras models (experimental).

- :ref:`PruningConfig<ug-PruningConfig>`: Configuration for the pruning process (experimental).
- :ref:`PruningInfo<ug-PruningInfo>`: Information about the pruned model such as pruned channel indices, etc. (experimental).


exporter
=========
- :ref:`quantization_config<ug-quantization_config>`: Module to configure the quantization process.
- :ref:`mixed_precision_quantization_config<ug-mixed_precision_quantization_config>`: Module to configure the quantization process when using mixed-precision PTQ.
- :ref:`network_editor<ug-network_editor>`: Module to edit your model during the quantization process.

- :ref:`exporter<ug-exporter>`: Module that enables to export a quantized model in different serialization formats.


trainable_infrastructure
=========================

- :ref:`trainable_infrastructure<ug-trainable_infrastructure>`: Module that contains quantization abstraction and quantizers for hardware-oriented model optimization tools.



set_log_folder
================
- :ref:`set_log_folder<ug-set_log_folder>`: Function to set the logger path directory and to enable logging.

keras_load_quantized_model
============================
- :ref:`keras_load_quantized_model<ug-keras_load_quantized_model>`: A function to load a quantized keras model.


target_platform
================
- :ref:`target_platform<ug-target_platform>`: Module to create and model hardware-related settings to optimize the model according to, by the hardware the optimized model will use during inference.
- :ref:`get_target_platform_capabilities<ug-get_target_platform_capabilities>`: A function to get a target platform model for Tensorflow and Pytorch.
- :ref:`DefaultDict<ug-DefaultDict>`: Util class for creating a TargetPlatformCapabilities.

Classes
=========
- :ref:`GradientPTQConfig<ug-GradientPTQConfig>`: Class to configure GradientPTQC options for gradient based post training quantization.
- :ref:`FolderImageLoader<ug-FolderImageLoader>`: Class to use an images directory as a representative dataset.
- :ref:`FrameworkInfo<ug-FrameworkInfo>`: Class to wrap framework information to be used by MCT when optimizing models.

Indices and tables
==================
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:orphan:

.. _ug-keras_data_generation_experimental:


=====================================
Keras Data Generation
=====================================

.. autofunction:: model_compression_toolkit.data_generation.keras_data_generation_experimental
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
:orphan:

.. _ug-keras_gradient_post_training_quantization_experimental:
.. _ug-keras_gradient_post_training_quantization:


================================================
Keras Gradient Based Post Training Quantization
================================================

.. autofunction:: model_compression_toolkit.gptq.keras_gradient_post_training_quantization_experimental
.. autofunction:: model_compression_toolkit.gptq.keras_gradient_post_training_quantization
2 changes: 1 addition & 1 deletion docsrc/source/api/api_docs/methods/keras_kpi_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
Get KPI information for Keras Models
=======================================

.. autofunction:: model_compression_toolkit.keras_kpi_data
.. autofunction:: model_compression_toolkit.core.keras_kpi_data
Loading

0 comments on commit 78f2f4d

Please sign in to comment.