Metadata-Version: 2.4
Name: etrecord-adapter-model-explorer
Version: 0.1.0
Summary: ETRecord adapter package for Model Explorer
License-Expression: Apache-2.0
Keywords: model-explorer,executorch,etrecord,visualization
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: <3.13,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: ai-edge-model-explorer<0.2.0,>=0.1.28
Requires-Dist: executorch>=1.2.0
Dynamic: license-file

<!---
SPDX-FileCopyrightText: Copyright 2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
SPDX-License-Identifier: Apache-2.0
--->

# ETRecord Adapter for Model Explorer

`etrecord-adapter-model-explorer` is the standalone Model Explorer adapter
for ExecuTorch `.etrecord` files.

This repository contains the ETRecord-specific adapter code, tests, and
fixtures. For a combined install that wires the PTE adapter, ETRecord adapter,
and ETDump data provider together, use the umbrella package
`executorch-extension-model-explorer`.

## Installation

Install the standalone adapter package:

```bash
pip install etrecord-adapter-model-explorer
```

The adapter expects an environment with the ExecuTorch Python packages
available.

## Usage

Run Model Explorer with the standalone ETRecord adapter enabled:

```bash
model-explorer --extensions=etrecord_adapter_model_explorer
```

Then open an `.etrecord` file.

## Delegate visibility

Delegated ExecuTorch programs often collapse a backend-supported subgraph into
an opaque `executorch_call_delegate` node. If an ETRecord is generated from the
post-delegation edge graph, this adapter can only display that delegate call for
the delegated region because the original edge operators are no longer present
in the recorded edge graph.

To keep the original operators visible, generate the ETRecord with the
pre-delegation `EdgeProgramManager` as `edge_dialect_program` and the delegated
`ExecutorchProgramManager` as `executorch_program`:

```python
import copy
import torch
from executorch.backends.arm import EthosUCompileSpec, EthosUPartitioner
from executorch.devtools import generate_etrecord
from executorch.exir import to_edge, to_edge_transform_and_lower

exported_program = torch.export.export(model.eval(), example_inputs)

edge_program = to_edge(exported_program)
edge_program_for_record = copy.deepcopy(edge_program)

compile_spec = EthosUCompileSpec("ethos-u55-128")
delegated_edge_program = to_edge_transform_and_lower(
    programs=exported_program,
    partitioner=[EthosUPartitioner(compile_spec)],
)
executorch_program = delegated_edge_program.to_executorch()

generate_etrecord(
    "model.etrecord",
    edge_dialect_program=edge_program_for_record,
    executorch_program=executorch_program,
)
```

Backends that emit delegate debug mapping can also let the adapter group those
operators under a delegate namespace such as
`delegates/CoreMLBackend/partition_0`. Backends that do not emit that mapping
can still show the pre-delegation operators, but delegate grouping may be
limited.

## Development

Local ETRecord test fixtures live under
`src/etrecord_adapter_model_explorer/tests/fixtures/`.

```bash
pytest
```
