Skip to content

Inspector APIs Doc Updates #12701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions devtools/inspector/_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,17 +1362,19 @@ def get_exported_program(
else self._etrecord.graph_map.get(graph)
)

def calculate_numeric_gap(self, distance: str = "MSE") -> pd.DataFrame:
def calculate_numeric_gap(self, distance: str = "MSE"):
"""
Compares logged intermediate outputs from the exported graph (in ETRecord)
with runtime outputs (in ETDump) using a user-specific numerical comparator.
To use this function, you must first generate the ETRecord using the `bundle_program`,
and then create the Inspector instance with the ETRecord and ETDump. The Inspector can then
compare the intermediate outputs from the AOT and the runtime.

Args:
distance: the metrics the inspector will use for gap calculation. Should be one of "MSE", "L1" and "SNR".

Returns:
pd.DataFrame: A DataFrame listing corresponding operator outputs from
both stages and their computed numerical gaps.
pd.DataFrame: A DataFrame listing corresponding operator intermediate outputs from both stages and their computed numerical gaps.
"""
aot_intermediate_outputs, aot_debug_handle_to_op_name = (
self._get_aot_intermediate_outputs_and_op_names()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions docs/source/model-inspector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ get_exported_program
Equality constraints: []


calculate_numeric_gap
~~~~~~~~~~~~~~~~~~

.. autofunction:: executorch.devtools.Inspector.calculate_numeric_gap

.. _example-usage-4:

**Example Usage:**

.. code:: python

print(inspector.calculate_numeric_gap("L1"))

.. image:: _static/img/calculate_numeric_gap.png

Inspector Attributes
--------------------

Expand Down
Loading