SIGN IN SIGN UP

Add ETDump support to MPS runtime (#1715)

Summary:
Summary of changes:
- Add `ETRecord` support to `mps_example` script
- Add `ETDump` support to `mps_runtime`

```bash
# Generates `add_mul_mps_bundled_fp32.pte` and `etrecord.bin`

python3 -m examples.apple.mps.scripts.mps_example --model_name="add_mul" --no-use_fp16 --bundled --generate_etrecord

# Build executor runner

## Build and install executorch
cmake -DBUCK2="$BUCK" \
          -DCMAKE_INSTALL_PREFIX=cmake-out \
          -DCMAKE_BUILD_TYPE=Release \
          -DEXECUTORCH_BUILD_SDK=ON \
          -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
          -DEXECUTORCH_BUILD_MPS=ON \
          -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
          -Bcmake-out .
cmake --build cmake-out -j9 --target install --config Release
CMAKE_PREFIX_PATH="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"

## build mps_executor_runner
rm -rf cmake-out/examples/apple/mps
cmake \
    -DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
    -DCMAKE_BUILD_TYPE=Release \
    -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
    -Bcmake-out/examples/apple/mps \
    examples/apple/mps
cmake --build cmake-out/examples/apple/mps -j9 --config Release

# Run executor runner. Generates `etdump.etdp`:
./cmake-out/examples/apple/mps/mps_executor_runner --model_path add_mul_mps_bundled_fp32.pte --bundled_program --dump_output

# Run the inspector cli tool to print the profiling results
python3 -m sdk.inspector.inspector_cli --etdump_path etdump.etdp --etrecord_path etrecord.bin
╒════╤════════════════════╤══════════════════════╤════════════╤════════════╤════════════╤════════════╤════════════╤════════════╤════════════╤═══════════════════╤═════════════════════════╕
│    │ event_block_name   │ event_name           │   p10 (ms) │   p50 (ms) │   p90 (ms) │   avg (ms) │   min (ms) │   max (ms) │ op_types   │ is_delegated_op   │ delegate_backend_name   │
╞════╪════════════════════╪══════════════════════╪════════════╪════════════╪════════════╪════════════╪════════════╪════════════╪════════════╪═══════════════════╪═════════════════════════╡
│  0 │ Default            │ Method::init         │   16.7222  │    16.7222 │    16.7222 │    16.7222 │  16.7222   │    16.7222 │ []         │ False             │                         │
├────┼────────────────────┼──────────────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼───────────────────┼─────────────────────────┤
│  1 │ Default            │ Program::load_method │   16.7285  │    16.7285 │    16.7285 │    16.7285 │  16.7285   │    16.7285 │ []         │ False             │                         │
├────┼────────────────────┼──────────────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼───────────────────┼─────────────────────────┤
│  2 │ Execute            │ DELEGATE_CALL        │    4.20317 │    19.4712 │    34.7392 │    19.4712 │   0.386167 │    38.5562 │ []         │ False             │                         │
├────┼────────────────────┼──────────────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼───────────────────┼─────────────────────────┤
│  3 │ Execute            │ Method::execute      │    4.21082 │    19.4848 │    34.7587 │    19.4848 │   0.392333 │    38.5772 │ []         │ False             │                         │
╘════╧════════════════════╧══════════════════════╧════════════╧════════════╧════════════╧════════════╧════════════╧════════════╧════════════╧═══════════════════╧═════════════════════════╛
```

cc tarun292, kimishpatel, shoumikhin, larryliu0820, cccclai

Pull Request resolved: https://github.com/pytorch/executorch/pull/1715

Reviewed By: cccclai

Differential Revision: D53111965

Pulled By: shoumikhin

fbshipit-source-id: 597284666aac23c926a98544a165b834a99b0315
D
Denis Vieriu committed
366960aa67ec39255a8dbe4d8cd3096a5f07eab0
Parent: 7b05f50
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 1/26/2024, 6:57:07 AM