:py:mod:`pocketpose.utils.stats`
================================

.. py:module:: pocketpose.utils.stats

.. autoapi-nested-parse::

   The module for computing model statistics. 



Submodules
----------
.. toctree::
   :titlesonly:
   :maxdepth: 1

   tflite/index.rst


Package Contents
----------------


Functions
~~~~~~~~~

.. autoapisummary::

   pocketpose.utils.stats.estimate_flops_tflite
   pocketpose.utils.stats.estimate_parameters_tflite
   pocketpose.utils.stats.get_stats_tflite
   pocketpose.utils.stats.tabulate_stats



.. py:function:: estimate_flops_tflite(model_path: str) -> float

   Estimates the number of floating point operations in a TFLite model.

   Note: This is a rough estimate which only considers CONV_2D, DEPTHWISE_CONV_2D,
   FULLY_CONNECTED, ADD, and MUL operators.

   For FULLY_CONNECTED layer, we assume that the number of FLOPs is approximately 2
   times the number of elements in the weight matrix, which assumes that each weight
   participates in one multiplication and one addition.

   For ADD and MUL layers, we assume that each operation is performed element-wise,
   and so the number of FLOPs is equal to the total number of elements in the
   input tensor.

   Args:
       model_path (str): Path to TFLite model

   Returns:
       float: Number of estimated GFLOPs in the model


.. py:function:: estimate_parameters_tflite(model_path: str) -> int

   Estimates the number of parameters in a TFLite model.

   Args:
       model_path (str): Path to TFLite model

   Returns:
       int: Number of parameters in the model


.. py:function:: get_stats_tflite(model_path: str) -> tuple[str, dict[str, Any]]


.. py:function:: tabulate_stats(statistics)

   Converts raw statistics into list of dictionaries.

   Args:
       statistics (dict): The raw statistics.

   Returns:
       list of dict: The statistics in a tabular format. These can be
                     directly written to a table using the `tabulate` package
                     or the `write_to_table` function in `io` module.


