|
| 1 | +--- |
| 2 | +title: "What is Model Explorer and what will you learn?" |
| 3 | + |
| 4 | +weight: 2 |
| 5 | + |
| 6 | +### FIXED, DO NOT MODIFY |
| 7 | +layout: "learningpathall" |
| 8 | +--- |
| 9 | + |
| 10 | +## Model Explorer and Arm extensions |
| 11 | + |
| 12 | +[Model Explorer](https://ai.google.dev/edge/model-explorer) is an open-source, web-based graph visualizer and debugger from Google AI Edge. It provides a hierarchical view of model graphs, lets you expand and collapse layers, search for nodes, inspect metadata, highlight inputs and outputs, compare models, and add overlays to graph nodes. The default version, [contained in this repository](https://github.com/google-ai-edge/model-explorer/) supports TFLite, TF, TFJS, MLIR, and PyTorch (Exported Program) formats. |
| 13 | + |
| 14 | +Model Explorer uses adapters and data providers to load formats beyond the built-in model types. The [ExecuTorch extension for Model Explorer](https://github.com/arm/executorch-extension-model-explorer) combines support for `.pte`, `.etrecord`, and `.etdp` files. Standalone `.tosa` and `.vgf` files use separate TOSA and VGF adapters. You install all three packages together in the next section. |
| 15 | + |
| 16 | +## What you will do |
| 17 | + |
| 18 | +This learning path is about model artifacts, not model training or export. You start from small pre-generated files and use each to gain an understanding of when you would use Model Explorer, and the insights you can gain. |
| 19 | + |
| 20 | +The artifacts covered in this learning path are: |
| 21 | + |
| 22 | +| Artifact | Model Explorer support | Workflow layer | Use it to inspect | |
| 23 | +| --- | --- | --- | --- | |
| 24 | +| `.pte` | PTE adapter in the ExecuTorch extension | ExecuTorch program | Delegate regions, backend partitioning, work outside delegates, and the deployed ExecuTorch graph | |
| 25 | +| `.tosa` | Separate TOSA adapter | Compiler/backend intermediate representation | Lowered operators, tensor shapes, quantized types, graph splits, and missed optimization opportunities | |
| 26 | +| `.vgf` | Separate VGF adapter | Graph artifact for the ML extensions for Vulkan | Inputs, outputs, constants, tensor metadata, graph connectivity, and SPIR-V graph modules | |
| 27 | +| `.etrecord` | ETRecord adapter in the ExecuTorch extension | Export-time profiling context | Graph structure, debug handles, operator names, and delegate metadata used to map runtime events back to graph nodes | |
| 28 | +| `.etdp` | ETDump data provider in the ExecuTorch extension | Runtime trace overlay | Timing data from a specific execution | |
| 29 | + |
| 30 | +This Learning Path focuses on Arm adapters and extensions for Model Explorer, but the artifacts repository also includes `.tflite` and `.pt2` files. You can optionally try these files because Model Explorer supports them without an additional adapter. |
| 31 | + |
| 32 | +{{% notice Note %}} |
| 33 | +Model Explorer visualizes the specific artifact you generated or received. Small differences in the target the model has been delegated to, could result in a very different model graph. For example, delegating the same model to an Ethos-U55, may produce a very different model graph from delegating to an Ethos-U85. |
| 34 | +{{% /notice %}} |
| 35 | + |
| 36 | +## Understand the model artifact flow |
| 37 | + |
| 38 | +Not every graph in this learning path needs to start with PyTorch and ExecuTorch. Let's run through what is specific to the ExecuTorch flow, and what is applicable more broadly. |
| 39 | + |
| 40 | +PTE is ExecuTorch-specific. A `.pte` file is the serialized ExecuTorch program loaded by the ExecuTorch runtime. Baseline portable-kernel, XNNPACK, Cortex-M, Ethos-U, and VGF-backend examples are all ExecuTorch deployment artifacts. |
| 41 | + |
| 42 | +The portable-kernel and XNNPACK routes are Cortex-A CPU routes. Cortex-M uses a separate ExecuTorch flow that applies CMSIS-NN-oriented passes for supported quantized operators. |
| 43 | + |
| 44 | +For Ethos-U, the ExecuTorch backend uses the Ethos-U Vela compiler to compile TOSA flatbuffers into an Ethos-U command stream that is packaged into the final `.pte`. |
| 45 | + |
| 46 | +TOSA is not inherently ExecuTorch-specific. TOSA is an intermediate representation (IR) that can sit between a model frontend and an Arm backend compiler or converter. ExecuTorch can lower supported graph partitions to TOSA, but another framework could also provide its own TOSA exporter and generate `.tosa` files. |
| 47 | + |
| 48 | +```output |
| 49 | + PyTorch model |
| 50 | + | |
| 51 | + v |
| 52 | + ExecuTorch export |
| 53 | + | |
| 54 | + +-- Cortex-A portable kernels -> baseline .pte |
| 55 | + | |
| 56 | + +-- Cortex-A XNNPACK delegate -> XNNPACK .pte |
| 57 | + | |
| 58 | + +-- Cortex-M CMSIS-NN passes -> Cortex-M .pte |
| 59 | + | |
| 60 | + +-- Lower to TOSA -------------+ |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + Alternative (non PT/ET) v |
| 65 | + frontend with TOSA export ---> TOSA (.tosa) |
| 66 | + | |
| 67 | + | |
| 68 | + +-- Ethos-U Vela |
| 69 | + | -> command stream |
| 70 | + | -> Ethos-U .pte |
| 71 | + | |
| 72 | + +-- ML SDK Model Converter |
| 73 | + -> VGF payload |
| 74 | + -> VGF-backend .pte |
| 75 | + -> standalone .vgf |
| 76 | + for workflows using the ML extensions for Vulkan |
| 77 | +``` |
| 78 | + |
| 79 | +For VGF, the ExecuTorch Arm VGF backend uses the [Arm ML SDK Model Converter](https://github.com/arm/ai-ml-sdk-model-converter) to produce a VGF backend payload from TOSA. But the Arm ML SDK Model Converter could be used to convert `.tosa` files generated from a different flow, so VGF is also not specific to just ExecuTorch. |
| 80 | + |
| 81 | +When ExecuTorch is used for VGF, a `.pte` is emitted as well. Use that VGF-backend `.pte` when you want to run through ExecuTorch. Use the standalone `.vgf` when you want to inspect or integrate the VGF artifact used with the ML extensions for Vulkan, such as in a neural graphics workflow. |
| 82 | + |
| 83 | +If you have used the [Arm Neural Graphics Model Gym](https://github.com/arm/neural-graphics-model-gym), then under the hood you have been using ExecuTorch to export your neural graphics model to VGF. If you are interested in learning more, try out the [Fine-tune neural graphics using Model Gym](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/model-training-gym/#:~:text=Upon%20completion%20of%20this%20Learning,and%20train%20neural%20graphics%20models) learning path, which briefly introduces Model Explorer. |
| 84 | + |
| 85 | +ETRecord and ETDump are additional, ExecuTorch-specific, artifacts. ETRecord is generated at export time and preserves the graph context needed for profiling attribution. ETDump is generated at runtime and records what actually happened when a `.pte` ran. Together, they let Model Explorer move from static inspection to runtime overlays: you can connect the graph structures you saw in the `.pte`, `.tosa`, and `.vgf` sections to operator and delegate events measured during execution. |
| 86 | + |
| 87 | +## Terminology |
| 88 | + |
| 89 | +A helpful glossary of different terms is provided below: |
| 90 | + |
| 91 | +| Term | Meaning in this learning path | |
| 92 | +| --- | --- | |
| 93 | +| Model | The neural network you want to deploy, before or after transformation by export and compiler tools. | |
| 94 | +| Framework | The software used to define or train the model, such as PyTorch. | |
| 95 | +| Export | The step that turns a framework model into a deployable or compiler-friendly representation. | |
| 96 | +| Artifact | A file produced by export, lowering, compilation, or conversion, such as `.pte`, `.tosa`, or `.vgf`. | |
| 97 | +| Runtime | The software on the target system that loads and executes a deployable artifact. ExecuTorch is the runtime for `.pte` files. | |
| 98 | +| Compiler | A tool that transforms an intermediate representation into a lower-level target representation, such as Vela compiling TOSA for Ethos-U. | |
| 99 | +| Lower | To transform a model or graph from a higher-level representation into a lower-level representation closer to a target backend. | |
| 100 | +| Convert | To change one artifact format into another, such as TOSA to VGF. | |
| 101 | +| Intermediate representation | A representation between the original model and the final target artifact. TOSA is the main intermediate representation in this learning path. | |
| 102 | +| Delegate | A backend-specific execution path that handles supported parts of a graph. Unsupported parts can remain outside the delegate, and can run on a CPU path only when the deployed runtime includes compatible kernels. | |
| 103 | +| Kernel | The code that executes a model operator for a specific runtime or backend, such as a portable ExecuTorch kernel or a CMSIS-NN kernel. | |
| 104 | +| Flatbuffer | A compact binary serialization format. TOSA flatbuffers store TOSA graphs; `.pte` files use a FlatBuffer-based ExecuTorch program format. | |
| 105 | +| SPIR-V | Standard Portable Intermediate Representation - Vulkan. SPIR-V modules inside VGF files describe the data graph used by the ML extensions for Vulkan. | |
| 106 | +| ETRecord | An ExecuTorch export-time debug artifact that preserves graph and delegate metadata for profiling attribution. | |
| 107 | +| ETDump | An ExecuTorch runtime trace artifact that can record operator, delegate, backend, timing, and cycle-count events from execution. The first Model Explorer overlay used in this Learning Path focuses on timing data. | |
| 108 | + |
| 109 | +## What models will I use? |
| 110 | + |
| 111 | +The hands-on sections will use a variety of pre-provided model artifacts. These are provided purely for educational purposes. |
| 112 | + |
| 113 | +```output |
| 114 | +ml-model-artifacts/ |
| 115 | +├── pte/ |
| 116 | +│ ├── mv2_cortex_m.pte |
| 117 | +│ ├── opt125m_cortex_a_portable.pte |
| 118 | +│ ├── opt125m_cortex_a_xnnpack.pte |
| 119 | +│ ├── mv2_fp32_ethos_u85.pte |
| 120 | +│ ├── mv2_int8_ethos_u85.pte |
| 121 | +│ ├── mv2_lrn_int8_ethos_u85.pte |
| 122 | +│ └── small_upscaler_ptq_vgf.pte |
| 123 | +├── tosa/ |
| 124 | +│ ├── mv2_fp32.tosa |
| 125 | +│ ├── mv2_int8.tosa |
| 126 | +│ ├── mv2_lrn_int8_1.tosa |
| 127 | +│ ├── mv2_lrn_int8_2.tosa |
| 128 | +│ ├── small_upscaler_ptq.tosa |
| 129 | +│ └── small_upscaler_qat.tosa |
| 130 | +├── vgf/ |
| 131 | +│ └── small_upscaler_ptq.vgf |
| 132 | +├── etrecord/ |
| 133 | +│ ├── opt125m_portable.etrecord |
| 134 | +│ ├── opt125m_xnnpack.etrecord |
| 135 | +│ ├── mobilenetv2_fp32_ethosu.etrecord |
| 136 | +│ ├── mobilenetv2_int8_ethosu.etrecord |
| 137 | +│ └── mobilenetv2_lrn_int8_ethosu.etrecord |
| 138 | +└── etdump/ |
| 139 | + ├── opt125m_portable.etdp |
| 140 | + ├── opt125m_xnnpack.etdp |
| 141 | + ├── mobilenetv2_fp32_ethosu.etdp |
| 142 | + ├── mobilenetv2_int8_ethosu.etdp |
| 143 | + └── mobilenetv2_lrn_int8_ethosu.etdp |
| 144 | +``` |
| 145 | + |
| 146 | +## What you have learned |
| 147 | + |
| 148 | +You have learned how the combined ExecuTorch extension and the separate TOSA and VGF adapters add artifact formats to Model Explorer. You have also seen how `.pte`, `.tosa`, `.vgf`, `.etrecord`, and `.etdp` files support Cortex-A, Cortex-M, Ethos-U, the ML extensions for Vulkan, and ExecuTorch profiling workflows. |
| 149 | + |
| 150 | +Next, you will install Model Explorer and the Arm extensions, then open the first `.pte` artifact. |
0 commit comments