From 747f30de2c573815ecb3406fc6572696377bbf24 Mon Sep 17 00:00:00 2001 From: Olivia Liu Date: Thu, 25 Jul 2024 00:16:47 -0700 Subject: [PATCH] copy sdk to dev_tools, add dev_tools to visibility config Differential Revision: D60210170 --- .ci/docker/ubuntu/Dockerfile | 2 +- CMakeLists.txt | 10 +- README.md | 4 +- backends/apple/coreml/CMakeLists.txt | 4 +- backends/apple/mps/TARGETS | 4 +- backends/apple/mps/setup.md | 6 +- backends/apple/mps/targets.bzl | 2 +- backends/apple/mps/test/test_mps_utils.py | 6 +- backends/qualcomm/scripts/build.sh | 2 +- backends/qualcomm/setup.md | 2 +- backends/qualcomm/tests/utils.py | 4 +- backends/xnnpack/test/TARGETS | 6 +- backends/xnnpack/test/test_xnnpack_utils.py | 12 +- build/Utils.cmake | 2 +- {sdk => dev_tools}/CMakeLists.txt | 22 +-- {sdk => dev_tools}/TARGETS | 6 +- {sdk => dev_tools}/__init__.py | 8 +- {sdk => dev_tools}/bundled_program/TARGETS | 4 +- .../bundled_program/bundled_program.cpp | 4 +- .../bundled_program/bundled_program.h | 0 {sdk => dev_tools}/bundled_program/config.py | 0 {sdk => dev_tools}/bundled_program/core.py | 10 +- .../bundled_program/schema/README.md | 0 .../bundled_program/schema/TARGETS | 4 +- .../bundled_program/schema/__init__.py | 0 .../schema/bundled_program_schema.fbs | 0 .../schema/bundled_program_schema.py | 0 .../bundled_program/schema/scalar_type.fbs | 0 .../bundled_program/schema/targets.bzl | 6 +- .../bundled_program/schema/test/TARGETS | 0 .../schema/test/test_schema.py | 4 +- .../bundled_program/serialize/TARGETS | 8 +- .../bundled_program/serialize/__init__.py | 4 +- .../bundled_program/serialize/test/TARGETS | 6 +- .../serialize/test/test_serialize.py | 8 +- .../bundled_program/targets.bzl | 2 +- .../bundled_program/test/TARGETS | 20 +-- .../bundled_program/test/test_bundle_data.py | 10 +- .../bundled_program/test/test_config.py | 6 +- .../bundled_program/test/test_end2end.py | 6 +- .../bundled_program/util/TARGETS | 4 +- .../bundled_program/util/test_util.py | 6 +- {sdk => dev_tools}/bundled_program/version.py | 0 {sdk => dev_tools}/debug_format/TARGETS | 0 .../debug_format/base_schema.py | 2 +- {sdk => dev_tools}/debug_format/et_schema.py | 4 +- {sdk => dev_tools}/etdump/TARGETS | 6 +- {sdk => dev_tools}/etdump/emitter.cpp | 2 +- {sdk => dev_tools}/etdump/emitter.h | 2 +- {sdk => dev_tools}/etdump/etdump_flatcc.cpp | 8 +- {sdk => dev_tools}/etdump/etdump_flatcc.h | 0 .../etdump/etdump_schema_flatcc.fbs | 0 {sdk => dev_tools}/etdump/scalar_type.fbs | 0 {sdk => dev_tools}/etdump/schema_flatcc.py | 2 +- {sdk => dev_tools}/etdump/serialize.py | 2 +- {sdk => dev_tools}/etdump/targets.bzl | 0 .../etdump/tests/CMakeLists.txt | 6 +- {sdk => dev_tools}/etdump/tests/TARGETS | 4 +- .../etdump/tests/etdump_test.cpp | 6 +- .../etdump/tests/serialize_test.py | 6 +- {sdk => dev_tools}/etdump/tests/targets.bzl | 4 +- {sdk => dev_tools}/etrecord/TARGETS | 4 +- {sdk => dev_tools}/etrecord/__init__.py | 2 +- {sdk => dev_tools}/etrecord/_etrecord.py | 10 +- {sdk => dev_tools}/etrecord/tests/TARGETS | 12 +- .../etrecord/tests/etrecord_test.py | 12 +- {sdk => dev_tools}/inspector/TARGETS | 18 +-- {sdk => dev_tools}/inspector/__init__.py | 9 +- {sdk => dev_tools}/inspector/_inspector.py | 16 +- .../inspector/_inspector_utils.py | 12 +- {sdk => dev_tools}/inspector/inspector_cli.py | 4 +- dev_tools/inspector/tests/TARGETS | 41 +++++ .../inspector/tests/event_blocks_test.py | 8 +- .../inspector/tests/inspector_test.py | 23 ++- .../inspector/tests/inspector_utils_test.py | 12 +- {sdk => dev_tools}/size_analysis_tool/TARGETS | 8 +- .../size_analysis_tool/size_analysis_tool.py | 2 +- .../size_analysis_tool_test.py | 6 +- dev_tools/targets.bzl | 8 + dev_tools/test/run_oss_cpp_tests.sh | 147 +++++++++++++++++ .../img/how-executorch-works-high-level.png | Bin 507262 -> 507268 bytes docs/source/build-run-coreml.md | 6 +- ...d-run-qualcomm-ai-engine-direct-backend.md | 2 +- .../compiler-delegate-and-partitioner.md | 8 +- docs/source/concepts.md | 4 +- ...-bundled-io.md => dev-tools-bundled-io.md} | 40 ++--- ...dk-debugging.md => dev-tools-debugging.md} | 18 +-- ...n.md => dev-tools-delegate-integration.md} | 4 +- .../{sdk-etdump.md => dev-tools-etdump.md} | 8 +- ...dk-etrecord.rst => dev-tools-etrecord.rst} | 8 +- ...-inspector.rst => dev-tools-inspector.rst} | 24 +-- ...{sdk-overview.md => dev-tools-overview.md} | 26 +-- ...dk-profiling.md => dev-tools-profiling.md} | 14 +- docs/source/dev-tools-tutorial.md | 3 + docs/source/extension-module.md | 4 +- docs/source/getting-started-architecture.md | 6 +- docs/source/index.rst | 30 ++-- docs/source/intro-how-it-works.md | 2 +- docs/source/llm/getting-started.md | 18 +-- ...e-delegates-executorch-xnnpack-delegate.md | 2 +- docs/source/runtime-overview.md | 4 +- docs/source/sdk-tutorial.md | 3 - ...l.py => dev-tools-integration-tutorial.py} | 46 +++--- .../website/docs/tutorials/bundled_program.md | 4 +- examples/README.md | 6 +- examples/apple/coreml/executor_runner/main.mm | 2 +- .../coreml/scripts/build_executor_runner.sh | 4 +- examples/apple/coreml/scripts/export.py | 2 +- .../apple/coreml/scripts/inspector_cli.py | 4 +- examples/apple/mps/CMakeLists.txt | 4 +- examples/apple/mps/README.md | 2 +- .../executor_runner/mps_executor_runner.mm | 4 +- .../apple/mps/executor_runner/targets.bzl | 4 +- .../mps/scripts/build_mps_executor_runner.sh | 2 +- examples/apple/mps/scripts/mps_example.py | 6 +- examples/apple/mps/test_mps.sh | 6 +- examples/{sdk => dev_tools}/CMakeLists.txt | 12 +- examples/{sdk => dev_tools}/README.md | 26 +-- .../build_dev_tools_example_runner.sh} | 12 +- .../dev_tools_example_runner}/TARGETS | 0 .../dev_tools_example_runner.cpp} | 4 +- .../dev_tools_example_runner}/targets.bzl | 8 +- examples/dev_tools/scripts/TARGETS | 29 ++++ .../{sdk => dev_tools}/scripts/etrecord.bin | Bin 15843 -> 15855 bytes .../scripts/export_bundled_program.py | 148 ++++++++++++++++++ .../dev_tools/scripts/gen_sample_etrecord.py | 86 ++++++++++ .../test_dev_tools_example_runner.sh} | 20 +-- examples/models/llama2/TARGETS | 2 +- examples/models/llama2/export_llama_lib.py | 4 +- .../models/llama2/params/demo_rand_params.pth | Bin 1600376 -> 1600388 bytes .../executor_runner/qnn_executor_runner.cpp | 2 +- examples/qualcomm/scripts/export_example.py | 2 +- .../sdk/scripts/export_bundled_program.py | 12 +- examples/sdk/scripts/gen_sample_etrecord.py | 2 +- examples/xnnpack/aot_compiler.py | 2 +- examples/xnnpack/targets.bzl | 2 +- exir/_serialize/TARGETS | 12 +- extension/pybindings/pybindings.cpp | 6 +- extension/pybindings/pybindings.pyi | 5 +- kernels/README.md | 2 +- pytest.ini | 4 +- runtime/core/event_tracer.h | 4 +- runtime/core/targets.bzl | 16 +- runtime/executor/test/targets.bzl | 4 +- schema/targets.bzl | 2 +- sdk/inspector/tests/TARGETS | 40 ----- sdk/targets.bzl | 8 - setup.py | 12 +- shim/xplat/executorch/build/env_interface.bzl | 6 +- .../extension/pybindings/pybindings.bzl | 12 +- test/end2end/TARGETS | 12 +- .../generate_linear_out_bundled_program.py | 10 +- test/models/targets.bzl | 6 +- test/run_oss_cpp_tests.sh | 4 +- 154 files changed, 961 insertions(+), 529 deletions(-) rename {sdk => dev_tools}/CMakeLists.txt (89%) rename {sdk => dev_tools}/TARGETS (53%) rename {sdk => dev_tools}/__init__.py (56%) rename {sdk => dev_tools}/bundled_program/TARGETS (88%) rename {sdk => dev_tools}/bundled_program/bundled_program.cpp (98%) rename {sdk => dev_tools}/bundled_program/bundled_program.h (100%) rename {sdk => dev_tools}/bundled_program/config.py (100%) rename {sdk => dev_tools}/bundled_program/core.py (98%) rename {sdk => dev_tools}/bundled_program/schema/README.md (100%) rename {sdk => dev_tools}/bundled_program/schema/TARGETS (84%) rename {sdk => dev_tools}/bundled_program/schema/__init__.py (100%) rename {sdk => dev_tools}/bundled_program/schema/bundled_program_schema.fbs (100%) rename {sdk => dev_tools}/bundled_program/schema/bundled_program_schema.py (100%) rename {sdk => dev_tools}/bundled_program/schema/scalar_type.fbs (100%) rename {sdk => dev_tools}/bundled_program/schema/targets.bzl (93%) rename {sdk => dev_tools}/bundled_program/schema/test/TARGETS (100%) rename {sdk => dev_tools}/bundled_program/schema/test/test_schema.py (79%) rename {sdk => dev_tools}/bundled_program/serialize/TARGETS (76%) rename {sdk => dev_tools}/bundled_program/serialize/__init__.py (97%) rename {sdk => dev_tools}/bundled_program/serialize/test/TARGETS (59%) rename {sdk => dev_tools}/bundled_program/serialize/test/test_serialize.py (82%) rename {sdk => dev_tools}/bundled_program/targets.bzl (91%) rename {sdk => dev_tools}/bundled_program/test/TARGETS (68%) rename {sdk => dev_tools}/bundled_program/test/test_bundle_data.py (93%) rename {sdk => dev_tools}/bundled_program/test/test_config.py (97%) rename {sdk => dev_tools}/bundled_program/test/test_end2end.py (92%) rename {sdk => dev_tools}/bundled_program/util/TARGETS (68%) rename {sdk => dev_tools}/bundled_program/util/test_util.py (99%) rename {sdk => dev_tools}/bundled_program/version.py (100%) rename {sdk => dev_tools}/debug_format/TARGETS (100%) rename {sdk => dev_tools}/debug_format/base_schema.py (95%) rename {sdk => dev_tools}/debug_format/et_schema.py (99%) rename {sdk => dev_tools}/etdump/TARGETS (80%) rename {sdk => dev_tools}/etdump/emitter.cpp (98%) rename {sdk => dev_tools}/etdump/emitter.h (92%) rename {sdk => dev_tools}/etdump/etdump_flatcc.cpp (98%) rename {sdk => dev_tools}/etdump/etdump_flatcc.h (100%) rename {sdk => dev_tools}/etdump/etdump_schema_flatcc.fbs (100%) rename {sdk => dev_tools}/etdump/scalar_type.fbs (100%) rename {sdk => dev_tools}/etdump/schema_flatcc.py (97%) rename {sdk => dev_tools}/etdump/serialize.py (98%) rename {sdk => dev_tools}/etdump/targets.bzl (100%) rename {sdk => dev_tools}/etdump/tests/CMakeLists.txt (85%) rename {sdk => dev_tools}/etdump/tests/TARGETS (75%) rename {sdk => dev_tools}/etdump/tests/etdump_test.cpp (99%) rename {sdk => dev_tools}/etdump/tests/serialize_test.py (97%) rename {sdk => dev_tools}/etdump/tests/targets.bzl (82%) rename {sdk => dev_tools}/etrecord/TARGETS (71%) rename {sdk => dev_tools}/etrecord/__init__.py (85%) rename {sdk => dev_tools}/etrecord/_etrecord.py (98%) rename {sdk => dev_tools}/etrecord/tests/TARGETS (63%) rename {sdk => dev_tools}/etrecord/tests/etrecord_test.py (95%) rename {sdk => dev_tools}/inspector/TARGETS (69%) rename {sdk => dev_tools}/inspector/__init__.py (60%) rename {sdk => dev_tools}/inspector/_inspector.py (99%) rename {sdk => dev_tools}/inspector/_inspector_utils.py (97%) rename {sdk => dev_tools}/inspector/inspector_cli.py (93%) create mode 100644 dev_tools/inspector/tests/TARGETS rename {sdk => dev_tools}/inspector/tests/event_blocks_test.py (98%) rename {sdk => dev_tools}/inspector/tests/inspector_test.py (97%) rename {sdk => dev_tools}/inspector/tests/inspector_utils_test.py (94%) rename {sdk => dev_tools}/size_analysis_tool/TARGETS (85%) rename {sdk => dev_tools}/size_analysis_tool/size_analysis_tool.py (99%) rename {sdk => dev_tools}/size_analysis_tool/size_analysis_tool_test.py (98%) create mode 100644 dev_tools/targets.bzl create mode 100755 dev_tools/test/run_oss_cpp_tests.sh rename docs/source/{sdk-bundled-io.md => dev-tools-bundled-io.md} (90%) rename docs/source/{sdk-debugging.md => dev-tools-debugging.md} (71%) rename docs/source/{sdk-delegate-integration.md => dev-tools-delegate-integration.md} (99%) rename docs/source/{sdk-etdump.md => dev-tools-etdump.md} (76%) rename docs/source/{sdk-etrecord.rst => dev-tools-etrecord.rst} (79%) rename docs/source/{sdk-inspector.rst => dev-tools-inspector.rst} (80%) rename docs/source/{sdk-overview.md => dev-tools-overview.md} (52%) rename docs/source/{sdk-profiling.md => dev-tools-profiling.md} (50%) create mode 100644 docs/source/dev-tools-tutorial.md delete mode 100644 docs/source/sdk-tutorial.md rename docs/source/tutorials_source/{sdk-integration-tutorial.py => dev-tools-integration-tutorial.py} (86%) rename examples/{sdk => dev_tools}/CMakeLists.txt (79%) rename examples/{sdk => dev_tools}/README.md (66%) rename examples/{sdk/build_sdk_example_runner.sh => dev_tools/build_dev_tools_example_runner.sh} (78%) rename examples/{sdk/sdk_example_runner => dev_tools/dev_tools_example_runner}/TARGETS (100%) rename examples/{sdk/sdk_example_runner/sdk_example_runner.cpp => dev_tools/dev_tools_example_runner/dev_tools_example_runner.cpp} (98%) rename examples/{sdk/sdk_example_runner => dev_tools/dev_tools_example_runner}/targets.bzl (82%) create mode 100644 examples/dev_tools/scripts/TARGETS rename examples/{sdk => dev_tools}/scripts/etrecord.bin (54%) create mode 100644 examples/dev_tools/scripts/export_bundled_program.py create mode 100644 examples/dev_tools/scripts/gen_sample_etrecord.py rename examples/{sdk/test_sdk_example_runner.sh => dev_tools/test_dev_tools_example_runner.sh} (71%) delete mode 100644 sdk/inspector/tests/TARGETS delete mode 100644 sdk/targets.bzl diff --git a/.ci/docker/ubuntu/Dockerfile b/.ci/docker/ubuntu/Dockerfile index 449cd14b6b..43d914bc34 100644 --- a/.ci/docker/ubuntu/Dockerfile +++ b/.ci/docker/ubuntu/Dockerfile @@ -80,7 +80,7 @@ RUN rm install_android.sh ARG ARM_SDK COPY --chown=ci-user:ci-user ./arm /opt/arm # Set up ARM SDK if needed -RUN if [ -n "${ARM_SDK}" ]; then git config --global user.email "ossci@example.com"; git config --global user.name "OSS CI"; bash /opt/arm/setup.sh --i-agree-to-the-contained-eula /opt/arm-sdk; chown -R ci-user:ci-user /opt/arm-sdk; fi +RUN if [ -n "${ARM_SDK}" ]; then git config --global user.email "ossci@example.com"; git config --global user.name "OSS CI"; bash /opt/arm/setup.sh --i-agree-to-the-contained-eula /opt/arm-dev_tools; chown -R ci-user:ci-user /opt/arm-dev_tools; fi USER ci-user CMD ["bash"] diff --git a/CMakeLists.txt b/CMakeLists.txt index 897fdefd14..1da48d4a22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -187,7 +187,7 @@ option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED "Build the optimized kernels" OFF) option(EXECUTORCH_BUILD_KERNELS_QUANTIZED "Build the quantized kernels" OFF) -option(EXECUTORCH_BUILD_SDK "Build the ExecuTorch SDK") +option(EXECUTORCH_BUILD_DEV_TOOLS "Build the ExecuTorch Developer Tools") option(EXECUTORCH_BUILD_SIZE_TEST "Build the size test" OFF) @@ -604,12 +604,12 @@ if(EXECUTORCH_BUILD_GTESTS) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/googletest) endif() -if(EXECUTORCH_BUILD_SDK) +if(EXECUTORCH_BUILD_DEV_TOOLS) set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON CACHE BOOL "EXECUTORCH_BUILD_EXTENSION_DATA_LOADER" FORCE ) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/sdk) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dev_tools) endif() if(EXECUTORCH_BUILD_EXTENSION_APPLE) @@ -663,8 +663,8 @@ if(EXECUTORCH_BUILD_PYBIND) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/data_loader) endif() - if(NOT EXECUTORCH_BUILD_SDK) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/sdk) + if(NOT EXECUTORCH_BUILD_DEV_TOOLS) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dev_tools) endif() # find pytorch lib, to allow pybind to take at::Tensor as input/output diff --git a/README.md b/README.md index c4e6e0caf7..60c535a130 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Key value propositions of ExecuTorch are: - **Portability:** Compatibility with a wide variety of computing platforms, from high-end mobile phones to highly constrained embedded systems and microcontrollers. -- **Productivity:** Enabling developers to use the same toolchains and SDK from +- **Productivity:** Enabling developers to use the same toolchains from PyTorch model authoring and conversion, to debugging and deployment to a wide variety of platforms. - **Performance:** Providing end users with a seamless and high-performance @@ -93,7 +93,7 @@ tools. ├── schema # ExecuTorch PTE file format flatbuffer schemas. ├── scripts # Utility scripts for size management, dependency management, etc. -├── sdk # Model profiling, debugging, and introspection. +├── dev_tools # Model profiling, debugging, and introspection. ├── shim # Compatibility layer between OSS and Internal builds ├── test # Broad scoped end-to-end tests. ├── third-party # Third-party dependencies. diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index d670b60e6c..655322aa1c 100644 --- a/backends/apple/coreml/CMakeLists.txt +++ b/backends/apple/coreml/CMakeLists.txt @@ -130,7 +130,7 @@ target_include_directories( target_include_directories(coremldelegate PRIVATE ${EXECUTORCH_ROOT}/..) target_link_libraries(coremldelegate PRIVATE executorch_no_prim_ops) -if(EXECUTORCH_BUILD_SDK) +if(EXECUTORCH_BUILD_DEV_TOOLS) target_sources(coremldelegate PRIVATE ${SDK_SOURCES} ${PROTOBUF_SOURCES}) target_include_directories( coremldelegate @@ -166,7 +166,7 @@ endif() target_compile_options(coremldelegate PRIVATE "-fobjc-arc") target_compile_options(coremldelegate PRIVATE "-fno-exceptions") -if(EXECUTORCH_BUILD_SDK) +if(EXECUTORCH_BUILD_DEV_TOOLS) target_compile_options( executorch_no_prim_ops PUBLIC -DET_EVENT_TRACER_ENABLED ) diff --git a/backends/apple/mps/TARGETS b/backends/apple/mps/TARGETS index 9961ddd3c7..3c1cdfe997 100644 --- a/backends/apple/mps/TARGETS +++ b/backends/apple/mps/TARGETS @@ -94,8 +94,8 @@ runtime.python_test( "//caffe2:torch", "//executorch/examples/models:models", "//executorch/exir/tests:models", - "//executorch/sdk:lib", - "//executorch/sdk/bundled_program/serialize:lib", + "//executorch/dev_tools:lib", + "//executorch/dev_tools/bundled_program/serialize:lib", "fbsource//third-party/pypi/pytest:pytest", ], ) diff --git a/backends/apple/mps/setup.md b/backends/apple/mps/setup.md index c8fdfeb98e..22a56969d9 100644 --- a/backends/apple/mps/setup.md +++ b/backends/apple/mps/setup.md @@ -111,18 +111,18 @@ python3 -m examples.apple.mps.scripts.mps_example --model_name="mv3" --no-use_fp ``` ### Profiling: -1. [Optional] Generate an [ETRecord](./sdk-etrecord.rst) while you're exporting your model. +1. [Optional] Generate an [ETRecord](./dev-tools-etrecord.rst) while you're exporting your model. ```bash cd executorch python3 -m examples.apple.mps.scripts.mps_example --model_name="mv3" --generate_etrecord -b ``` -2. Run your Program on the ExecuTorch runtime and generate an [ETDump](./sdk-etdump.md). +2. Run your Program on the ExecuTorch runtime and generate an [ETDump](./dev-tools-etdump.md). ``` ./cmake-out/examples/apple/mps/mps_executor_runner --model_path mv3_mps_bundled_fp16.pte --bundled_program --dump-outputs ``` 3. Create an instance of the Inspector API by passing in the ETDump you have sourced from the runtime along with the optionally generated ETRecord from step 1. ```bash -python3 -m sdk.inspector.inspector_cli --etdump_path etdump.etdp --etrecord_path etrecord.bin +python3 -m dev_tools.inspector.inspector_cli --etdump_path etdump.etdp --etrecord_path etrecord.bin ``` ## Deploying and Running on Device diff --git a/backends/apple/mps/targets.bzl b/backends/apple/mps/targets.bzl index 8b9c64e143..a5d95b53bd 100644 --- a/backends/apple/mps/targets.bzl +++ b/backends/apple/mps/targets.bzl @@ -47,7 +47,7 @@ def define_common_targets(is_xplat = False, platforms = []): "//executorch/exir/backend:backend_lib", "//executorch/extension/pybindings/...", "//executorch/runtime/backend/...", - "//executorch/sdk/runners/...", + "//executorch/dev_tools/runners/...", "//executorch/test/...", "@EXECUTORCH_CLIENTS", ], diff --git a/backends/apple/mps/test/test_mps_utils.py b/backends/apple/mps/test/test_mps_utils.py index f3ae771c3d..501fce096c 100644 --- a/backends/apple/mps/test/test_mps_utils.py +++ b/backends/apple/mps/test/test_mps_utils.py @@ -22,9 +22,9 @@ from executorch.exir.backend.backend_details import CompileSpec from executorch.exir.capture._config import ExecutorchBackendConfig from executorch.exir.tracer import Value -from executorch.sdk import BundledProgram -from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite -from executorch.sdk.bundled_program.serialize import ( +from executorch.dev_tools import BundledProgram +from executorch.dev_tools.bundled_program.config import MethodTestCase, MethodTestSuite +from executorch.dev_tools.bundled_program.serialize import ( serialize_from_bundled_program_to_flatbuffer, ) from torch.export import export, ExportedProgram diff --git a/backends/qualcomm/scripts/build.sh b/backends/qualcomm/scripts/build.sh index 3712a83fde..c6f3fa3913 100755 --- a/backends/qualcomm/scripts/build.sh +++ b/backends/qualcomm/scripts/build.sh @@ -72,7 +72,7 @@ if [ "$BUILD_AARCH64" = true ]; then -DCMAKE_INSTALL_PREFIX=$BUILD_ROOT \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DEXECUTORCH_BUILD_QNN=ON \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \ -DQNN_SDK_ROOT=$QNN_SDK_ROOT \ diff --git a/backends/qualcomm/setup.md b/backends/qualcomm/setup.md index b4b0f2ea72..4df712c4b7 100644 --- a/backends/qualcomm/setup.md +++ b/backends/qualcomm/setup.md @@ -102,7 +102,7 @@ cd build_android cmake .. \ -DCMAKE_INSTALL_PREFIX=$PWD \ -DEXECUTORCH_BUILD_QNN=ON \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \ -DQNN_SDK_ROOT=$QNN_SDK_ROOT \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \ diff --git a/backends/qualcomm/tests/utils.py b/backends/qualcomm/tests/utils.py index f31f07562b..10e8de5866 100644 --- a/backends/qualcomm/tests/utils.py +++ b/backends/qualcomm/tests/utils.py @@ -36,8 +36,8 @@ from executorch.exir.pass_base import ExportPass from executorch.exir.passes.memory_planning_pass import MemoryPlanningPass from executorch.exir.program._program import ExecutorchProgram -from executorch.sdk import generate_etrecord -from executorch.sdk.inspector import Inspector +from executorch.dev_tools import generate_etrecord +from executorch.dev_tools.inspector import Inspector from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e diff --git a/backends/xnnpack/test/TARGETS b/backends/xnnpack/test/TARGETS index abedffb8e6..bf3222e757 100644 --- a/backends/xnnpack/test/TARGETS +++ b/backends/xnnpack/test/TARGETS @@ -36,10 +36,10 @@ runtime.python_test( deps = [ "//executorch/backends/xnnpack/partition:xnnpack_partitioner", "//executorch/backends/xnnpack/test/tester:tester", + "//executorch/dev_tools:lib", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools/bundled_program/serialize:lib", "//executorch/exir/passes:constant_prop_pass", - "//executorch/sdk:lib", - "//executorch/sdk/bundled_program:config", - "//executorch/sdk/bundled_program/serialize:lib", "//pytorch/ao:torchao", # @manual ], external_deps = [ diff --git a/backends/xnnpack/test/test_xnnpack_utils.py b/backends/xnnpack/test/test_xnnpack_utils.py index c6b1513d31..83cce9f67a 100644 --- a/backends/xnnpack/test/test_xnnpack_utils.py +++ b/backends/xnnpack/test/test_xnnpack_utils.py @@ -25,6 +25,12 @@ # import the xnnpack backend implementation from executorch.backends.xnnpack.xnnpack_preprocess import XnnpackBackend +from executorch.dev_tools import BundledProgram + +from executorch.dev_tools.bundled_program.config import MethodTestCase, MethodTestSuite +from executorch.dev_tools.bundled_program.serialize import ( + serialize_from_bundled_program_to_flatbuffer, +) from executorch.exir import ExecutorchProgram, ExirExportedProgram from executorch.exir.backend.backend_api import to_backend, validation_disabled @@ -34,12 +40,6 @@ _load_for_executorch_from_buffer, ) from executorch.extension.pytree import tree_flatten -from executorch.sdk import BundledProgram - -from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite -from executorch.sdk.bundled_program.serialize import ( - serialize_from_bundled_program_to_flatbuffer, -) from torch.ao.quantization import ( # @manual default_per_channel_symmetric_qnnpack_qconfig, diff --git a/build/Utils.cmake b/build/Utils.cmake index 56fc1e104b..d3aa308da8 100644 --- a/build/Utils.cmake +++ b/build/Utils.cmake @@ -97,7 +97,7 @@ function(executorch_print_configuration_summary) "${EXECUTORCH_BUILD_KERNELS_QUANTIZED}" ) message( - STATUS " EXECUTORCH_BUILD_SDK : ${EXECUTORCH_BUILD_SDK}" + STATUS " EXECUTORCH_BUILD_DEV_TOOLS : ${EXECUTORCH_BUILD_DEV_TOOLS}" ) message( STATUS diff --git a/sdk/CMakeLists.txt b/dev_tools/CMakeLists.txt similarity index 89% rename from sdk/CMakeLists.txt rename to dev_tools/CMakeLists.txt index 75a200d90c..443e50c96e 100644 --- a/sdk/CMakeLists.txt +++ b/dev_tools/CMakeLists.txt @@ -74,8 +74,8 @@ set_property(TARGET flatccrt PROPERTY POSITION_INDEPENDENT_CODE ON) include(ExternalProject) # The include directory that will contain the generated schema headers. -set(_program_schema__include_dir "${CMAKE_BINARY_DIR}/sdk/include") -set(_bundled_schema__include_dir "${CMAKE_BINARY_DIR}/sdk/bundled_program") +set(_program_schema__include_dir "${CMAKE_BINARY_DIR}/dev_tools/include") +set(_bundled_schema__include_dir "${CMAKE_BINARY_DIR}/dev_tools/bundled_program") # TODO(dbort): Only enable this when cross-compiling. It can cause build race # conditions (libflatcc.a errors) when enabled. @@ -110,11 +110,11 @@ set(_etdump_schema__outputs) foreach(fbs_file ${_etdump_schema_names}) string(REGEX REPLACE "[.]fbs$" "_reader.h" generated "${fbs_file}") list(APPEND _etdump_schema__outputs - "${_program_schema__include_dir}/executorch/sdk/etdump/${generated}" + "${_program_schema__include_dir}/executorch/dev_tools/etdump/${generated}" ) string(REGEX REPLACE "[.]fbs$" "_builder.h" generated "${fbs_file}") list(APPEND _etdump_schema__outputs - "${_program_schema__include_dir}/executorch/sdk/etdump/${generated}" + "${_program_schema__include_dir}/executorch/dev_tools/etdump/${generated}" ) endforeach() @@ -125,7 +125,7 @@ foreach(fbs_file ${_bundled_input_schema_names}) list( APPEND _bundled_program_schema__outputs - "${_bundled_schema__include_dir}/executorch/sdk/bundled_program/schema/${generated}" + "${_bundled_schema__include_dir}/executorch/dev_tools/bundled_program/schema/${generated}" ) endforeach() @@ -137,9 +137,9 @@ add_library( # Ensure the host tool is built before the main project add_dependencies(etdump_schema flatcc_cli) -file(MAKE_DIRECTORY ${_program_schema__include_dir}/executorch/sdk/etdump) +file(MAKE_DIRECTORY ${_program_schema__include_dir}/executorch/dev_tools/etdump) file(MAKE_DIRECTORY - ${_program_schema__include_dir}/executorch/sdk/bundled_program + ${_program_schema__include_dir}/executorch/dev_tools/bundled_program ) if(EXECUTORCH_SEPARATE_FLATCC_HOST_PROJECT) @@ -177,10 +177,10 @@ add_custom_command( # tree instead of under the binary directory, and there's no way to change # that behavior. ${_flatcc_source_dir}/bin/flatcc -cwr -o - ${_program_schema__include_dir}/executorch/sdk/etdump + ${_program_schema__include_dir}/executorch/dev_tools/etdump ${_etdump_schema__srcs} COMMAND rm -f ${_etdump_schema_cleanup_paths} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/sdk + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dev_tools DEPENDS ${_etdump_schema_gen_dep} COMMENT "Generating etdump headers" VERBATIM @@ -201,9 +201,9 @@ add_custom_command( OUTPUT ${_bundled_program_schema__outputs} COMMAND ${FLATC_EXECUTABLE} --cpp --cpp-std c++11 --gen-mutable --scoped-enums -o - "${_bundled_schema__include_dir}/executorch/sdk/bundled_program/schema" + "${_bundled_schema__include_dir}/executorch/dev_tools/bundled_program/schema" ${_bundled_program_schema__srcs} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/sdk + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dev_tools DEPENDS ${FLATC_EXECUTABLE} ${_bundled_program_schema__srcs} COMMENT "Generating bundled_program headers" VERBATIM diff --git a/sdk/TARGETS b/dev_tools/TARGETS similarity index 53% rename from sdk/TARGETS rename to dev_tools/TARGETS index 56d38a4ad3..7d19e87b58 100644 --- a/sdk/TARGETS +++ b/dev_tools/TARGETS @@ -6,8 +6,8 @@ python_library( name = "lib", srcs = ["__init__.py"], deps = [ - "//executorch/sdk/bundled_program:core", - "//executorch/sdk/etrecord:etrecord", - "//executorch/sdk/inspector:lib", + "//executorch/dev_tools/bundled_program:core", + "//executorch/dev_tools/etrecord:etrecord", + "//executorch/dev_tools/inspector:lib", ], ) diff --git a/sdk/__init__.py b/dev_tools/__init__.py similarity index 56% rename from sdk/__init__.py rename to dev_tools/__init__.py index 11134bf276..b5810fe932 100644 --- a/sdk/__init__.py +++ b/dev_tools/__init__.py @@ -4,10 +4,10 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -import executorch.sdk.inspector as inspector -from executorch.sdk.bundled_program.core import BundledProgram -from executorch.sdk.etrecord import ETRecord, generate_etrecord, parse_etrecord -from executorch.sdk.inspector import Inspector +import executorch.dev_tools.inspector as inspector +from executorch.dev_tools.bundled_program.core import BundledProgram +from executorch.dev_tools.etrecord import ETRecord, generate_etrecord, parse_etrecord +from executorch.dev_tools.inspector import Inspector __all__ = [ "ETRecord", diff --git a/sdk/bundled_program/TARGETS b/dev_tools/bundled_program/TARGETS similarity index 88% rename from sdk/bundled_program/TARGETS rename to dev_tools/bundled_program/TARGETS index c731606217..416a523fa8 100644 --- a/sdk/bundled_program/TARGETS +++ b/dev_tools/bundled_program/TARGETS @@ -18,10 +18,10 @@ runtime.python_library( ":config", ":version", "//caffe2:torch", + "//executorch/dev_tools/bundled_program/schema:bundled_program_schema_py", "//executorch/exir:schema", "//executorch/exir:tensor", "//executorch/exir/_serialize:lib", - "//executorch/sdk/bundled_program/schema:bundled_program_schema_py", ], ) @@ -46,6 +46,6 @@ runtime.python_library( "version.py", ], visibility = [ - "//executorch/sdk/...", + "//executorch/dev_tools/...", ], ) diff --git a/sdk/bundled_program/bundled_program.cpp b/dev_tools/bundled_program/bundled_program.cpp similarity index 98% rename from sdk/bundled_program/bundled_program.cpp rename to dev_tools/bundled_program/bundled_program.cpp index 39e6ea960e..e367f8fc3b 100644 --- a/sdk/bundled_program/bundled_program.cpp +++ b/dev_tools/bundled_program/bundled_program.cpp @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. */ -#include +#include #include #include @@ -16,12 +16,12 @@ #include #endif // USE_ATEN_LIB +#include #include #include #include #include #include -#include namespace torch { namespace executor { diff --git a/sdk/bundled_program/bundled_program.h b/dev_tools/bundled_program/bundled_program.h similarity index 100% rename from sdk/bundled_program/bundled_program.h rename to dev_tools/bundled_program/bundled_program.h diff --git a/sdk/bundled_program/config.py b/dev_tools/bundled_program/config.py similarity index 100% rename from sdk/bundled_program/config.py rename to dev_tools/bundled_program/config.py diff --git a/sdk/bundled_program/core.py b/dev_tools/bundled_program/core.py similarity index 98% rename from sdk/bundled_program/core.py rename to dev_tools/bundled_program/core.py index 4fede5e595..e5f53609bc 100644 --- a/sdk/bundled_program/core.py +++ b/dev_tools/bundled_program/core.py @@ -8,19 +8,19 @@ import typing from typing import Dict, List, Optional, Sequence, Type, Union -import executorch.exir.schema as core_schema +import executorch.dev_tools.bundled_program.schema as bp_schema -import executorch.sdk.bundled_program.schema as bp_schema +import executorch.exir.schema as core_schema import torch import torch.fx +from executorch.dev_tools.bundled_program.config import ConfigValue, MethodTestSuite + +from executorch.dev_tools.bundled_program.version import BUNDLED_PROGRAM_SCHEMA_VERSION from executorch.exir import ExecutorchProgram, ExecutorchProgramManager from executorch.exir._serialize import _serialize_pte_binary from executorch.exir.tensor import get_scalar_type, scalar_type_enum, TensorSpec -from executorch.sdk.bundled_program.config import ConfigValue, MethodTestSuite - -from executorch.sdk.bundled_program.version import BUNDLED_PROGRAM_SCHEMA_VERSION # pyre-ignore supported_program_type_table: Dict[Type[core_schema.KernelTypes], ConfigValue] = { diff --git a/sdk/bundled_program/schema/README.md b/dev_tools/bundled_program/schema/README.md similarity index 100% rename from sdk/bundled_program/schema/README.md rename to dev_tools/bundled_program/schema/README.md diff --git a/sdk/bundled_program/schema/TARGETS b/dev_tools/bundled_program/schema/TARGETS similarity index 84% rename from sdk/bundled_program/schema/TARGETS rename to dev_tools/bundled_program/schema/TARGETS index e9bd642069..114516e332 100644 --- a/sdk/bundled_program/schema/TARGETS +++ b/dev_tools/bundled_program/schema/TARGETS @@ -15,8 +15,8 @@ runtime.python_library( "bundled_program_schema.py", ], visibility = [ - "//executorch/sdk/bundled_program/...", - "//executorch/sdk/etrecord/...", + "//executorch/dev_tools/bundled_program/...", + "//executorch/dev_tools/etrecord/...", ], deps = [ "//executorch/exir:scalar_type", diff --git a/sdk/bundled_program/schema/__init__.py b/dev_tools/bundled_program/schema/__init__.py similarity index 100% rename from sdk/bundled_program/schema/__init__.py rename to dev_tools/bundled_program/schema/__init__.py diff --git a/sdk/bundled_program/schema/bundled_program_schema.fbs b/dev_tools/bundled_program/schema/bundled_program_schema.fbs similarity index 100% rename from sdk/bundled_program/schema/bundled_program_schema.fbs rename to dev_tools/bundled_program/schema/bundled_program_schema.fbs diff --git a/sdk/bundled_program/schema/bundled_program_schema.py b/dev_tools/bundled_program/schema/bundled_program_schema.py similarity index 100% rename from sdk/bundled_program/schema/bundled_program_schema.py rename to dev_tools/bundled_program/schema/bundled_program_schema.py diff --git a/sdk/bundled_program/schema/scalar_type.fbs b/dev_tools/bundled_program/schema/scalar_type.fbs similarity index 100% rename from sdk/bundled_program/schema/scalar_type.fbs rename to dev_tools/bundled_program/schema/scalar_type.fbs diff --git a/sdk/bundled_program/schema/targets.bzl b/dev_tools/bundled_program/schema/targets.bzl similarity index 93% rename from sdk/bundled_program/schema/targets.bzl rename to dev_tools/bundled_program/schema/targets.bzl index a25d792c5a..a69a458085 100644 --- a/sdk/bundled_program/schema/targets.bzl +++ b/dev_tools/bundled_program/schema/targets.bzl @@ -49,14 +49,14 @@ def define_common_targets(): runtime.export_file( name = INPUT_BUNDLED, visibility = [ - "//executorch/sdk/bundled_program/serialize/...", + "//executorch/dev_tools/bundled_program/serialize/...", ], ) runtime.export_file( name = INPUT_SCALAR_TYPE, visibility = [ - "//executorch/sdk/bundled_program/serialize/...", + "//executorch/dev_tools/bundled_program/serialize/...", ], ) @@ -72,7 +72,7 @@ def define_common_targets(): name = BUNDLED_LIBRARY_NAME, srcs = [], visibility = [ - "//executorch/sdk/bundled_program/...", + "//executorch/dev_tools/bundled_program/...", "//executorch/extension/pybindings/...", ], exported_headers = { diff --git a/sdk/bundled_program/schema/test/TARGETS b/dev_tools/bundled_program/schema/test/TARGETS similarity index 100% rename from sdk/bundled_program/schema/test/TARGETS rename to dev_tools/bundled_program/schema/test/TARGETS diff --git a/sdk/bundled_program/schema/test/test_schema.py b/dev_tools/bundled_program/schema/test/test_schema.py similarity index 79% rename from sdk/bundled_program/schema/test/test_schema.py rename to dev_tools/bundled_program/schema/test/test_schema.py index ab3d2760d2..b4eaa58d1e 100644 --- a/sdk/bundled_program/schema/test/test_schema.py +++ b/dev_tools/bundled_program/schema/test/test_schema.py @@ -20,8 +20,8 @@ def test_schema_sync(self) -> None: self.assertTrue( filecmp.cmp( - prefix + "sdk/bundled_program/schema/scalar_type.fbs", + prefix + "dev_tools/bundled_program/schema/scalar_type.fbs", prefix + "schema/scalar_type.fbs", ), - 'Please run "hg cp fbcode//executorch/schema/scalar_type.fbs fbcode//executorch/sdk/bundled_program/schema/scalar_type.fbs" to sync schema changes.', + 'Please run "hg cp fbcode//executorch/schema/scalar_type.fbs fbcode//executorch/dev_tools/bundled_program/schema/scalar_type.fbs" to sync schema changes.', ) diff --git a/sdk/bundled_program/serialize/TARGETS b/dev_tools/bundled_program/serialize/TARGETS similarity index 76% rename from sdk/bundled_program/serialize/TARGETS rename to dev_tools/bundled_program/serialize/TARGETS index 20abccd7fd..28998198e9 100644 --- a/sdk/bundled_program/serialize/TARGETS +++ b/dev_tools/bundled_program/serialize/TARGETS @@ -10,8 +10,8 @@ runtime.python_library( "__init__.py", ], resources = { - "//executorch/sdk/bundled_program/schema:bundled_program_schema.fbs": "bundled_program_schema.fbs", - "//executorch/sdk/bundled_program/schema:scalar_type.fbs": "scalar_type.fbs", + "//executorch/dev_tools/bundled_program/schema:bundled_program_schema.fbs": "bundled_program_schema.fbs", + "//executorch/dev_tools/bundled_program/schema:scalar_type.fbs": "scalar_type.fbs", }, # Currently serialization API should only be used in some dedicated targets, # to avoid ODR violation when linking with another Flatbuffers library. @@ -20,18 +20,18 @@ runtime.python_library( "//executorch/bacends/...", "//executorch/backends/xnnpack/test/...", "//executorch/codegen/...", + "//executorch/dev_tools/bundled_program/tests/...", "//executorch/examples/async_exec:emit_program_lib", "//executorch/exir:lib", "//executorch/extension/pybindings/test:test", "//executorch/extension/pybindings/test:test-library", "//executorch/profiler/...", - "//executorch/sdk/bundled_program/tests/...", "//executorch/test/...", "@EXECUTORCH_CLIENTS", ], deps = [ "fbsource//third-party/pypi/setuptools:setuptools", + "//executorch/dev_tools/bundled_program/schema:bundled_program_schema_py", "//executorch/exir/_serialize:lib", - "//executorch/sdk/bundled_program/schema:bundled_program_schema_py", ], ) diff --git a/sdk/bundled_program/serialize/__init__.py b/dev_tools/bundled_program/serialize/__init__.py similarity index 97% rename from sdk/bundled_program/serialize/__init__.py rename to dev_tools/bundled_program/serialize/__init__.py index e0c75574c9..1b41ec93e7 100644 --- a/sdk/bundled_program/serialize/__init__.py +++ b/dev_tools/bundled_program/serialize/__init__.py @@ -12,14 +12,14 @@ import os import tempfile -import executorch.sdk.bundled_program.schema as bp_schema +import executorch.dev_tools.bundled_program.schema as bp_schema # @manual=fbsource//third-party/pypi/setuptools:setuptools import pkg_resources +from executorch.dev_tools.bundled_program.core import BundledProgram from executorch.exir._serialize._dataclass import _DataclassEncoder, _json_to_dataclass from executorch.exir._serialize._flatbuffer import _flatc_compile, _flatc_decompile -from executorch.sdk.bundled_program.core import BundledProgram # The prefix of schema files used for bundled program BUNDLED_PROGRAM_SCHEMA_NAME = "bundled_program_schema" diff --git a/sdk/bundled_program/serialize/test/TARGETS b/dev_tools/bundled_program/serialize/test/TARGETS similarity index 59% rename from sdk/bundled_program/serialize/test/TARGETS rename to dev_tools/bundled_program/serialize/test/TARGETS index 85f55c02f8..eb7bb56046 100644 --- a/sdk/bundled_program/serialize/test/TARGETS +++ b/dev_tools/bundled_program/serialize/test/TARGETS @@ -10,9 +10,9 @@ python_unittest( "test_serialize.py", ], deps = [ + "//executorch/dev_tools/bundled_program:core", + "//executorch/dev_tools/bundled_program/serialize:lib", + "//executorch/dev_tools/bundled_program/util:test_util", "//executorch/exir:print_program", - "//executorch/sdk/bundled_program:core", - "//executorch/sdk/bundled_program/serialize:lib", - "//executorch/sdk/bundled_program/util:test_util", ], ) diff --git a/sdk/bundled_program/serialize/test/test_serialize.py b/dev_tools/bundled_program/serialize/test/test_serialize.py similarity index 82% rename from sdk/bundled_program/serialize/test/test_serialize.py rename to dev_tools/bundled_program/serialize/test/test_serialize.py index 1db6871fc0..4dde7edb62 100644 --- a/sdk/bundled_program/serialize/test/test_serialize.py +++ b/dev_tools/bundled_program/serialize/test/test_serialize.py @@ -8,13 +8,15 @@ import unittest -from executorch.sdk.bundled_program.core import BundledProgram +from executorch.dev_tools.bundled_program.core import BundledProgram -from executorch.sdk.bundled_program.serialize import ( +from executorch.dev_tools.bundled_program.serialize import ( deserialize_from_flatbuffer_to_bundled_program, serialize_from_bundled_program_to_flatbuffer, ) -from executorch.sdk.bundled_program.util.test_util import get_common_executorch_program +from executorch.dev_tools.bundled_program.util.test_util import ( + get_common_executorch_program, +) class TestSerialize(unittest.TestCase): diff --git a/sdk/bundled_program/targets.bzl b/dev_tools/bundled_program/targets.bzl similarity index 91% rename from sdk/bundled_program/targets.bzl rename to dev_tools/bundled_program/targets.bzl index a3268dff2c..64188256d4 100644 --- a/sdk/bundled_program/targets.bzl +++ b/dev_tools/bundled_program/targets.bzl @@ -19,7 +19,7 @@ def define_common_targets(): ], deps = [ "//executorch/runtime/core/exec_aten/util:dim_order_util" + aten_suffix, - "//executorch/sdk/bundled_program/schema:bundled_program_schema_fbs", + "//executorch/dev_tools/bundled_program/schema:bundled_program_schema_fbs", ], exported_deps = [ "//executorch/runtime/core:memory_allocator", diff --git a/sdk/bundled_program/test/TARGETS b/dev_tools/bundled_program/test/TARGETS similarity index 68% rename from sdk/bundled_program/test/TARGETS rename to dev_tools/bundled_program/test/TARGETS index caf69be60e..679baf7620 100644 --- a/sdk/bundled_program/test/TARGETS +++ b/dev_tools/bundled_program/test/TARGETS @@ -10,11 +10,11 @@ python_unittest( ], deps = [ "//caffe2:torch", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools/bundled_program:core", + "//executorch/dev_tools/bundled_program/schema:bundled_program_schema_py", + "//executorch/dev_tools/bundled_program/util:test_util", "//executorch/exir/_serialize:lib", - "//executorch/sdk/bundled_program:config", - "//executorch/sdk/bundled_program:core", - "//executorch/sdk/bundled_program/schema:bundled_program_schema_py", - "//executorch/sdk/bundled_program/util:test_util", ], ) @@ -25,9 +25,9 @@ python_unittest( ], deps = [ "//caffe2:torch", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools/bundled_program/util:test_util", "//executorch/extension/pytree:pylib", - "//executorch/sdk/bundled_program:config", - "//executorch/sdk/bundled_program/util:test_util", ], ) @@ -38,6 +38,10 @@ python_unittest( ], deps = [ "//caffe2:torch", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools/bundled_program:core", + "//executorch/dev_tools/bundled_program/serialize:lib", + "//executorch/dev_tools/bundled_program/util:test_util", "//executorch/exir:dynamic_shape", "//executorch/exir:lib", "//executorch/exir:memory", @@ -54,9 +58,5 @@ python_unittest( "//executorch/extension/pybindings:portable_lib", "//executorch/extension/pytree:pybindings", "//executorch/kernels/portable:custom_ops_generated_lib", - "//executorch/sdk/bundled_program:config", - "//executorch/sdk/bundled_program:core", - "//executorch/sdk/bundled_program/serialize:lib", - "//executorch/sdk/bundled_program/util:test_util", ], ) diff --git a/sdk/bundled_program/test/test_bundle_data.py b/dev_tools/bundled_program/test/test_bundle_data.py similarity index 93% rename from sdk/bundled_program/test/test_bundle_data.py rename to dev_tools/bundled_program/test/test_bundle_data.py index a8d9485c5f..c76dc9be9c 100644 --- a/sdk/bundled_program/test/test_bundle_data.py +++ b/dev_tools/bundled_program/test/test_bundle_data.py @@ -9,13 +9,15 @@ import unittest from typing import List -import executorch.sdk.bundled_program.schema as bp_schema +import executorch.dev_tools.bundled_program.schema as bp_schema import torch +from executorch.dev_tools.bundled_program.config import ConfigValue +from executorch.dev_tools.bundled_program.core import BundledProgram +from executorch.dev_tools.bundled_program.util.test_util import ( + get_common_executorch_program, +) from executorch.exir._serialize import _serialize_pte_binary -from executorch.sdk.bundled_program.config import ConfigValue -from executorch.sdk.bundled_program.core import BundledProgram -from executorch.sdk.bundled_program.util.test_util import get_common_executorch_program class TestBundle(unittest.TestCase): diff --git a/sdk/bundled_program/test/test_config.py b/dev_tools/bundled_program/test/test_config.py similarity index 97% rename from sdk/bundled_program/test/test_config.py rename to dev_tools/bundled_program/test/test_config.py index 3183ad907f..3013cf5fa1 100644 --- a/sdk/bundled_program/test/test_config.py +++ b/dev_tools/bundled_program/test/test_config.py @@ -10,14 +10,14 @@ from typing import get_args, List, Union import torch -from executorch.extension.pytree import tree_flatten -from executorch.sdk.bundled_program.config import DataContainer +from executorch.dev_tools.bundled_program.config import DataContainer -from executorch.sdk.bundled_program.util.test_util import ( +from executorch.dev_tools.bundled_program.util.test_util import ( get_random_test_suites, get_random_test_suites_with_eager_model, SampleModel, ) +from executorch.extension.pytree import tree_flatten class TestConfig(unittest.TestCase): diff --git a/sdk/bundled_program/test/test_end2end.py b/dev_tools/bundled_program/test/test_end2end.py similarity index 92% rename from sdk/bundled_program/test/test_end2end.py rename to dev_tools/bundled_program/test/test_end2end.py index 99d58ee15c..5106662fce 100644 --- a/sdk/bundled_program/test/test_end2end.py +++ b/dev_tools/bundled_program/test/test_end2end.py @@ -21,12 +21,12 @@ import torch -from executorch.sdk.bundled_program.core import BundledProgram -from executorch.sdk.bundled_program.serialize import ( +from executorch.dev_tools.bundled_program.core import BundledProgram +from executorch.dev_tools.bundled_program.serialize import ( serialize_from_bundled_program_to_flatbuffer, ) -from executorch.sdk.bundled_program.util.test_util import ( +from executorch.dev_tools.bundled_program.util.test_util import ( get_common_executorch_program, SampleModel, ) diff --git a/sdk/bundled_program/util/TARGETS b/dev_tools/bundled_program/util/TARGETS similarity index 68% rename from sdk/bundled_program/util/TARGETS rename to dev_tools/bundled_program/util/TARGETS index 17d19dfb29..32da05f687 100644 --- a/sdk/bundled_program/util/TARGETS +++ b/dev_tools/bundled_program/util/TARGETS @@ -7,10 +7,10 @@ python_library( srcs = [ "test_util.py", ], - visibility = ["//executorch/sdk/bundled_program/..."], + visibility = ["//executorch/dev_tools/bundled_program/..."], deps = [ "//caffe2:torch", + "//executorch/dev_tools/bundled_program:config", "//executorch/exir:lib", - "//executorch/sdk/bundled_program:config", ], ) diff --git a/sdk/bundled_program/util/test_util.py b/dev_tools/bundled_program/util/test_util.py similarity index 99% rename from sdk/bundled_program/util/test_util.py rename to dev_tools/bundled_program/util/test_util.py index bfea8158ac..cb37b936a8 100644 --- a/sdk/bundled_program/util/test_util.py +++ b/dev_tools/bundled_program/util/test_util.py @@ -10,14 +10,14 @@ from typing import List, Tuple import torch - -from executorch.exir import ExecutorchProgramManager, to_edge -from executorch.sdk.bundled_program.config import ( +from executorch.dev_tools.bundled_program.config import ( MethodInputType, MethodOutputType, MethodTestCase, MethodTestSuite, ) + +from executorch.exir import ExecutorchProgramManager, to_edge from torch.export import export from torch.export.unflatten import _assign_attr, _AttrKind diff --git a/sdk/bundled_program/version.py b/dev_tools/bundled_program/version.py similarity index 100% rename from sdk/bundled_program/version.py rename to dev_tools/bundled_program/version.py diff --git a/sdk/debug_format/TARGETS b/dev_tools/debug_format/TARGETS similarity index 100% rename from sdk/debug_format/TARGETS rename to dev_tools/debug_format/TARGETS diff --git a/sdk/debug_format/base_schema.py b/dev_tools/debug_format/base_schema.py similarity index 95% rename from sdk/debug_format/base_schema.py rename to dev_tools/debug_format/base_schema.py index b987c28874..f6d69be0d7 100644 --- a/sdk/debug_format/base_schema.py +++ b/dev_tools/debug_format/base_schema.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. """ -Base Intermediate Representation for Productivity SDK consumers +Base Intermediate Representation for Developer Tools consumers (e.g. TensorBoard, Terminal Debugger) """ diff --git a/sdk/debug_format/et_schema.py b/dev_tools/debug_format/et_schema.py similarity index 99% rename from sdk/debug_format/et_schema.py rename to dev_tools/debug_format/et_schema.py index 9a6af4edba..3385382098 100644 --- a/sdk/debug_format/et_schema.py +++ b/dev_tools/debug_format/et_schema.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. """ -Intermediate Representation of ExecuTorch Concepts in Productivity SDK +Intermediate Representation of ExecuTorch Concepts in Developer Tools """ from __future__ import annotations @@ -21,7 +21,7 @@ import torch from executorch import exir -from executorch.sdk.debug_format.base_schema import ( +from executorch.dev_tools.debug_format.base_schema import ( Node, OperatorGraph, OperatorNode, diff --git a/sdk/etdump/TARGETS b/dev_tools/etdump/TARGETS similarity index 80% rename from sdk/etdump/TARGETS rename to dev_tools/etdump/TARGETS index 22d07478cb..79fe0914f8 100644 --- a/sdk/etdump/TARGETS +++ b/dev_tools/etdump/TARGETS @@ -11,7 +11,7 @@ runtime.python_library( "schema_flatcc.py", ], visibility = [ - "//executorch/sdk/...", + "//executorch/dev_tools/...", ], deps = [ "//executorch/exir:scalar_type", @@ -24,11 +24,11 @@ runtime.python_library( "serialize.py", ], resources = { + "//executorch/dev_tools/etdump:etdump_schema_flatcc.fbs": "etdump_schema_flatcc.fbs", "//executorch/schema:scalar_type.fbs": "scalar_type.fbs", - "//executorch/sdk/etdump:etdump_schema_flatcc.fbs": "etdump_schema_flatcc.fbs", }, visibility = [ - "//executorch/sdk/...", + "//executorch/dev_tools/...", ], deps = [ "fbsource//third-party/pypi/setuptools:setuptools", diff --git a/sdk/etdump/emitter.cpp b/dev_tools/etdump/emitter.cpp similarity index 98% rename from sdk/etdump/emitter.cpp rename to dev_tools/etdump/emitter.cpp index 1b3cba9d19..a110d8838f 100644 --- a/sdk/etdump/emitter.cpp +++ b/dev_tools/etdump/emitter.cpp @@ -9,8 +9,8 @@ #include #include +#include "executorch/dev_tools/etdump/emitter.h" #include "executorch/runtime/platform/assert.h" -#include "executorch/sdk/etdump/emitter.h" namespace torch { namespace executor { diff --git a/sdk/etdump/emitter.h b/dev_tools/etdump/emitter.h similarity index 92% rename from sdk/etdump/emitter.h rename to dev_tools/etdump/emitter.h index 3910d3bd27..ac8dc92334 100644 --- a/sdk/etdump/emitter.h +++ b/dev_tools/etdump/emitter.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #pragma once diff --git a/sdk/etdump/etdump_flatcc.cpp b/dev_tools/etdump/etdump_flatcc.cpp similarity index 98% rename from sdk/etdump/etdump_flatcc.cpp rename to dev_tools/etdump/etdump_flatcc.cpp index dab1443b55..0fba6a7e3d 100644 --- a/sdk/etdump/etdump_flatcc.cpp +++ b/dev_tools/etdump/etdump_flatcc.cpp @@ -6,16 +6,16 @@ * LICENSE file in the root directory of this source tree. */ -#include "executorch/sdk/etdump/etdump_flatcc.h" -#include -#include +#include "executorch/dev_tools/etdump/etdump_flatcc.h" +#include +#include #include #include #include +#include "executorch/dev_tools/etdump/emitter.h" #include "executorch/runtime/core/exec_aten/exec_aten.h" #include "executorch/runtime/core/exec_aten/util/scalar_type_util.h" #include "executorch/runtime/platform/assert.h" -#include "executorch/sdk/etdump/emitter.h" namespace torch { namespace executor { diff --git a/sdk/etdump/etdump_flatcc.h b/dev_tools/etdump/etdump_flatcc.h similarity index 100% rename from sdk/etdump/etdump_flatcc.h rename to dev_tools/etdump/etdump_flatcc.h diff --git a/sdk/etdump/etdump_schema_flatcc.fbs b/dev_tools/etdump/etdump_schema_flatcc.fbs similarity index 100% rename from sdk/etdump/etdump_schema_flatcc.fbs rename to dev_tools/etdump/etdump_schema_flatcc.fbs diff --git a/sdk/etdump/scalar_type.fbs b/dev_tools/etdump/scalar_type.fbs similarity index 100% rename from sdk/etdump/scalar_type.fbs rename to dev_tools/etdump/scalar_type.fbs diff --git a/sdk/etdump/schema_flatcc.py b/dev_tools/etdump/schema_flatcc.py similarity index 97% rename from sdk/etdump/schema_flatcc.py rename to dev_tools/etdump/schema_flatcc.py index eaad876a53..97bd7a209d 100644 --- a/sdk/etdump/schema_flatcc.py +++ b/dev_tools/etdump/schema_flatcc.py @@ -7,7 +7,7 @@ # pyre-strict """ This file is the python representation of the schema contained in -executorch/sdk/etdump/etdump_schema.fbs. Any changes made to that +executorch/dev_tools/etdump/etdump_schema.fbs. Any changes made to that flatbuffer schema should accordingly be reflected here also. """ diff --git a/sdk/etdump/serialize.py b/dev_tools/etdump/serialize.py similarity index 98% rename from sdk/etdump/serialize.py rename to dev_tools/etdump/serialize.py index 0cc6682bfc..2a6d5b5986 100644 --- a/sdk/etdump/serialize.py +++ b/dev_tools/etdump/serialize.py @@ -11,11 +11,11 @@ import tempfile import pkg_resources +from executorch.dev_tools.etdump.schema_flatcc import ETDumpFlatCC from executorch.exir._serialize._dataclass import _DataclassEncoder, _json_to_dataclass from executorch.exir._serialize._flatbuffer import _flatc_compile, _flatc_decompile -from executorch.sdk.etdump.schema_flatcc import ETDumpFlatCC # The prefix of schema files used for etdump ETDUMP_FLATCC_SCHEMA_NAME = "etdump_schema_flatcc" diff --git a/sdk/etdump/targets.bzl b/dev_tools/etdump/targets.bzl similarity index 100% rename from sdk/etdump/targets.bzl rename to dev_tools/etdump/targets.bzl diff --git a/sdk/etdump/tests/CMakeLists.txt b/dev_tools/etdump/tests/CMakeLists.txt similarity index 85% rename from sdk/etdump/tests/CMakeLists.txt rename to dev_tools/etdump/tests/CMakeLists.txt index 1995088057..898c8eb059 100644 --- a/sdk/etdump/tests/CMakeLists.txt +++ b/dev_tools/etdump/tests/CMakeLists.txt @@ -12,7 +12,7 @@ # cmake_minimum_required(VERSION 3.19) -project(sdk_etdump_tests) +project(dev_tools_etdump_tests) # Use C++17 for test. set(CMAKE_CXX_STANDARD 17) @@ -24,7 +24,7 @@ include(${EXECUTORCH_ROOT}/build/Test.cmake) set(_test_srcs etdump_test.cpp) et_cxx_test( - sdk_etdump_tests + dev_tools_etdump_tests SOURCES ${_test_srcs} EXTRA_LIBS @@ -33,6 +33,6 @@ et_cxx_test( flatccrt_d ) target_include_directories( - sdk_etdump_tests PRIVATE ${CMAKE_INSTALL_PREFIX}/sdk/include + dev_tools_etdump_tests PRIVATE ${CMAKE_INSTALL_PREFIX}/dev_tools/include ${EXECUTORCH_ROOT}/third-party/flatcc/include ) diff --git a/sdk/etdump/tests/TARGETS b/dev_tools/etdump/tests/TARGETS similarity index 75% rename from sdk/etdump/tests/TARGETS rename to dev_tools/etdump/tests/TARGETS index ad48948c48..b47624127e 100644 --- a/sdk/etdump/tests/TARGETS +++ b/dev_tools/etdump/tests/TARGETS @@ -11,8 +11,8 @@ python_unittest( "serialize_test.py", ], deps = [ + "//executorch/dev_tools/etdump:schema_flatcc", + "//executorch/dev_tools/etdump:serialize", "//executorch/exir/_serialize:lib", - "//executorch/sdk/etdump:schema_flatcc", - "//executorch/sdk/etdump:serialize", ], ) diff --git a/sdk/etdump/tests/etdump_test.cpp b/dev_tools/etdump/tests/etdump_test.cpp similarity index 99% rename from sdk/etdump/tests/etdump_test.cpp rename to dev_tools/etdump/tests/etdump_test.cpp index d30bd9a303..aa4c00e622 100644 --- a/sdk/etdump/tests/etdump_test.cpp +++ b/dev_tools/etdump/tests/etdump_test.cpp @@ -9,12 +9,12 @@ #include #include +#include +#include +#include #include #include #include -#include -#include -#include #include #include #include diff --git a/sdk/etdump/tests/serialize_test.py b/dev_tools/etdump/tests/serialize_test.py similarity index 97% rename from sdk/etdump/tests/serialize_test.py rename to dev_tools/etdump/tests/serialize_test.py index 2b1497f597..5004be28b0 100644 --- a/sdk/etdump/tests/serialize_test.py +++ b/dev_tools/etdump/tests/serialize_test.py @@ -12,13 +12,13 @@ from pprint import pformat from typing import List -import executorch.sdk.etdump.schema_flatcc as flatcc -from executorch.exir._serialize._dataclass import _DataclassEncoder +import executorch.dev_tools.etdump.schema_flatcc as flatcc -from executorch.sdk.etdump.serialize import ( +from executorch.dev_tools.etdump.serialize import ( deserialize_from_etdump_flatcc, serialize_to_etdump_flatcc, ) +from executorch.exir._serialize._dataclass import _DataclassEncoder def diff_jsons(a: str, b: str) -> List[str]: diff --git a/sdk/etdump/tests/targets.bzl b/dev_tools/etdump/tests/targets.bzl similarity index 82% rename from sdk/etdump/tests/targets.bzl rename to dev_tools/etdump/tests/targets.bzl index 41b19ca65e..4b65c53a72 100644 --- a/sdk/etdump/tests/targets.bzl +++ b/dev_tools/etdump/tests/targets.bzl @@ -13,8 +13,8 @@ def define_common_targets(): "etdump_test.cpp", ], deps = [ - "//executorch/sdk/etdump:etdump_flatcc", - "//executorch/sdk/etdump:etdump_schema_flatcc", + "//executorch/dev_tools/etdump:etdump_flatcc", + "//executorch/dev_tools/etdump:etdump_schema_flatcc", "//executorch/runtime/platform:platform", "//executorch/runtime/core/exec_aten/testing_util:tensor_util", ], diff --git a/sdk/etrecord/TARGETS b/dev_tools/etrecord/TARGETS similarity index 71% rename from sdk/etrecord/TARGETS rename to dev_tools/etrecord/TARGETS index c7de63a81f..63d70998f1 100644 --- a/sdk/etrecord/TARGETS +++ b/dev_tools/etrecord/TARGETS @@ -9,10 +9,10 @@ python_library( "_etrecord.py", ], deps = [ + "//executorch/dev_tools/bundled_program:core", + "//executorch/dev_tools/bundled_program/schema:bundled_program_schema_py", "//executorch/exir:lib", "//executorch/exir/emit:emit", "//executorch/exir/serde:serialize", - "//executorch/sdk/bundled_program:core", - "//executorch/sdk/bundled_program/schema:bundled_program_schema_py", ], ) diff --git a/sdk/etrecord/__init__.py b/dev_tools/etrecord/__init__.py similarity index 85% rename from sdk/etrecord/__init__.py rename to dev_tools/etrecord/__init__.py index 29c29462a7..04508b6a50 100644 --- a/sdk/etrecord/__init__.py +++ b/dev_tools/etrecord/__init__.py @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -from executorch.sdk.etrecord._etrecord import ( +from executorch.dev_tools.etrecord._etrecord import ( ETRecord, generate_etrecord, parse_etrecord, diff --git a/sdk/etrecord/_etrecord.py b/dev_tools/etrecord/_etrecord.py similarity index 98% rename from sdk/etrecord/_etrecord.py rename to dev_tools/etrecord/_etrecord.py index 55e231f216..43b233e056 100644 --- a/sdk/etrecord/_etrecord.py +++ b/dev_tools/etrecord/_etrecord.py @@ -12,6 +12,9 @@ from zipfile import BadZipFile, ZipFile from executorch import exir +from executorch.dev_tools.bundled_program.core import BundledProgram + +from executorch.dev_tools.bundled_program.schema.bundled_program_schema import Value from executorch.exir import ( EdgeProgramManager, ExecutorchProgram, @@ -23,9 +26,6 @@ from executorch.exir.serde.export_serialize import SerializedArtifact from executorch.exir.serde.serialize import deserialize, serialize -from executorch.sdk.bundled_program.core import BundledProgram - -from executorch.sdk.bundled_program.schema.bundled_program_schema import Value ProgramOutput = List[Value] @@ -182,7 +182,7 @@ def generate_etrecord( is the closest graph module representation of what is eventually run on the device. In addition to all the graph modules, we also serialize the program buffer, which the users can provide to the ExecuTorch runtime to run the model, and the debug handle map - for SDK tooling usage. + for Developer Tools usage. Args: etrecord_path: Path to where the `ETRecord` file will be saved to. @@ -201,7 +201,7 @@ def generate_etrecord( etrecord_zip = ZipFile(et_record, "w") # Write the magic file identifier that will be used to verify that this file - # is an etrecord when it's used later in the SDK tooling. + # is an etrecord when it's used later in the Developer Tools. etrecord_zip.writestr(ETRecordReservedFileNames.ETRECORD_IDENTIFIER, "") if export_modules is not None: diff --git a/sdk/etrecord/tests/TARGETS b/dev_tools/etrecord/tests/TARGETS similarity index 63% rename from sdk/etrecord/tests/TARGETS rename to dev_tools/etrecord/tests/TARGETS index 0984c755a4..cefcafb53b 100644 --- a/sdk/etrecord/tests/TARGETS +++ b/dev_tools/etrecord/tests/TARGETS @@ -8,11 +8,11 @@ python_unittest( srcs = ["etrecord_test.py"], deps = [ "//caffe2:torch", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools/bundled_program:core", + "//executorch/dev_tools/etrecord:etrecord", "//executorch/exir:lib", "//executorch/exir/tests:models", - "//executorch/sdk/bundled_program:config", - "//executorch/sdk/bundled_program:core", - "//executorch/sdk/etrecord:etrecord", ], ) @@ -21,10 +21,10 @@ python_library( srcs = ["etrecord_test.py"], deps = [ "//caffe2:torch", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools/bundled_program:core", + "//executorch/dev_tools/etrecord:etrecord", "//executorch/exir:lib", "//executorch/exir/tests:models", - "//executorch/sdk/bundled_program:config", - "//executorch/sdk/bundled_program:core", - "//executorch/sdk/etrecord:etrecord", ], ) diff --git a/sdk/etrecord/tests/etrecord_test.py b/dev_tools/etrecord/tests/etrecord_test.py similarity index 95% rename from sdk/etrecord/tests/etrecord_test.py rename to dev_tools/etrecord/tests/etrecord_test.py index bc534fd487..1b8c0992c5 100644 --- a/sdk/etrecord/tests/etrecord_test.py +++ b/dev_tools/etrecord/tests/etrecord_test.py @@ -12,14 +12,14 @@ import executorch.exir.tests.models as models import torch from executorch import exir -from executorch.exir import EdgeCompileConfig, EdgeProgramManager, to_edge -from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite -from executorch.sdk.bundled_program.core import BundledProgram -from executorch.sdk.etrecord import generate_etrecord, parse_etrecord -from executorch.sdk.etrecord._etrecord import ( +from executorch.dev_tools.bundled_program.config import MethodTestCase, MethodTestSuite +from executorch.dev_tools.bundled_program.core import BundledProgram +from executorch.dev_tools.etrecord import generate_etrecord, parse_etrecord +from executorch.dev_tools.etrecord._etrecord import ( _get_reference_outputs, ETRecordReservedFileNames, ) +from executorch.exir import EdgeCompileConfig, EdgeProgramManager, to_edge from torch.export import export @@ -75,7 +75,7 @@ def get_test_model_with_manager(self): return (aten_dialect, edge_program_copy, edge_program.to_executorch()) # Serialized and deserialized graph modules are not completely the same, so we check - # that they are close enough and match especially on the parameters we care about in the SDK. + # that they are close enough and match especially on the parameters we care about in the Developer Tools. def check_graph_closeness(self, graph_a, graph_b): self.assertEqual(len(graph_a.graph.nodes), len(graph_b.graph.nodes)) for node_a, node_b in zip(graph_a.graph.nodes, graph_b.graph.nodes): diff --git a/sdk/inspector/TARGETS b/dev_tools/inspector/TARGETS similarity index 69% rename from sdk/inspector/TARGETS rename to dev_tools/inspector/TARGETS index bc53c90c11..a92460a1c9 100644 --- a/sdk/inspector/TARGETS +++ b/dev_tools/inspector/TARGETS @@ -14,10 +14,10 @@ python_library( "fbsource//third-party/pypi/pandas:pandas", "fbsource//third-party/pypi/tabulate:tabulate", ":inspector_utils", + "//executorch/dev_tools/debug_format:et_schema", + "//executorch/dev_tools/etdump:schema_flatcc", + "//executorch/dev_tools/etrecord:etrecord", "//executorch/exir:lib", - "//executorch/sdk/debug_format:et_schema", - "//executorch/sdk/etdump:schema_flatcc", - "//executorch/sdk/etrecord:etrecord", ], ) @@ -27,7 +27,7 @@ python_binary( main_src = "inspector_cli.py", deps = [ ":inspector_utils", - "//executorch/sdk:lib", + "//executorch/dev_tools:lib", ], ) @@ -40,11 +40,11 @@ python_library( "fbsource//third-party/pypi/matplotlib:matplotlib", "fbsource//third-party/pypi/numpy:numpy", "//caffe2:torch", - "//executorch/sdk/debug_format:base_schema", - "//executorch/sdk/debug_format:et_schema", - "//executorch/sdk/etdump:schema_flatcc", - "//executorch/sdk/etdump:serialize", - "//executorch/sdk/etrecord:etrecord", + "//executorch/dev_tools/debug_format:base_schema", + "//executorch/dev_tools/debug_format:et_schema", + "//executorch/dev_tools/etdump:schema_flatcc", + "//executorch/dev_tools/etdump:serialize", + "//executorch/dev_tools/etrecord:etrecord", ], ) diff --git a/sdk/inspector/__init__.py b/dev_tools/inspector/__init__.py similarity index 60% rename from sdk/inspector/__init__.py rename to dev_tools/inspector/__init__.py index bef3d363d5..2b0716a787 100644 --- a/sdk/inspector/__init__.py +++ b/dev_tools/inspector/__init__.py @@ -4,7 +4,12 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -from executorch.sdk.inspector._inspector import Event, EventBlock, Inspector, PerfData -from executorch.sdk.inspector._inspector_utils import TimeScale +from executorch.dev_tools.inspector._inspector import ( + Event, + EventBlock, + Inspector, + PerfData, +) +from executorch.dev_tools.inspector._inspector_utils import TimeScale __all__ = ["Event", "EventBlock", "Inspector", "PerfData", "TimeScale"] diff --git a/sdk/inspector/_inspector.py b/dev_tools/inspector/_inspector.py similarity index 99% rename from sdk/inspector/_inspector.py rename to dev_tools/inspector/_inspector.py index 5f9bfafee7..eb45781ca4 100644 --- a/sdk/inspector/_inspector.py +++ b/dev_tools/inspector/_inspector.py @@ -26,16 +26,19 @@ Union, ) -import executorch.sdk.etdump.schema_flatcc as flatcc +import executorch.dev_tools.etdump.schema_flatcc as flatcc import numpy as np import pandas as pd -from executorch.exir import ExportedProgram -from executorch.sdk.debug_format.et_schema import OperatorGraph, OperatorNode -from executorch.sdk.etdump.schema_flatcc import DebugEvent, ETDumpFlatCC, ProfileEvent -from executorch.sdk.etrecord import ETRecord, parse_etrecord -from executorch.sdk.inspector._inspector_utils import ( +from executorch.dev_tools.debug_format.et_schema import OperatorGraph, OperatorNode +from executorch.dev_tools.etdump.schema_flatcc import ( + DebugEvent, + ETDumpFlatCC, + ProfileEvent, +) +from executorch.dev_tools.etrecord import ETRecord, parse_etrecord +from executorch.dev_tools.inspector._inspector_utils import ( create_debug_handle_to_op_node_mapping, EDGE_DIALECT_GRAPH_KEY, EXCLUDED_COLUMNS_WHEN_PRINTING, @@ -53,6 +56,7 @@ TimeScale, verify_debug_data_equivalence, ) +from executorch.exir import ExportedProgram from tabulate import tabulate diff --git a/sdk/inspector/_inspector_utils.py b/dev_tools/inspector/_inspector_utils.py similarity index 97% rename from sdk/inspector/_inspector_utils.py rename to dev_tools/inspector/_inspector_utils.py index 6879e85505..fd4ab86b9d 100644 --- a/sdk/inspector/_inspector_utils.py +++ b/dev_tools/inspector/_inspector_utils.py @@ -8,14 +8,14 @@ from enum import Enum from typing import Dict, List, Mapping, Optional, Tuple, TypeAlias, Union -import executorch.sdk.etdump.schema_flatcc as flatcc +import executorch.dev_tools.etdump.schema_flatcc as flatcc import torch -from executorch.sdk.debug_format.base_schema import OperatorNode +from executorch.dev_tools.debug_format.base_schema import OperatorNode -from executorch.sdk.debug_format.et_schema import FXOperatorGraph, OperatorGraph -from executorch.sdk.etdump.schema_flatcc import ( +from executorch.dev_tools.debug_format.et_schema import FXOperatorGraph, OperatorGraph +from executorch.dev_tools.etdump.schema_flatcc import ( DebugEvent, ETDumpFlatCC, ProfileEvent, @@ -25,8 +25,8 @@ ValueType, ) -from executorch.sdk.etdump.serialize import deserialize_from_etdump_flatcc -from executorch.sdk.etrecord import ETRecord +from executorch.dev_tools.etdump.serialize import deserialize_from_etdump_flatcc +from executorch.dev_tools.etrecord import ETRecord FORWARD = "forward" EDGE_DIALECT_GRAPH_KEY = "edge_dialect_graph_module" diff --git a/sdk/inspector/inspector_cli.py b/dev_tools/inspector/inspector_cli.py similarity index 93% rename from sdk/inspector/inspector_cli.py rename to dev_tools/inspector/inspector_cli.py index d6c8d5442f..49346e7c10 100644 --- a/sdk/inspector/inspector_cli.py +++ b/dev_tools/inspector/inspector_cli.py @@ -6,8 +6,8 @@ import argparse -from executorch.sdk import Inspector -from executorch.sdk.inspector._inspector_utils import compare_results, TimeScale +from executorch.dev_tools import Inspector +from executorch.dev_tools.inspector._inspector_utils import compare_results, TimeScale def main() -> None: diff --git a/dev_tools/inspector/tests/TARGETS b/dev_tools/inspector/tests/TARGETS new file mode 100644 index 0000000000..cb36f43177 --- /dev/null +++ b/dev_tools/inspector/tests/TARGETS @@ -0,0 +1,41 @@ +load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") + +oncall("executorch") + +python_unittest( + name = "inspector_test", + srcs = ["inspector_test.py"], + deps = [ + "//executorch/dev_tools:lib", + "//executorch/dev_tools/debug_format:et_schema", + "//executorch/dev_tools/etdump:schema_flatcc", + "//executorch/dev_tools/etrecord/tests:etrecord_test_library", + "//executorch/dev_tools/inspector:inspector", + "//executorch/dev_tools/inspector:lib", + "//executorch/exir:lib", + ], +) + +python_unittest( + name = "event_blocks_test", + srcs = ["event_blocks_test.py"], + deps = [ + "//executorch/dev_tools/etdump:schema_flatcc", + "//executorch/dev_tools/inspector:inspector", + "//executorch/dev_tools/inspector:lib", + ], +) + +python_unittest( + name = "inspector_utils_test", + srcs = ["inspector_utils_test.py"], + deps = [ + "//caffe2:torch", + "//executorch/dev_tools:lib", + "//executorch/dev_tools/debug_format:base_schema", + "//executorch/dev_tools/debug_format:et_schema", + "//executorch/dev_tools/etdump:schema_flatcc", + "//executorch/dev_tools/etrecord/tests:etrecord_test_library", + "//executorch/dev_tools/inspector:inspector_utils", + ], +) diff --git a/sdk/inspector/tests/event_blocks_test.py b/dev_tools/inspector/tests/event_blocks_test.py similarity index 98% rename from sdk/inspector/tests/event_blocks_test.py rename to dev_tools/inspector/tests/event_blocks_test.py index 7c7da00186..200ce72609 100644 --- a/sdk/inspector/tests/event_blocks_test.py +++ b/dev_tools/inspector/tests/event_blocks_test.py @@ -8,10 +8,10 @@ import unittest from typing import List, Optional, Tuple, Union -import executorch.sdk.etdump.schema_flatcc as flatcc -from executorch.sdk.etdump.schema_flatcc import ETDumpFlatCC, ProfileEvent -from executorch.sdk.inspector import Event, EventBlock, PerfData -from executorch.sdk.inspector._inspector import ( +import executorch.dev_tools.etdump.schema_flatcc as flatcc +from executorch.dev_tools.etdump.schema_flatcc import ETDumpFlatCC, ProfileEvent +from executorch.dev_tools.inspector import Event, EventBlock, PerfData +from executorch.dev_tools.inspector._inspector import ( DelegateMetadata, EventSignature, InstructionEvent, diff --git a/sdk/inspector/tests/inspector_test.py b/dev_tools/inspector/tests/inspector_test.py similarity index 97% rename from sdk/inspector/tests/inspector_test.py rename to dev_tools/inspector/tests/inspector_test.py index a372c7c569..436f6fa882 100644 --- a/sdk/inspector/tests/inspector_test.py +++ b/dev_tools/inspector/tests/inspector_test.py @@ -14,14 +14,19 @@ from unittest.mock import patch -from executorch.exir import ExportedProgram -from executorch.sdk import generate_etrecord, parse_etrecord -from executorch.sdk.debug_format.et_schema import OperatorNode -from executorch.sdk.etdump.schema_flatcc import ProfileEvent -from executorch.sdk.etrecord.tests.etrecord_test import TestETRecord - -from executorch.sdk.inspector import _inspector, Event, EventBlock, Inspector, PerfData -from executorch.sdk.inspector._inspector import ( +from executorch.dev_tools import generate_etrecord, parse_etrecord +from executorch.dev_tools.debug_format.et_schema import OperatorNode +from executorch.dev_tools.etdump.schema_flatcc import ProfileEvent +from executorch.dev_tools.etrecord.tests.etrecord_test import TestETRecord + +from executorch.dev_tools.inspector import ( + _inspector, + Event, + EventBlock, + Inspector, + PerfData, +) +from executorch.dev_tools.inspector._inspector import ( DebugEventSignature, flatcc, InstructionEvent, @@ -29,6 +34,8 @@ ProfileEventSignature, ) +from executorch.exir import ExportedProgram + OP_TYPE = "aten::add" EVENT_BLOCK_NAME = "block_0" diff --git a/sdk/inspector/tests/inspector_utils_test.py b/dev_tools/inspector/tests/inspector_utils_test.py similarity index 94% rename from sdk/inspector/tests/inspector_utils_test.py rename to dev_tools/inspector/tests/inspector_utils_test.py index b5b9b54d6c..13d2f2459a 100644 --- a/sdk/inspector/tests/inspector_utils_test.py +++ b/dev_tools/inspector/tests/inspector_utils_test.py @@ -10,19 +10,19 @@ import torch -from executorch.sdk import generate_etrecord, parse_etrecord +from executorch.dev_tools import generate_etrecord, parse_etrecord -from executorch.sdk.debug_format.base_schema import ( +from executorch.dev_tools.debug_format.base_schema import ( OperatorGraph, OperatorNode, ValueNode, ) -from executorch.sdk.debug_format.et_schema import FXOperatorGraph -from executorch.sdk.etdump import schema_flatcc as flatcc +from executorch.dev_tools.debug_format.et_schema import FXOperatorGraph +from executorch.dev_tools.etdump import schema_flatcc as flatcc -from executorch.sdk.etrecord.tests.etrecord_test import TestETRecord -from executorch.sdk.inspector._inspector_utils import ( +from executorch.dev_tools.etrecord.tests.etrecord_test import TestETRecord +from executorch.dev_tools.inspector._inspector_utils import ( create_debug_handle_to_op_node_mapping, EDGE_DIALECT_GRAPH_KEY, find_populated_event, diff --git a/sdk/size_analysis_tool/TARGETS b/dev_tools/size_analysis_tool/TARGETS similarity index 85% rename from sdk/size_analysis_tool/TARGETS rename to dev_tools/size_analysis_tool/TARGETS index 44ae0aa6f8..511f847d75 100644 --- a/sdk/size_analysis_tool/TARGETS +++ b/dev_tools/size_analysis_tool/TARGETS @@ -12,9 +12,9 @@ python_library( visibility = ["PUBLIC"], deps = [ "//caffe2:torch", + "//executorch/dev_tools:lib", "//executorch/exir:lib", "//executorch/exir/backend:backend_api", - "//executorch/sdk:lib", ], ) @@ -23,13 +23,13 @@ python_binary( srcs = [ "size_analysis_tool.py", ], - main_function = "executorch.sdk.size_analysis_tool.size_analysis_tool.main", + main_function = "executorch.dev_tools.size_analysis_tool.size_analysis_tool.main", visibility = ["PUBLIC"], deps = [ "//caffe2:torch", + "//executorch/dev_tools:lib", "//executorch/exir:lib", "//executorch/exir/backend:backend_api", - "//executorch/sdk:lib", ], ) @@ -43,9 +43,9 @@ python_unittest( "//caffe2:torch", "//executorch/backends/xnnpack/partition:xnnpack_partitioner", "//executorch/backends/xnnpack/utils:xnnpack_utils", + "//executorch/dev_tools:lib", "//executorch/exir:lib", "//executorch/exir/backend:backend_api", "//executorch/exir/passes:spec_prop_pass", - "//executorch/sdk:lib", ], ) diff --git a/sdk/size_analysis_tool/size_analysis_tool.py b/dev_tools/size_analysis_tool/size_analysis_tool.py similarity index 99% rename from sdk/size_analysis_tool/size_analysis_tool.py rename to dev_tools/size_analysis_tool/size_analysis_tool.py index d17ec5ac47..9fcf364616 100644 --- a/sdk/size_analysis_tool/size_analysis_tool.py +++ b/dev_tools/size_analysis_tool/size_analysis_tool.py @@ -9,10 +9,10 @@ from typing import Any, Callable, Dict, List, Optional, Tuple import torch +from executorch.dev_tools import parse_etrecord from executorch.exir import ExportedProgram from executorch.exir.backend.backend_api import LoweredBackendModule -from executorch.sdk import parse_etrecord def _get_tensor_data(node: torch.fx.Node, tensor: torch.Tensor) -> Dict[str, Any]: diff --git a/sdk/size_analysis_tool/size_analysis_tool_test.py b/dev_tools/size_analysis_tool/size_analysis_tool_test.py similarity index 98% rename from sdk/size_analysis_tool/size_analysis_tool_test.py rename to dev_tools/size_analysis_tool/size_analysis_tool_test.py index 3e1efec77b..bf63042c26 100644 --- a/sdk/size_analysis_tool/size_analysis_tool_test.py +++ b/dev_tools/size_analysis_tool/size_analysis_tool_test.py @@ -14,12 +14,12 @@ get_xnnpack_executorch_backend_config, ) from executorch.backends.xnnpack.utils.utils import capture_graph_for_xnnpack -from executorch.exir.backend.backend_api import to_backend, validation_disabled -from executorch.exir.passes.spec_prop_pass import SpecPropPass -from executorch.sdk.size_analysis_tool.size_analysis_tool import ( +from executorch.dev_tools.size_analysis_tool.size_analysis_tool import ( generate_model_size_information, ) +from executorch.exir.backend.backend_api import to_backend, validation_disabled +from executorch.exir.passes.spec_prop_pass import SpecPropPass class SizeAnalysisToolTest(unittest.TestCase): diff --git a/dev_tools/targets.bzl b/dev_tools/targets.bzl new file mode 100644 index 0000000000..0fa39dbb90 --- /dev/null +++ b/dev_tools/targets.bzl @@ -0,0 +1,8 @@ +def build_dev_tools(): + return native.read_config("executorch", "build_dev_tools", "false") == "true" + +def get_dev_tools_flags(): + dev_tools_flags = [] + if build_dev_tools(): + dev_tools_flags += ["-DEXECUTORCH_BUILD_DEV_TOOLS"] + return dev_tools_flags diff --git a/dev_tools/test/run_oss_cpp_tests.sh b/dev_tools/test/run_oss_cpp_tests.sh new file mode 100755 index 0000000000..ed1a45e7e2 --- /dev/null +++ b/dev_tools/test/run_oss_cpp_tests.sh @@ -0,0 +1,147 @@ +#!/bin/bash +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# This script helps build and run C++ tests with CMakeLists.txt. +# It builds and installs the root ExecuTorch package, and then sub-directories. +# +# If no arg is given, it probes all sub-directories containing +# test/CMakeLists.txt. It builds and runs these tests. +# If an arg is given, like `runtime/core/test/`, it runs that directory only. + +set -ex + +if [[ $(uname) == "Darwin" ]]; then + export LLVM_PROFDATA="${LLVM_PROFDATA:-xcrun llvm-profdata}" + export LLVM_COV="${LLVM_COV:-xcrun llvm-cov}" +elif [[ $(uname) == "Linux" ]]; then + export LLVM_PROFDATA="${LLVM_PROFDATA:-llvm-profdata}" + export LLVM_COV="${LLVM_COV:-llvm-cov}" +fi + +build_executorch() { + BUILD_VULKAN="OFF" + if [ -x "$(command -v glslc)" ]; then + BUILD_VULKAN="ON" + fi + cmake . \ + -DCMAKE_INSTALL_PREFIX=cmake-out \ + -DEXECUTORCH_USE_CPP_CODE_COVERAGE=ON \ + -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \ + -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \ + -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \ + -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ + -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ + -DEXECUTORCH_BUILD_VULKAN=$BUILD_VULKAN \ + -DEXECUTORCH_BUILD_XNNPACK=ON \ + -Bcmake-out + cmake --build cmake-out -j9 --target install +} + +build_gtest() { + mkdir -p third-party/googletest/build + pushd third-party/googletest/build + cmake .. -DCMAKE_INSTALL_PREFIX=. + make -j4 + make install + popd +} + +export_test_model() { + python3 -m test.models.export_program --modules "ModuleAdd,ModuleAddHalf,ModuleDynamicCatUnallocatedIO,ModuleIndex,ModuleLinear,ModuleMultipleEntry" --outdir "cmake-out" 2> /dev/null + python3 -m test.models.export_delegated_program --modules "ModuleAddMul" --backend_id "StubBackend" --outdir "cmake-out" || true + + ET_MODULE_ADD_HALF_PATH="$(realpath cmake-out/ModuleAddHalf.pte)" + ET_MODULE_ADD_PATH="$(realpath cmake-out/ModuleAdd.pte)" + ET_MODULE_DYNAMIC_CAT_UNALLOCATED_IO_PATH="$(realpath cmake-out/ModuleDynamicCatUnallocatedIO.pte)" + ET_MODULE_INDEX_PATH="$(realpath cmake-out/ModuleIndex.pte)" + ET_MODULE_LINEAR_CONSTANT_BUFFER_PATH="$(realpath cmake-out/ModuleLinear-no-constant-segment.pte)" + ET_MODULE_LINEAR_CONSTANT_SEGMENT_PATH="$(realpath cmake-out/ModuleLinear.pte)" + ET_MODULE_MULTI_ENTRY_PATH="$(realpath cmake-out/ModuleMultipleEntry.pte)" + ET_MODULE_ADD_MUL_NOSEGMENTS_DA1024_PATH="$(realpath cmake-out/ModuleAddMul-nosegments-da1024.pte)" + ET_MODULE_ADD_MUL_NOSEGMENTS_PATH="$(realpath cmake-out/ModuleAddMul-nosegments.pte)" + ET_MODULE_ADD_MUL_PATH="$(realpath cmake-out/ModuleAddMul.pte)" + export ET_MODULE_ADD_HALF_PATH + export ET_MODULE_ADD_PATH + export ET_MODULE_DYNAMIC_CAT_UNALLOCATED_IO_PATH + export ET_MODULE_INDEX_PATH + export ET_MODULE_LINEAR_CONSTANT_BUFFER_PATH + export ET_MODULE_LINEAR_CONSTANT_SEGMENT_PATH + export ET_MODULE_MULTI_ENTRY_PATH + export ET_MODULE_ADD_MUL_NOSEGMENTS_DA1024_PATH + export ET_MODULE_ADD_MUL_NOSEGMENTS_PATH + export ET_MODULE_ADD_MUL_PATH +} + +build_and_run_test() { + local test_dir=$1 + cmake "${test_dir}" \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX=cmake-out \ + -DEXECUTORCH_USE_CPP_CODE_COVERAGE=ON \ + -DCMAKE_PREFIX_PATH="$(pwd)/third-party/googletest/build" \ + -Bcmake-out/"${test_dir}" + cmake --build cmake-out/"${test_dir}" -j9 + + if [[ "$test_dir" =~ .*examples/models/llama2/tokenizer.* ]]; then + RESOURCES_PATH=$(realpath examples/models/llama2/tokenizer/test/resources) + elif [[ "$test_dir" =~ .*extension/llm/tokenizer.* ]]; then + RESOURCES_PATH=$(realpath extension/llm/tokenizer/test/resources) + else + RESOURCES_PATH=$(realpath extension/module/test/resources) + fi + export RESOURCES_PATH + + for t in cmake-out/"${test_dir}"/*test; do + if [ -e "$t" ]; then + LLVM_PROFILE_FILE="cmake-out/$(basename $t).profraw" ./"$t"; + TEST_BINARY_LIST="${TEST_BINARY_LIST} -object $t" + fi + done +} + +report_coverage() { + ${LLVM_PROFDATA} merge -sparse cmake-out/*.profraw -o cmake-out/merged.profdata + ${LLVM_COV} report -instr-profile=cmake-out/merged.profdata $TEST_BINARY_LIST +} + +probe_tests() { + # This function finds the set of directories that contain C++ tests + # CMakeLists.txt rules, that are buildable using build_and_run_test + dirs=( + backends + examples + extension + kernels + runtime + schema + dev_tools + test + ) + + find "${dirs[@]}" \ + \( -type f -wholename '*/test/CMakeLists.txt' -exec dirname {} \; \) -o \ + \( -type d -path '*/third-party/*' -prune \) \ + | sort -u +} + +build_executorch +build_gtest +export_test_model + +if [ -z "$1" ]; then + echo "Running all directories:" + probe_tests + + for test_dir in $(probe_tests); do + build_and_run_test "${test_dir}" + done +else + build_and_run_test "$1" +fi + +report_coverage || true diff --git a/docs/source/_static/img/how-executorch-works-high-level.png b/docs/source/_static/img/how-executorch-works-high-level.png index 58b7369d5f2ee512665c34f5cef970711115cfff..9a736f901f8820f91ac8cf1a1722b473f1c60e84 100644 GIT binary patch delta 51 zcmezOORnX&T*DT|mpeIAQp@5?^7C_w+u!VD1Y#y2W(HywAZ7((w(W0rvQJ_L0J*= 14.4. -1. [Optional] Generate an [ETRecord](./sdk-etrecord.rst) when exporting your model. +1. [Optional] Generate an [ETRecord](./dev-tools-etrecord.rst) when exporting your model. ```bash cd executorch @@ -100,7 +100,7 @@ python3 -m examples.apple.coreml.scripts.export --model_name mv3 --generate_etre # Builds `coreml_executor_runner`. ./examples/apple/coreml/scripts/build_executor_runner.sh ``` -3. Run and generate an [ETDump](./sdk-etdump.md). +3. Run and generate an [ETDump](./dev-tools-etdump.md). ```bash cd executorch @@ -108,7 +108,7 @@ cd executorch ./coreml_executor_runner --model_path mv3_coreml_all.pte --profile_model --etdump_path etdump.etdp ``` -4. Create an instance of the [Inspector API](./sdk-inspector.rst) by passing in the [ETDump](./sdk-etdump.md) you have sourced from the runtime along with the optionally generated [ETRecord](./sdk-etrecord.rst) from step 1 or execute the following command in your terminal to display the profiling data table. +4. Create an instance of the [Inspector API](./dev-tools-inspector.rst) by passing in the [ETDump](./dev-tools-etdump.md) you have sourced from the runtime along with the optionally generated [ETRecord](./dev-tools-etrecord.rst) from step 1 or execute the following command in your terminal to display the profiling data table. ```bash python examples/apple/coreml/scripts/inspector_cli.py --etdump_path etdump.etdp --etrecord_path mv3_coreml.bin ``` diff --git a/docs/source/build-run-qualcomm-ai-engine-direct-backend.md b/docs/source/build-run-qualcomm-ai-engine-direct-backend.md index ff5cb51595..48b2bbdd93 100644 --- a/docs/source/build-run-qualcomm-ai-engine-direct-backend.md +++ b/docs/source/build-run-qualcomm-ai-engine-direct-backend.md @@ -143,7 +143,7 @@ cd build_android # build executorch & qnn_executorch_backend cmake .. \ -DCMAKE_INSTALL_PREFIX=$PWD \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_BUILD_QNN=ON \ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ -DQNN_SDK_ROOT=$QNN_SDK_ROOT \ diff --git a/docs/source/compiler-delegate-and-partitioner.md b/docs/source/compiler-delegate-and-partitioner.md index 52a515aa7f..49595237b5 100644 --- a/docs/source/compiler-delegate-and-partitioner.md +++ b/docs/source/compiler-delegate-and-partitioner.md @@ -127,13 +127,13 @@ static auto success_with_compiler = register_backend(backend); ``` -## SDK Integration: Debuggability +## Developer Tools Integration: Debuggability -Providing consistent debugging experience, be it for runtime failures or performance profiling, is important. ExecuTorch employs native SDK (Software Development Kit) for this purpose, which enables correlating program instructions to original PyTorch code, via debug handles. You can read more about it [here](./sdk-etrecord). +Providing consistent debugging experience, be it for runtime failures or performance profiling, is important. ExecuTorch employs native Developer Tools for this purpose, which enables correlating program instructions to original PyTorch code, via debug handles. You can read more about it [here](./dev-tools-etrecord). -Delegated program or subgraphs are opaque to ExecuTorch runtime and appear as a special `call_delegate` instruction, which asks corresponding backend to handle the execution of the subgraph or program. Due to the opaque nature of backend delgates, native SDK does not have visibility into delegated program. Thus the debugging, functional or performance, experiences of delegated execution suffers significantly as compared to it's non-delegated counterpart. +Delegated program or subgraphs are opaque to ExecuTorch runtime and appear as a special `call_delegate` instruction, which asks corresponding backend to handle the execution of the subgraph or program. Due to the opaque nature of backend delgates, native Developer Tools does not have visibility into delegated program. Thus the debugging, functional or performance, experiences of delegated execution suffers significantly as compared to it's non-delegated counterpart. -In order to provide consistent debugging experience to users, regardless of the use of delegation for a model, SDK provides an interface to correlate delegated (sub)graph to original (sub)graph. The SDK does so via debug handles map which allows delegates to generate internal handles that can be associated with the original (sub)graph consumed by the delegate. Then at runtime, backend developer can report error or profiling information using the internal handle, which will be mapped to original (sub)graph using the debug handle map. For more information, please refer to [SDK delegate integration](./sdk-delegate-integration). +In order to provide consistent debugging experience to users, regardless of the use of delegation for a model, Developer Tools provides an interface to correlate delegated (sub)graph to original (sub)graph. The Developer Tools does so via debug handles map which allows delegates to generate internal handles that can be associated with the original (sub)graph consumed by the delegate. Then at runtime, backend developer can report error or profiling information using the internal handle, which will be mapped to original (sub)graph using the debug handle map. For more information, please refer to [Developer Tools delegate integration](./dev-tools-delegate-integration). By leveraging the debug identifier, backend developer can embed the debug as part of the delegated blob diff --git a/docs/source/concepts.md b/docs/source/concepts.md index 33d944c376..ef500bafad 100644 --- a/docs/source/concepts.md +++ b/docs/source/concepts.md @@ -283,9 +283,9 @@ Techniques for performing computations and memory accesses on tensors with lower The ExecuTorch runtime executes models on edge devices. It is responsible for program initialization, program execution and, optionally, destruction (releasing backend owned resources). -## [SDK](./sdk-overview.md) +## [Developer Tools](./dev-tools-overview.md) -Software Development Kit. The tooling users need to profile, debug and visualize programs that are running with ExecuTorch. +The tooling users need to profile, debug and visualize programs that are running with ExecuTorch. ## [Selective build](./kernel-library-selective-build.md) diff --git a/docs/source/sdk-bundled-io.md b/docs/source/dev-tools-bundled-io.md similarity index 90% rename from docs/source/sdk-bundled-io.md rename to docs/source/dev-tools-bundled-io.md index 33deae3904..1ae6fa4727 100644 --- a/docs/source/sdk-bundled-io.md +++ b/docs/source/dev-tools-bundled-io.md @@ -28,7 +28,7 @@ In `BundledProgram`, we create two new classes, `MethodTestCase` and `MethodTest :::{dropdown} `MethodTestCase` ```{eval-rst} -.. autofunction:: executorch.sdk.bundled_program.config.MethodTestCase.__init__ +.. autofunction:: executorch.dev_tools.bundled_program.config.MethodTestCase.__init__ :noindex: ``` ::: @@ -38,7 +38,7 @@ In `BundledProgram`, we create two new classes, `MethodTestCase` and `MethodTest :::{dropdown} `MethodTestSuite` ```{eval-rst} -.. autofunction:: executorch.sdk.bundled_program.config.MethodTestSuite +.. autofunction:: executorch.dev_tools.bundled_program.config.MethodTestSuite :noindex: ``` ::: @@ -48,13 +48,13 @@ Since each model may have multiple inference methods, we need to generate `List[ ### Step 3: Generate `BundledProgram` -We provide `BundledProgram` class under `executorch/sdk/bundled_program/core.py` to bundled the `ExecutorchProgram`-like variable, including +We provide `BundledProgram` class under `executorch/dev_tools/bundled_program/core.py` to bundled the `ExecutorchProgram`-like variable, including `ExecutorchProgram`, `MultiMethodExecutorchProgram` or `ExecutorchProgramManager`, with the `List[MethodTestSuite]`: :::{dropdown} `BundledProgram` ```{eval-rst} -.. autofunction:: executorch.sdk.bundled_program.core.BundledProgram.__init__ +.. autofunction:: executorch.dev_tools.bundled_program.core.BundledProgram.__init__ :noindex: ``` ::: @@ -65,18 +65,18 @@ Construtor of `BundledProgram `will do sannity check internally to see if the gi ### Step 4: Serialize `BundledProgram` to Flatbuffer. -To serialize `BundledProgram` to make runtime APIs use it, we provide two APIs, both under `executorch/sdk/bundled_program/serialize/__init__.py`. +To serialize `BundledProgram` to make runtime APIs use it, we provide two APIs, both under `executorch/dev_tools/bundled_program/serialize/__init__.py`. :::{dropdown} Serialize and Deserialize ```{eval-rst} -.. currentmodule:: executorch.sdk.bundled_program.serialize +.. currentmodule:: executorch.dev_tools.bundled_program.serialize .. autofunction:: serialize_from_bundled_program_to_flatbuffer :noindex: ``` ```{eval-rst} -.. currentmodule:: executorch.sdk.bundled_program.serialize +.. currentmodule:: executorch.dev_tools.bundled_program.serialize .. autofunction:: deserialize_from_flatbuffer_to_bundled_program :noindex: ``` @@ -90,10 +90,10 @@ Here is a flow highlighting how to generate a `BundledProgram` given a PyTorch m import torch from executorch.exir import to_edge -from executorch.sdk import BundledProgram +from executorch.dev_tools import BundledProgram -from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite -from executorch.sdk.bundled_program.serialize import ( +from executorch.dev_tools.bundled_program.config import MethodTestCase, MethodTestSuite +from executorch.dev_tools.bundled_program.serialize import ( serialize_from_bundled_program_to_flatbuffer, ) from torch._export import capture_pre_autograd_graph @@ -187,7 +187,7 @@ with open(save_path, "wb") as f: We can also regenerate `BundledProgram` from flatbuffer file if needed: ```python -from executorch.sdk.bundled_program.serialize import deserialize_from_flatbuffer_to_bundled_program +from executorch.dev_tools.bundled_program.serialize import deserialize_from_flatbuffer_to_bundled_program save_path = "bundled_program.bpte" with open(save_path, "rb") as f: serialized_bundled_program = f.read() @@ -255,7 +255,7 @@ We call `torch::executor::bundled_program::VerifyResultWithBundledExpectedOutput ### Runtime Example -Here we provide an example about how to run the bundled program step by step. Most of the code is borrowed from [executor_runner](https://github.com/pytorch/executorch/blob/main/examples/sdk/sdk_example_runner/sdk_example_runner.cpp), and please review that file if you need more info and context: +Here we provide an example about how to run the bundled program step by step. Most of the code is borrowed from [executor_runner](https://github.com/pytorch/executorch/blob/main/examples/dev_tools/dev_tools_example_runner/dev_tools_example_runner.cpp), and please review that file if you need more info and context: ```c++ // method_name is the name for the method we want to test @@ -313,9 +313,9 @@ Here's the example of the dtype of test input not meet model's requirement: import torch from executorch.exir import to_edge -from executorch.sdk import BundledProgram +from executorch.dev_tools import BundledProgram -from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite +from executorch.dev_tools.bundled_program.config import MethodTestCase, MethodTestSuite from torch.export import export @@ -400,7 +400,7 @@ Cell In[1], line 72 68 ] 70 # Step 3: Generate BundledProgram ---> 72 bundled_program = create_bundled_program(program, method_test_suites) -File /executorch/sdk/bundled_program/core.py:276, in create_bundled_program(program, method_test_suites) +File /executorch/dev_tools/bundled_program/core.py:276, in create_bundled_program(program, method_test_suites) 264 """Create bp_schema.BundledProgram by bundling the given program and method_test_suites together. 265 266 Args: @@ -411,7 +411,7 @@ File /executorch/sdk/bundled_program/core.py:276, in create_bundled_program(prog --> 276 assert_valid_bundle(program, method_test_suites) 278 bundled_method_test_suites: List[bp_schema.BundledMethodTestSuite] = [] 280 # Emit data and metadata of bundled tensor -File /executorch/sdk/bundled_program/core.py:219, in assert_valid_bundle(program, method_test_suites) +File /executorch/dev_tools/bundled_program/core.py:219, in assert_valid_bundle(program, method_test_suites) 215 # type of tensor input should match execution plan 216 if type(cur_plan_test_inputs[j]) == torch.Tensor: 217 # pyre-fixme[16]: Undefined attribute [16]: Item `bool` of `typing.Union[bool, float, int, torch._tensor.Tensor]` @@ -449,9 +449,9 @@ Another common error would be the method name in any `MethodTestSuite` does not import torch from executorch.exir import to_edge -from executorch.sdk import BundledProgram +from executorch.dev_tools import BundledProgram -from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite +from executorch.dev_tools.bundled_program.config import MethodTestCase, MethodTestSuite from torch.export import export @@ -532,7 +532,7 @@ Cell In[3], line 73 70 method_test_suites[0].method_name = "MISSING_METHOD_NAME" 72 # Generate BundledProgram ---> 73 bundled_program = create_bundled_program(program, method_test_suites) -File /executorch/sdk/bundled_program/core.py:276, in create_bundled_program(program, method_test_suites) +File /executorch/dev_tools/bundled_program/core.py:276, in create_bundled_program(program, method_test_suites) 264 """Create bp_schema.BundledProgram by bundling the given program and method_test_suites together. 265 266 Args: @@ -543,7 +543,7 @@ File /executorch/sdk/bundled_program/core.py:276, in create_bundled_program(prog --> 276 assert_valid_bundle(program, method_test_suites) 278 bundled_method_test_suites: List[bp_schema.BundledMethodTestSuite] = [] 280 # Emit data and metadata of bundled tensor -File /executorch/sdk/bundled_program/core.py:141, in assert_valid_bundle(program, method_test_suites) +File /executorch/dev_tools/bundled_program/core.py:141, in assert_valid_bundle(program, method_test_suites) 138 method_name_of_program = {e.name for e in program.execution_plan} 139 method_name_of_test_suites = {t.method_name for t in method_test_suites} --> 141 assert method_name_of_test_suites.issubset( diff --git a/docs/source/sdk-debugging.md b/docs/source/dev-tools-debugging.md similarity index 71% rename from docs/source/sdk-debugging.md rename to docs/source/dev-tools-debugging.md index 45e50b44e8..340f9e4945 100644 --- a/docs/source/sdk-debugging.md +++ b/docs/source/dev-tools-debugging.md @@ -1,6 +1,6 @@ # Debugging Models in ExecuTorch -With the ExecuTorch SDK, users can debug their models for numerical inaccurcies and extract model outputs from their device to do quality analysis (such as Signal-to-Noise, Mean square error etc.). +With the ExecuTorch Developer Tools, users can debug their models for numerical inaccurcies and extract model outputs from their device to do quality analysis (such as Signal-to-Noise, Mean square error etc.). Currently, ExecuTorch supports the following debugging flows: - Extraction of model level outputs via ETDump. @@ -11,10 +11,10 @@ Currently, ExecuTorch supports the following debugging flows: ## Steps to debug a model in ExecuTorch ### Runtime -For a real example reflecting the steps below, please refer to [sdk_example_runner.cpp](https://github.com/pytorch/executorch/blob/main/examples/sdk/sdk_example_runner/sdk_example_runner.cpp). +For a real example reflecting the steps below, please refer to [dev_tools_example_runner.cpp](https://github.com/pytorch/executorch/blob/main/examples/dev_tools/dev_tools_example_runner/dev_tools_example_runner.cpp). -1. [Optional] Generate an [ETRecord](./sdk-etrecord.rst) while exporting your model. When provided, this enables users to link profiling information back to the eager model source code (with stack traces and module hierarchy). -2. Integrate [ETDump generation](./sdk-etdump.md) into the runtime and set the debugging level by configuring the `ETDumpGen` object. Then, provide an additional buffer to which intermediate outputs and program outputs will be written. Currently we support two levels of debugging: +1. [Optional] Generate an [ETRecord](./dev-tools-etrecord.rst) while exporting your model. When provided, this enables users to link profiling information back to the eager model source code (with stack traces and module hierarchy). +2. Integrate [ETDump generation](./dev-tools-etdump.md) into the runtime and set the debugging level by configuring the `ETDumpGen` object. Then, provide an additional buffer to which intermediate outputs and program outputs will be written. Currently we support two levels of debugging: - Program level outputs ```C++ Span buffer((uint8_t*)debug_buffer, debug_buffer_size); @@ -30,15 +30,15 @@ For a real example reflecting the steps below, please refer to [sdk_example_runn etdump_gen.set_event_tracer_debug_level( EventTracerDebugLogLevel::kIntermediateOutputs); ``` -3. Build the runtime with the pre-processor flag that enables tracking of debug events. Instructions are in the [ETDump documentation](./sdk-etdump.md). -4. Run your model and dump out the ETDump buffer as described [here](./sdk-etdump.md). (Do so similarly for the debug buffer if configured above) +3. Build the runtime with the pre-processor flag that enables tracking of debug events. Instructions are in the [ETDump documentation](./dev-tools-etdump.md). +4. Run your model and dump out the ETDump buffer as described [here](./dev-tools-etdump.md). (Do so similarly for the debug buffer if configured above) ### Accessing the debug outputs post run using the Inspector API's -Once a model has been run, using the generated ETDump and debug buffers, users can leverage the [Inspector API's](./sdk-inspector.rst) to inspect these debug outputs. +Once a model has been run, using the generated ETDump and debug buffers, users can leverage the [Inspector API's](./dev-tools-inspector.rst) to inspect these debug outputs. ```python -from executorch.sdk import Inspector +from executorch.dev_tools import Inspector # Create an Inspector instance with etdump and the debug buffer. inspector = Inspector(etdump_path=etdump_path, @@ -67,7 +67,7 @@ We've also provided a simple set of utilities that let users perform quality ana ```python -from executorch.sdk.inspector._inspector_utils import compare_results +from executorch.dev_tools.inspector._inspector_utils import compare_results # Run a simple quality analysis between the model outputs sourced from the # runtime and a set of reference outputs. diff --git a/docs/source/sdk-delegate-integration.md b/docs/source/dev-tools-delegate-integration.md similarity index 99% rename from docs/source/sdk-delegate-integration.md rename to docs/source/dev-tools-delegate-integration.md index 8003371155..e201f5aee4 100644 --- a/docs/source/sdk-delegate-integration.md +++ b/docs/source/dev-tools-delegate-integration.md @@ -1,4 +1,4 @@ -# SDK Delegate Integration +# Developer Tools Delegate Integration [Delegate backends](compiler-delegate-and-partitioner.md) are a prominent component of on-device models due to their flexibility in defining behavior. A side effect of this flexibility is that it operates as an opaque transformation. This obfuscates rich associations and mutations that are valuable in post-processing. - For example, if two different operator fusions were to occur within a delegate, post processing wouldn’t be able to separate the two transformations. @@ -127,7 +127,7 @@ A demo of the runtime code can be found [here](https://github.com/pytorch/execut ## Surfacing custom metadata from delegate events -As seen in the runtime logging API's above, users can log an array of bytes along with their delegate profiling event. We make this data available for users in post processing via the [Inspector API](./sdk-inspector.rst). +As seen in the runtime logging API's above, users can log an array of bytes along with their delegate profiling event. We make this data available for users in post processing via the [Inspector API](./dev-tools-inspector.rst). Users can pass a metadata parser when creating an instance of the Inspector. The parser is a callable that deserializes the data and returns a list of strings or a dictionary containing key-value pairs. The deserialized data is then added back to the corresponding event in the event block for user consumption. Here's an example of how to write this parser: diff --git a/docs/source/sdk-etdump.md b/docs/source/dev-tools-etdump.md similarity index 76% rename from docs/source/sdk-etdump.md rename to docs/source/dev-tools-etdump.md index 4eacb18b14..27297cc3de 100644 --- a/docs/source/sdk-etdump.md +++ b/docs/source/dev-tools-etdump.md @@ -1,6 +1,6 @@ # Prerequisite | ETDump - ExecuTorch Dump -ETDump (ExecuTorch Dump) is one of the core components of the ExecuTorch SDK experience. It is the mechanism through which all forms of profiling and debugging data is extracted from the runtime. Users can't parse ETDump directly; instead, they should pass it into the Inspector API, which deserializes the data, offering interfaces for flexible analysis and debugging. +ETDump (ExecuTorch Dump) is one of the core components of the ExecuTorch Developer Tools experience. It is the mechanism through which all forms of profiling and debugging data is extracted from the runtime. Users can't parse ETDump directly; instead, they should pass it into the Inspector API, which deserializes the data, offering interfaces for flexible analysis and debugging. ## Generating an ETDump @@ -9,7 +9,7 @@ Generating an ETDump is a relatively straightforward process. Users can follow t 1. ***Include*** the ETDump header in your code. ```C++ -#include +#include ``` 2. ***Create*** an Instance of the ETDumpGen class and pass it into the `load_method` call that is invoked in the runtime. @@ -34,11 +34,11 @@ if (result.buf != nullptr && result.size > 0) { } ``` -4. ***Compile*** your binary using CMake with the `ET_EVENT_TRACER_ENABLED` pre-processor flag to enable events to be traced and logged into ETDump inside the ExecuTorch runtime. This flag needs to be added to the ExecuTorch library and any operator library that you are compiling into your binary. For reference, you can take a look at `examples/sdk/CMakeLists.txt`. The lines of interest are: +4. ***Compile*** your binary using CMake with the `ET_EVENT_TRACER_ENABLED` pre-processor flag to enable events to be traced and logged into ETDump inside the ExecuTorch runtime. This flag needs to be added to the ExecuTorch library and any operator library that you are compiling into your binary. For reference, you can take a look at `examples/dev_tools/CMakeLists.txt`. The lines of interest are: ``` target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED) target_compile_options(portable_ops_lib INTERFACE -DET_EVENT_TRACER_ENABLED) ``` ## Using an ETDump -Pass this ETDump into the [Inspector API](./sdk-inspector.rst) to access this data and do post-run analysis. +Pass this ETDump into the [Inspector API](./dev-tools-inspector.rst) to access this data and do post-run analysis. diff --git a/docs/source/sdk-etrecord.rst b/docs/source/dev-tools-etrecord.rst similarity index 79% rename from docs/source/sdk-etrecord.rst rename to docs/source/dev-tools-etrecord.rst index 43ed5095c6..b1eba6ecb9 100644 --- a/docs/source/sdk-etrecord.rst +++ b/docs/source/dev-tools-etrecord.rst @@ -9,7 +9,7 @@ users ahead of time (when they export their model to run on ExecuTorch). To draw a rough equivalent to conventional software development, ``ETRecord`` can be considered as the binary built with debug symbols that is used for debugging in GNU Debugger (gdb). It is expected that -the user will supply this to the ExecuTorch SDK tooling in order for +the user will supply this to the ExecuTorch Developer Tools in order for them to debug and visualize their model. ``ETRecord`` contains numerous components such as: @@ -18,7 +18,7 @@ them to debug and visualize their model. * Delegate debug handle maps The ``ETRecord`` object itself is intended to be opaque to users and they should not access any components inside it directly. -It should be provided to the `Inspector API `__ to link back performance and debug data sourced from the runtime back to the Python source code. +It should be provided to the `Inspector API `__ to link back performance and debug data sourced from the runtime back to the Python source code. Generating an ``ETRecord`` -------------------------- @@ -31,10 +31,10 @@ they are interested in working with via our tooling. .. warning:: Users should do a deepcopy of the output of ``to_edge()`` and pass in the deepcopy to the ``generate_etrecord`` API. This is needed because the subsequent call, ``to_executorch()``, does an in-place mutation and will lose debug data in the process. -.. currentmodule:: executorch.sdk.etrecord._etrecord +.. currentmodule:: executorch.dev_tools.etrecord._etrecord .. autofunction:: generate_etrecord Using an ``ETRecord`` --------------------- -Pass the ``ETRecord`` as an optional argument into the `Inspector API `__ to access this data and do post-run analysis. +Pass the ``ETRecord`` as an optional argument into the `Inspector API `__ to access this data and do post-run analysis. diff --git a/docs/source/sdk-inspector.rst b/docs/source/dev-tools-inspector.rst similarity index 80% rename from docs/source/sdk-inspector.rst rename to docs/source/dev-tools-inspector.rst index e15c1f2a39..3c319a1fe8 100644 --- a/docs/source/sdk-inspector.rst +++ b/docs/source/dev-tools-inspector.rst @@ -5,8 +5,8 @@ Overview -------- The Inspector APIs provide a convenient interface for analyzing the -contents of `ETRecord `__ and -`ETDump `__, helping developers get insights about model +contents of `ETRecord `__ and +`ETDump `__, helping developers get insights about model architecture and performance statistics. It’s built on top of the `EventBlock Class <#eventblock-class>`__ data structure, which organizes a group of `Event <#event-class>`__\ s for easy access to details of profiling events. @@ -17,7 +17,7 @@ APIs: * By accessing the `public attributes <#inspector-attributes>`__ of the ``Inspector``, ``EventBlock``, and ``Event`` classes. * By using a `CLI <#cli>`__ tool for basic functionalities. -Please refer to the `e2e use case doc `__ get an understanding of how to use these in a real world example. +Please refer to the `e2e use case doc `__ get an understanding of how to use these in a real world example. Inspector Methods @@ -26,26 +26,26 @@ Inspector Methods Constructor ~~~~~~~~~~~ -.. autofunction:: executorch.sdk.Inspector.__init__ +.. autofunction:: executorch.dev_tools.Inspector.__init__ **Example Usage:** .. code:: python - from executorch.sdk import Inspector + from executorch.dev_tools import Inspector inspector = Inspector(etdump_path="/path/to/etdump.etdp", etrecord="/path/to/etrecord.bin") to_dataframe ~~~~~~~~~~~~~~~~ -.. autofunction:: executorch.sdk.Inspector.to_dataframe +.. autofunction:: executorch.dev_tools.Inspector.to_dataframe print_data_tabular ~~~~~~~~~~~~~~~~~~ -.. autofunction:: executorch.sdk.Inspector.print_data_tabular +.. autofunction:: executorch.dev_tools.Inspector.print_data_tabular .. _example-usage-1: @@ -62,7 +62,7 @@ Note that the unit of delegate profiling events is "cycles". We're working on pr find_total_for_module ~~~~~~~~~~~~~~~~~~~~~ -.. autofunction:: executorch.sdk.Inspector.find_total_for_module +.. autofunction:: executorch.dev_tools.Inspector.find_total_for_module .. _example-usage-2: @@ -80,7 +80,7 @@ find_total_for_module get_exported_program ~~~~~~~~~~~~~~~~~~~~ -.. autofunction:: executorch.sdk.Inspector.get_exported_program +.. autofunction:: executorch.dev_tools.Inspector.get_exported_program .. _example-usage-3: @@ -119,7 +119,7 @@ of an ``Inspector`` instance, for example: inspector.event_blocks -.. autoclass:: executorch.sdk.inspector.EventBlock +.. autoclass:: executorch.dev_tools.inspector.EventBlock ``Event`` Class ~~~~~~~~~~~~~~~ @@ -127,7 +127,7 @@ of an ``Inspector`` instance, for example: Access ``Event`` instances through the ``events`` attribute of an ``EventBlock`` instance. -.. autoclass:: executorch.sdk.inspector.Event +.. autoclass:: executorch.dev_tools.inspector.Event **Example Usage:** @@ -152,7 +152,7 @@ table. This command produces the identical table output as calling the .. code:: bash - python3 -m sdk.inspector.inspector_cli --etdump_path --etrecord_path + python3 -m dev_tools.inspector.inspector_cli --etdump_path --etrecord_path Note that the `etrecord_path` argument is optional. diff --git a/docs/source/sdk-overview.md b/docs/source/dev-tools-overview.md similarity index 52% rename from docs/source/sdk-overview.md rename to docs/source/dev-tools-overview.md index 53f7d88613..b42fef75be 100644 --- a/docs/source/sdk-overview.md +++ b/docs/source/dev-tools-overview.md @@ -1,12 +1,12 @@ -# Introduction to the ExecuTorch SDK +# Introduction to the ExecuTorch Developer Tools -ExecuTorch has been designed with [productivity](./intro-overview.md) as one of its core objectives and the ExecuTorch SDK enables this through the comprehensive suite of tools it provides users to help them profile, debug, and visualize models that they have onboarded onto ExecuTorch. +ExecuTorch has been designed with [productivity](./intro-overview.md) as one of its core objectives and the ExecuTorch Developer Tools enables this through the comprehensive suite of tools it provides users to help them profile, debug, and visualize models that they have onboarded onto ExecuTorch. -All the components of the SDK have been designed from the ground up with deep integration in both the export process and the runtime. This enables us to provide unique features such as linking back operator execution in the runtime to the line of code in the original eager model that this operator originated from. +All the components of the Developer Tools have been designed from the ground up with deep integration in both the export process and the runtime. This enables us to provide unique features such as linking back operator execution in the runtime to the line of code in the original eager model that this operator originated from. -## SDK Features +## Developer Tools Features -The ExecuTorch SDK supports the following features: +The ExecuTorch Developer Tools supports the following features: - **BundledProgram** is a utility tool for exporting the model bundled with a sample set of (representative) inputs and expected outputs, so that during runtime users can validate that the actual output is in fact the same as the expected output. - **Profiling** models with operator level breakdown of performance stats @@ -17,28 +17,28 @@ The ExecuTorch SDK supports the following features: - **Debugging** - Intermediate outputs and output quality analysis - **Visualization** - Coming soon -## Fundamental components of the SDK +## Fundamental components of the Developer Tools -In order to fully understand and leverage the power of the SDK in this section, the fundamental components that power the SDK will be detailed. +In order to fully understand and leverage the power of the Developer Tools in this section, the fundamental components that power the Developer Tools will be detailed. ### ETRecord -ETRecord (ExecuTorch Record) is an artifact generated during the export process that stores the graphs and other metadata that is critical for the SDK tooling to be able to link back the performance/debug data sourced from the runtime to the source code of the eager model. +ETRecord (ExecuTorch Record) is an artifact generated during the export process that stores the graphs and other metadata that is critical for the Developer Tools to be able to link back the performance/debug data sourced from the runtime to the source code of the eager model. To draw a rough equivalence to conventional software development ETRecord can be considered as the binary built with debug symbols that is used for debugging in GNU Project debugger (gdb). -More details are available in the [ETRecord documentation](sdk-etrecord.rst) on how to generate and store an ETRecord. +More details are available in the [ETRecord documentation](dev-tools-etrecord.rst) on how to generate and store an ETRecord. ### ETDump ETDump (ExecuTorch Dump) is the binary blob that is generated by the runtime after running a model. Similarly as above, to draw a rough equivalence to conventional software development, ETDump can be considered as the coredump of ExecuTorch, but in this case within ETDump we store all the performance and debug data that was generated by the runtime during model execution. ```{note} -If you only care about looking at the raw performance data without linking back to source code and other extensive features, an ETDump alone will be enough to leverage the basic features of the SDK. For the full experience, it is recommended that the users also generate an ETRecord. +If you only care about looking at the raw performance data without linking back to source code and other extensive features, an ETDump alone will be enough to leverage the basic features of the Developer Tools. For the full experience, it is recommended that the users also generate an ETRecord. ``` -More details are available in the [ETDump documentation](sdk-etdump.md) on how to generate and store an ETDump from the runtime. +More details are available in the [ETDump documentation](dev-tools-etdump.md) on how to generate and store an ETDump from the runtime. ### Inspector APIs -The Inspector Python APIs are the main user enrty point into the SDK. They join the data sourced from ETDump and ETRecord to give users access to all the performance and debug data sourced from the runtime along with linkage back to eager model source code and module hierarchy in an easy to use API. +The Inspector Python APIs are the main user enrty point into the Developer Tools. They join the data sourced from ETDump and ETRecord to give users access to all the performance and debug data sourced from the runtime along with linkage back to eager model source code and module hierarchy in an easy to use API. -More details are available in the [Inspector API documentation](sdk-inspector.rst) on how to use the Inspector APIs. +More details are available in the [Inspector API documentation](dev-tools-inspector.rst) on how to use the Inspector APIs. diff --git a/docs/source/sdk-profiling.md b/docs/source/dev-tools-profiling.md similarity index 50% rename from docs/source/sdk-profiling.md rename to docs/source/dev-tools-profiling.md index 83276d8d18..0ef0e33735 100644 --- a/docs/source/sdk-profiling.md +++ b/docs/source/dev-tools-profiling.md @@ -4,20 +4,20 @@ Profiling in ExecuTorch gives users access to these runtime metrics: - Model Load Time. - Operator Level Execution Time. - Delegate Execution Time. - - If the delegate that the user is calling into has been integrated with the [SDK](./sdk-delegate-integration.md), then users will also be able to access delegated operator execution time. + - If the delegate that the user is calling into has been integrated with the [Developer Tools](./dev-tools-delegate-integration.md), then users will also be able to access delegated operator execution time. - End-to-end Inference Execution Time. One uniqe aspect of ExecuTorch Profiling is the ability to link every runtime executed operator back to the exact line of python code from which this operator originated. This capability enables users to easily identify hotspots in their model, source them back to the exact line of Python code, and optimize if chosen to. -We provide access to all the profiling data via the Python [Inspector API](./sdk-inspector.rst). The data mentioned above can be accessed through these interfaces, allowing users to perform any post-run analysis of their choice. +We provide access to all the profiling data via the Python [Inspector API](./dev-tools-inspector.rst). The data mentioned above can be accessed through these interfaces, allowing users to perform any post-run analysis of their choice. ## Steps to Profile a Model in ExecuTorch -1. [Optional] Generate an [ETRecord](./sdk-etrecord.rst) while you're exporting your model. If provided this will enable users to link back profiling details to eager model source code (with stack traces and module hierarchy). -2. Build the runtime with the pre-processor flags that enable profiling. Detailed in the [ETDump documentation](./sdk-etdump.md). -3. Run your Program on the ExecuTorch runtime and generate an [ETDump](./sdk-etdump.md). -4. Create an instance of the [Inspector API](./sdk-inspector.rst) by passing in the ETDump you have sourced from the runtime along with the optionally generated ETRecord from step 1. +1. [Optional] Generate an [ETRecord](./dev-tools-etrecord.rst) while you're exporting your model. If provided this will enable users to link back profiling details to eager model source code (with stack traces and module hierarchy). +2. Build the runtime with the pre-processor flags that enable profiling. Detailed in the [ETDump documentation](./dev-tools-etdump.md). +3. Run your Program on the ExecuTorch runtime and generate an [ETDump](./dev-tools-etdump.md). +4. Create an instance of the [Inspector API](./dev-tools-inspector.rst) by passing in the ETDump you have sourced from the runtime along with the optionally generated ETRecord from step 1. - Through the Inspector API, users can do a wide range of analysis varying from printing out performance details to doing more finer granular calculation on module level. -Please refer to the [SDK tutorial](./tutorials/sdk-integration-tutorial.rst) for a step-by-step walkthrough of the above process on a sample model. +Please refer to the [Developer Tools](./tutorials/dev-tools-integration-tutorial.rst) for a step-by-step walkthrough of the above process on a sample model. diff --git a/docs/source/dev-tools-tutorial.md b/docs/source/dev-tools-tutorial.md new file mode 100644 index 0000000000..5d51d3e269 --- /dev/null +++ b/docs/source/dev-tools-tutorial.md @@ -0,0 +1,3 @@ +## Developer Tools usage tutorial + +Please refer to the [Developer Tools tutorial](./tutorials/dev-tools-integration-tutorial) for a walkthrough on how to profile a model in ExecuTorch using the Developer Tools. diff --git a/docs/source/extension-module.md b/docs/source/extension-module.md index 9e236e8e48..6c9e66089f 100644 --- a/docs/source/extension-module.md +++ b/docs/source/extension-module.md @@ -126,13 +126,13 @@ Most of the ExecuTorch APIs, including those described above, return either `Res ### Profile the Module -Use [ExecuTorch Dump](sdk-etdump.md) to trace model execution. Create an instance of the `ETDumpGen` class and pass it to the `Module` constructor. After executing a method, save the `ETDump` to a file for further analysis. You can capture multiple executions in a single trace if desired. +Use [ExecuTorch Dump](dev-tools-etdump.md) to trace model execution. Create an instance of the `ETDumpGen` class and pass it to the `Module` constructor. After executing a method, save the `ETDump` to a file for further analysis. You can capture multiple executions in a single trace if desired. ```cpp #include #include #include -#include +#include using namespace ::torch::executor; diff --git a/docs/source/getting-started-architecture.md b/docs/source/getting-started-architecture.md index 2c3f85aff1..f853a5987f 100644 --- a/docs/source/getting-started-architecture.md +++ b/docs/source/getting-started-architecture.md @@ -87,8 +87,8 @@ The ExecuTorch runtime is written in C++ with minimal dependencies for portabili _Executor_ is the entry point to load the program and execute it. The execution triggers corresponding operator kernels or backend execution from this very minimal runtime. -## SDK +## Developer Tools -It should be efficient for users to go from research to production using the flow above. Productivity is essentially important, for users to author, optimize and deploy their models. We provide [ExecuTorch SDK](./sdk-overview.md) to improve productivity. The SDK is not in the diagram. Instead it's a tool set that covers the developer workflow in all three phases. +It should be efficient for users to go from research to production using the flow above. Productivity is essentially important, for users to author, optimize and deploy their models. We provide [ExecuTorch Developer Tools](./dev-tools-overview.md) to improve productivity. The Developer Tools is not in the diagram. Instead it's a tool set that covers the developer workflow in all three phases. -During the program preparation and execution, users can use the ExecuTorch SDK to profile, debug, or visualize the program. Since the end-to-end flow is within the PyTorch ecosystem, users can correlate and display performance data along with graph visualization as well as direct references to the program source code and model hierarchy. We consider this to be a critical component for quickly iterating and lowering PyTorch programs to edge devices and environments. +During the program preparation and execution, users can use the ExecuTorch Developer Tools to profile, debug, or visualize the program. Since the end-to-end flow is within the PyTorch ecosystem, users can correlate and display performance data along with graph visualization as well as direct references to the program source code and model hierarchy. We consider this to be a critical component for quickly iterating and lowering PyTorch programs to edge devices and environments. diff --git a/docs/source/index.rst b/docs/source/index.rst index 57dc2c4bcc..8977958314 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -94,7 +94,7 @@ Topics in this section will help you get started with ExecuTorch. tutorials/export-to-executorch-tutorial running-a-model-cpp-tutorial extension-module - tutorials/sdk-integration-tutorial + tutorials/dev-tools-integration-tutorial apple-runtime demo-apps-ios demo-apps-android @@ -192,18 +192,18 @@ Topics in this section will help you get started with ExecuTorch. .. toctree:: :glob: :maxdepth: 1 - :caption: SDK + :caption: Developer Tools :hidden: - sdk-overview - sdk-bundled-io - sdk-etrecord - sdk-etdump - sdk-profiling - sdk-debugging - sdk-inspector - sdk-delegate-integration - sdk-tutorial + dev-tools-overview + dev-tools-bundled-io + dev-tools-etrecord + dev-tools-etdump + dev-tools-profiling + dev-tools-debugging + dev-tools-inspector + dev-tools-delegate-integration + dev-tools-tutorial .. toctree:: :glob: @@ -243,11 +243,11 @@ ExecuTorch tutorials. :tags: .. customcarditem:: - :header: Using the ExecuTorch SDK to Profile a Model - :card_description: A tutorial for using the ExecuTorch SDK to profile and analyze a model with linkage back to source code. + :header: Using the ExecuTorch Developer Tools to Profile a Model + :card_description: A tutorial for using the ExecuTorch Developer Tools to profile and analyze a model with linkage back to source code. :image: _static/img/generic-pytorch-logo.png - :link: tutorials/sdk-integration-tutorial.html - :tags: SDK + :link: tutorials/dev-tools-integration-tutorial.html + :tags: Developer Tools .. customcarditem:: :header: Integrating and Running ExecuTorch on Apple Platforms diff --git a/docs/source/intro-how-it-works.md b/docs/source/intro-how-it-works.md index 9b8ee87f78..eeda02fd25 100644 --- a/docs/source/intro-how-it-works.md +++ b/docs/source/intro-how-it-works.md @@ -18,7 +18,7 @@ ExecuTorch provides the following benefits to engineers who need to deploy machi * **Export that is robust and powerful.** Export uses [`torch.export()`](https://pytorch.org/docs/main/export.html), which uses the same technology used in PyTorch 2.x to capture PyTorch programs for fast execution. While eager mode is flexible and allows experimentation in Python, it may not work well if Python isn't available or cannot deliver efficient execution. The _Export Intermediate Representation (Export IR)_ that export flow generates can describe a wide range of dynamism in PyTorch models, including control flow and dynamic shapes, which makes it a powerful tool for fully capturing existing PyTorch models with little effort. * **Operator standardization.** During the graph export process, the nodes in the graph represent operators such as addition, multiplication, or convolution. These operators are part of a small standardized list called the [Core ATen Op set](https://pytorch.org/docs/main/torch.compiler_ir.html#core-aten-ir). Most PyTorch programs can be decomposed into a graph using this small set of operators during export. Small list of standardized operators reduces the surface, needed to be covered, by third-party operator libraries as well as accelerator backends, in order to run models exported for ExecuTorch. ExecuTorch runtime ships with one such library, called portable operator library, that implements core ATen opset. * **Standardization for compiler interfaces (aka delegates) and the OSS ecosystem.** In addition to the _Operator standardization_ above, ExecuTorch has a standardized interface for delegation to compilers. This allows third-party vendors and compilers to implement interfaces and API entry points for compilation and execution of (either partial or full) graphs targeting their specialized hardware. This provides greater flexibility in terms of hardware support and performance optimization, as well as easier integration with the PyTorch open source ecosystem for on-device AI. -* **First-party SDK and toolchain.** Due to the above standardization efforts, it was possible to build a unified first-party SDK for ExecuTorch, where developers can export, compile, and deploy to a wide range of target devices--such as iOS, Android, and microcontrollers--using the same SDK, streamlining the process and gaining productivity. Additionally, the SDK provides profiling and debugging functionality to easily inspect intermediate states, which are core parts of most developer workflows. +* **First-party Developer Tools.** Due to the above standardization efforts, it was possible to build a unified first-party Developer Tools for ExecuTorch, where developers can export, compile, and deploy to a wide range of target devices--such as iOS, Android, and microcontrollers--using the same Developer Tools, streamlining the process and gaining productivity. Additionally, the Developer Tools provides profiling and debugging functionality to easily inspect intermediate states, which are core parts of most developer workflows. * **No intermediate conversions necessary.** ExecuTorch's main design principle is to allow developers to run their models on target devices without the need for converting to third-party intermediate representations. This eliminates a number of problems that on-device developers typically face when working with these conversion steps, such as lack of debuggability and profiling, the need to familiarize themselves with hardware-specific tools, and models not being able to run due to conversion steps failing. * **Ease of customization.** Developers can optimize their deployment for even better performance gains on the target architecture by applying custom techniques, such as linking with high-performance operator implementations or customizing memory planning based on storage and latency trade-offs. This level of customization is made possible through the standardization of the compiler pass interface and registration APIs on exported graphs. * **Low overhead runtime and execution.** The ExecuTorch runtime, written in C++, is highly efficient and can run on a wide range of architectures, including Linux, iOS, Android, embedded systems, and bare metal hardware, with little additional setup or configuration. It is capable of linking in only those operators needed for the model, resulting in a minimal runtime binary size. It is also able to run at low latency because of ahead-of-time compilation and memory planning stages, with the runtime responsible only for execution (e.g., call operator `conv` and save the result in memory location X). diff --git a/docs/source/llm/getting-started.md b/docs/source/llm/getting-started.md index 5fffb7e8ca..cc0ac51e91 100644 --- a/docs/source/llm/getting-started.md +++ b/docs/source/llm/getting-started.md @@ -750,20 +750,20 @@ In the fragment of the output for nanoGPT below, observe that embedding and add ### Performance Analysis -Through the ExecuTorch SDK, users are able to profile model execution, giving timing information for each operator in the model. +Through the ExecuTorch Developer Tools, users are able to profile model execution, giving timing information for each operator in the model. #### Prerequisites ##### ETRecord generation (Optional) -An ETRecord is an artifact generated at the time of export that contains model graphs and source-level metadata linking the ExecuTorch program to the original PyTorch model. You can view all profiling events without an ETRecord, though with an ETRecord, you will also be able to link each event to the types of operators being executed, module hierarchy, and stack traces of the original PyTorch source code. For more information, see [the ETRecord docs](../sdk-etrecord.md). +An ETRecord is an artifact generated at the time of export that contains model graphs and source-level metadata linking the ExecuTorch program to the original PyTorch model. You can view all profiling events without an ETRecord, though with an ETRecord, you will also be able to link each event to the types of operators being executed, module hierarchy, and stack traces of the original PyTorch source code. For more information, see [the ETRecord docs](../dev-tools-etrecord.md). In your export script, after calling `to_edge()` and `to_executorch()`, call `generate_etrecord()` with the `EdgeProgramManager` from `to_edge()` and the `ExecuTorchProgramManager` from `to_executorch()`. Make sure to copy the `EdgeProgramManager`, as the call to `to_backend()` mutates the graph in-place. ``` import copy -from executorch.sdk import generate_etrecord +from executorch.dev_tools import generate_etrecord # Make the deep copy immediately after to to_edge() edge_manager_copy = copy.deepcopy(edge_manager) @@ -778,13 +778,13 @@ Run the export script and the ETRecord will be generated as `etrecord.bin`. ##### ETDump generation -An ETDump is an artifact generated at runtime containing a trace of the model execution. For more information, see [the ETDump docs](../sdk-etdump.md). +An ETDump is an artifact generated at runtime containing a trace of the model execution. For more information, see [the ETDump docs](../dev-tools-etdump.md). Include the ETDump header in your code. ```cpp // main.cpp -#include +#include ``` Create an Instance of the ETDumpGen class and pass it to the Module constructor. @@ -809,10 +809,10 @@ if (result.buf != nullptr && result.size > 0) { } ``` -Additionally, update CMakeLists.txt to build with SDK and enable events to be traced and logged into ETDump: +Additionally, update CMakeLists.txt to build with Developer Tools and enable events to be traced and logged into ETDump: ``` -option(EXECUTORCH_BUILD_SDK "" ON) +option(EXECUTORCH_BUILD_DEV_TOOLS "" ON) # ... @@ -835,7 +835,7 @@ Run the runner, you will see “etdump.etdp” generated. Once you’ve collected debug artifacts ETDump (and optionally an ETRecord), you can use the Inspector API to view performance information. ```python -from executorch.sdk import Inspector +from executorch.dev_tools import Inspector inspector = Inspector(etdump_path="etdump.etdp") # If you also generated an ETRecord, then pass that in as well: `inspector = Inspector(etdump_path="etdump.etdp", etrecord="etrecord.bin")` @@ -847,7 +847,7 @@ This prints the performance data in a tabular format in “inspector_out.txt”, ![](../_static/img/llm_manual_print_data_tabular.png) View in full size -To learn more about the Inspector and the rich functionality it provides, see the [Inspector API Reference](../sdk-inspector.md). +To learn more about the Inspector and the rich functionality it provides, see the [Inspector API Reference](../dev-tools-inspector.md). ## Custom Kernels With the ExecuTorch custom operator APIs, custom operator and kernel authors can easily bring in their kernel into PyTorch/ExecuTorch. diff --git a/docs/source/native-delegates-executorch-xnnpack-delegate.md b/docs/source/native-delegates-executorch-xnnpack-delegate.md index 1d12daef9d..6b335ca3a0 100644 --- a/docs/source/native-delegates-executorch-xnnpack-delegate.md +++ b/docs/source/native-delegates-executorch-xnnpack-delegate.md @@ -74,7 +74,7 @@ Since weight packing creates an extra copy of the weights inside XNNPACK, We fre When executing the XNNPACK subgraphs, we prepare the tensor inputs and outputs and feed them to the XNNPACK runtime graph. After executing the runtime graph, the output pointers are filled with the computed tensors. #### **Profiling** -We have enabled basic profiling for XNNPACK delegate that can be enabled with the following compiler flag `-DENABLE_XNNPACK_PROFILING`. With ExecuTorch's SDK integration, you can also now use the SDK tools to profile the model. You can follow the steps in [Using the ExecuTorch SDK to Profile a Model](./tutorials/sdk-integration-tutorial) on how to profile ExecuTorch models and use SDK's Inspector API to view XNNPACK's internal profiling information. +We have enabled basic profiling for XNNPACK delegate that can be enabled with the following compiler flag `-DENABLE_XNNPACK_PROFILING`. With ExecuTorch's Developer Tools integration, you can also now use it to profile the model. You can follow the steps in [Using the ExecuTorch Developer Tools to Profile a Model](./tutorials/dev-tools-integration-tutorial) on how to profile ExecuTorch models and use Developer Tools' Inspector API to view XNNPACK's internal profiling information. [comment]: <> (TODO: Refactor quantizer to a more official quantization doc) diff --git a/docs/source/runtime-overview.md b/docs/source/runtime-overview.md index 7bc8b4dd8b..65a09a946d 100644 --- a/docs/source/runtime-overview.md +++ b/docs/source/runtime-overview.md @@ -33,7 +33,7 @@ The runtime is also responsible for: semantics of those operators. * Dispatching predetermined sections of the model to [backend delegates](compiler-delegate-and-partitioner.md) for acceleration. -* Optionally gathering [profiling data](sdk-profiling.md) during load and +* Optionally gathering [profiling data](dev-tools-profiling.md) during load and execution. ## Design Goals @@ -159,7 +159,7 @@ For more details about the ExecuTorch runtime, please see: * [Simplified Runtime APIs Tutorial](extension-module.md) * [Runtime Build and Cross Compilation](runtime-build-and-cross-compilation.md) * [Runtime Platform Abstraction Layer](runtime-platform-abstraction-layer.md) -* [Runtime Profiling](sdk-profiling.md) +* [Runtime Profiling](dev-tools-profiling.md) * [Backends and Delegates](compiler-delegate-and-partitioner.md) * [Backend Delegate Implementation](runtime-backend-delegate-implementation-and-linking.md) * [Kernel Library Overview](kernel-library-overview.md) diff --git a/docs/source/sdk-tutorial.md b/docs/source/sdk-tutorial.md deleted file mode 100644 index 90c9ed6d34..0000000000 --- a/docs/source/sdk-tutorial.md +++ /dev/null @@ -1,3 +0,0 @@ -## SDK usage tutorial - -Please refer to the [SDK tutorial](./tutorials/sdk-integration-tutorial) for a walkthrough on how to profile a model in ExecuTorch using the SDK. diff --git a/docs/source/tutorials_source/sdk-integration-tutorial.py b/docs/source/tutorials_source/dev-tools-integration-tutorial.py similarity index 86% rename from docs/source/tutorials_source/sdk-integration-tutorial.py rename to docs/source/tutorials_source/dev-tools-integration-tutorial.py index ccc2e480ad..18336f576a 100644 --- a/docs/source/tutorials_source/sdk-integration-tutorial.py +++ b/docs/source/tutorials_source/dev-tools-integration-tutorial.py @@ -6,21 +6,21 @@ # LICENSE file in the root directory of this source tree. """ -Using the ExecuTorch SDK to Profile a Model +Using the ExecuTorch Developer Tools to Profile a Model ======================== **Author:** `Jack Khuu `__ """ ###################################################################### -# The `ExecuTorch SDK <../sdk-overview.html>`__ is a set of tools designed to +# The `ExecuTorch Developer Tools <../dev-tools-overview.html>`__ is a set of tools designed to # provide users with the ability to profile, debug, and visualize ExecuTorch # models. # -# This tutorial will show a full end-to-end flow of how to utilize the SDK. +# This tutorial will show a full end-to-end flow of how to utilize the Developer Tools. # Specifically, it will: # -# 1. Generate the artifacts consumed by the SDK (`ETRecord <../sdk-etrecord.html>`__, `ETDump <../sdk-etdump.html>`__). +# 1. Generate the artifacts consumed by the Developer Tools (`ETRecord <../dev-tools-etrecord.html>`__, `ETDump <../dev-tools-etdump.html>`__). # 2. Create an Inspector class consuming these artifacts. # 3. Utilize the Inspector class to analyze the model. @@ -38,9 +38,9 @@ # # The first step is to generate an ``ETRecord``. ``ETRecord`` contains model # graphs and metadata for linking runtime results (such as profiling) to -# the eager model. This is generated via ``executorch.sdk.generate_etrecord``. +# the eager model. This is generated via ``executorch.dev_tools.generate_etrecord``. # -# ``executorch.sdk.generate_etrecord`` takes in an output file path (str), the +# ``executorch.dev_tools.generate_etrecord`` takes in an output file path (str), the # edge dialect model (``EdgeProgramManager``), the ExecuTorch dialect model # (``ExecutorchProgramManager``), and an optional dictionary of additional models. # @@ -51,6 +51,7 @@ import torch import torch.nn as nn import torch.nn.functional as F +from executorch.dev_tools import generate_etrecord from executorch.exir import ( EdgeCompileConfig, @@ -58,7 +59,6 @@ ExecutorchProgramManager, to_edge, ) -from executorch.sdk import generate_etrecord from torch.export import export, ExportedProgram @@ -124,19 +124,19 @@ def forward(self, x): # --------------- # # Next step is to generate an ``ETDump``. ``ETDump`` contains runtime results -# from executing a `Bundled Program Model <../sdk-bundled-io.html>`__. +# from executing a `Bundled Program Model <../dev-tools-bundled-io.html>`__. # # In this tutorial, a `Bundled Program` is created from the example model above. import torch +from executorch.dev_tools import BundledProgram -from executorch.exir import to_edge -from executorch.sdk import BundledProgram - -from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite -from executorch.sdk.bundled_program.serialize import ( +from executorch.dev_tools.bundled_program.config import MethodTestCase, MethodTestSuite +from executorch.dev_tools.bundled_program.serialize import ( serialize_from_bundled_program_to_flatbuffer, ) + +from executorch.exir import to_edge from torch.export import export # Step 1: ExecuTorch Program Export @@ -172,8 +172,8 @@ def forward(self, x): # Use CMake (follow `these instructions <../runtime-build-and-cross-compilation.html#configure-the-cmake-build>`__ to set up cmake) to execute the Bundled Program to generate the ``ETDump``:: # # cd executorch -# ./examples/sdk/build_sdk_example_runner.sh -# cmake-out/examples/sdk/sdk_example_runner --bundled_program_path="bundled_program.bp" +# ./examples/dev_tools/build_dev_tools_example_runner.sh +# cmake-out/examples/dev_tools/dev_tools_example_runner --bundled_program_path="bundled_program.bp" ###################################################################### # Creating an Inspector @@ -188,7 +188,7 @@ def forward(self, x): # # To visualize all runtime events, call Inspector's ``print_data_tabular``. -from executorch.sdk import Inspector +from executorch.dev_tools import Inspector # sphinx_gallery_start_ignore inspector_patch = patch.object(Inspector, "__init__", return_value=None) @@ -212,7 +212,7 @@ def forward(self, x): # Analyzing with an Inspector # --------------------------- # -# ``Inspector`` provides 2 ways of accessing ingested information: `EventBlocks <../sdk-inspector#eventblock-class>`__ +# ``Inspector`` provides 2 ways of accessing ingested information: `EventBlocks <../dev-tools-inspector#eventblock-class>`__ # and ``DataFrames``. These mediums give users the ability to perform custom # analysis about their model performance. # @@ -281,20 +281,20 @@ def forward(self, x): ###################################################################### # Note: ``find_total_for_module`` is a special first class method of -# `Inspector <../sdk-inspector.html>`__ +# `Inspector <../dev-tools-inspector.html>`__ ###################################################################### # Conclusion # ---------- # # In this tutorial, we learned about the steps required to consume an ExecuTorch -# model with the ExecuTorch SDK. It also showed how to use the Inspector APIs +# model with the ExecuTorch Developer Tools. It also showed how to use the Inspector APIs # to analyze the model run results. # # Links Mentioned # ^^^^^^^^^^^^^^^ # -# - `ExecuTorch SDK <../sdk-overview.html>`__ -# - `ETRecord <../sdk-etrecord.html>`__ -# - `ETDump <../sdk-etdump.html>`__ -# - `Inspector <../sdk-inspector.html>`__ +# - `ExecuTorch Developer Tools <../dev-tools-overview.html>`__ +# - `ETRecord <../dev-tools-etrecord.html>`__ +# - `ETDump <../dev-tools-etdump.html>`__ +# - `Inspector <../dev-tools-inspector.html>`__ diff --git a/docs/website/docs/tutorials/bundled_program.md b/docs/website/docs/tutorials/bundled_program.md index 9dd2a8a95a..efee80569a 100644 --- a/docs/website/docs/tutorials/bundled_program.md +++ b/docs/website/docs/tutorials/bundled_program.md @@ -1,4 +1,4 @@ -DEPRECATED: This document is moving to //executorch/docs/source/sdk-bundled-io.md +DEPRECATED: This document is moving to //executorch/docs/source/dev-tools-bundled-io.md # Bundled Program @@ -122,7 +122,7 @@ __ET_NODISCARD Error VerifyResultWithBundledExpectedOutput( ### Example -Here we provide an example about how to run the bundled program step by step. Most of the code are borrowed from "fbcode/executorch/sdk/fb/runners/executor_runner.cpp" and please review that file if you need more info and context: +Here we provide an example about how to run the bundled program step by step. Most of the code are borrowed from "fbcode/executorch/dev_tools/fb/runners/executor_runner.cpp" and please review that file if you need more info and context: ```c++ // method_name is the name for the method we want to test diff --git a/examples/README.md b/examples/README.md index 0b0ff0daf3..23e01abd97 100644 --- a/examples/README.md +++ b/examples/README.md @@ -13,7 +13,7 @@ examples ├── models # Contains a set of popular and representative PyTorch models ├── portable # Contains end-to-end demos for ExecuTorch in portable mode ├── selective_build # Contains demos of selective build for optimizing the binary size of the ExecuTorch runtime -├── sdk # Contains demos of BundledProgram and ETDump +├── dev_tools # Contains demos of BundledProgram and ETDump ├── demo-apps # Contains demo apps for Android and iOS ├── xnnpack # Contains end-to-end ExecuTorch demos with first-party optimization using XNNPACK ├── apple @@ -39,9 +39,9 @@ A user's journey may commence by exploring the demos located in the [`portable/` To understand how to deploy the ExecuTorch runtime with optimization for binary size, explore the demos available in the [`selective_build/`](./selective_build) directory. These demos are specifically designed to illustrate the [Selective Build](../docs/source/kernel-library-selective_build.md), offering insights into reducing the binary size while maintaining efficiency. -## Demo of ExecuTorch SDK +## Demo of ExecuTorch Developer Tools -You will find demos of [ExecuTorch SDK](./sdk/) in the [`sdk/`](./sdk/) directory. The examples focuses on exporting and executing BundledProgram for ExecuTorch model verification and ETDump for collecting profiling and debug data. +You will find demos of [ExecuTorch Developer Tools](./dev_tools/) in the [`dev_tools/`](./dev_tools/) directory. The examples focuses on exporting and executing BundledProgram for ExecuTorch model verification and ETDump for collecting profiling and debug data. ## Demo Apps diff --git a/examples/apple/coreml/executor_runner/main.mm b/examples/apple/coreml/executor_runner/main.mm index 346c59637a..e571df6154 100644 --- a/examples/apple/coreml/executor_runner/main.mm +++ b/examples/apple/coreml/executor_runner/main.mm @@ -13,7 +13,7 @@ #import #import #import -#import +#import #import #import #import diff --git a/examples/apple/coreml/scripts/build_executor_runner.sh b/examples/apple/coreml/scripts/build_executor_runner.sh index 86ff5f6edb..365a56a540 100755 --- a/examples/apple/coreml/scripts/build_executor_runner.sh +++ b/examples/apple/coreml/scripts/build_executor_runner.sh @@ -35,7 +35,7 @@ cmake "$EXECUTORCH_ROOT_PATH" -B"$CMAKE_BUILD_DIR_PATH" \ -DFLATC_EXECUTABLE="$(which flatc)" \ -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \ -DEXECUTORCH_BUILD_XNNPACK=OFF \ --DEXECUTORCH_BUILD_SDK=ON \ +-DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_BUILD_COREML=ON \ -DCOREML_BUILD_EXECUTOR_RUNNER=ON \ -Dprotobuf_BUILD_TESTS=OFF \ @@ -55,7 +55,7 @@ mkdir -p "$EXECUTORCH_INCLUDE_DIR_PATH" find extension \( -name "*.h" -o -name "*.hpp" \) -exec rsync -R '{}' "$EXECUTORCH_INCLUDE_DIR_PATH" \; find runtime \( -name "*.h" -o -name "*.hpp" \) -exec rsync -R '{}' "$EXECUTORCH_INCLUDE_DIR_PATH" \; find util \( -name "*.h" -o -name "*.hpp" \) -exec rsync -R '{}' "$EXECUTORCH_INCLUDE_DIR_PATH" \; -find sdk \( -name "*.h" -o -name "*.hpp" \) -exec rsync -R '{}' "$EXECUTORCH_INCLUDE_DIR_PATH" \; +find dev_tools \( -name "*.h" -o -name "*.hpp" \) -exec rsync -R '{}' "$EXECUTORCH_INCLUDE_DIR_PATH" \; cp -rf "$COREML_DIR_PATH/runtime/include/" "$INCLUDE_DIR_PATH" # Copy required libraries diff --git a/examples/apple/coreml/scripts/export.py b/examples/apple/coreml/scripts/export.py index 4bf26a7f3e..47978a6660 100644 --- a/examples/apple/coreml/scripts/export.py +++ b/examples/apple/coreml/scripts/export.py @@ -20,7 +20,7 @@ from executorch.exir import to_edge from executorch.exir.backend.backend_api import to_backend -from executorch.sdk.etrecord import generate_etrecord +from executorch.dev_tools.etrecord import generate_etrecord from torch.export import export REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent.parent.parent.parent diff --git a/examples/apple/coreml/scripts/inspector_cli.py b/examples/apple/coreml/scripts/inspector_cli.py index 077c8c26ef..42dd3f88f8 100644 --- a/examples/apple/coreml/scripts/inspector_cli.py +++ b/examples/apple/coreml/scripts/inspector_cli.py @@ -9,8 +9,8 @@ from typing import Any, Dict, Final, List, Tuple, Union -from executorch.sdk import Inspector -from executorch.sdk.inspector._inspector_utils import compare_results +from executorch.dev_tools import Inspector +from executorch.dev_tools.inspector._inspector_utils import compare_results COREML_METADATA_KEYS: Final[List[Tuple[str, str]]] = [ ("operatorName", "coreml_operator"), diff --git a/examples/apple/mps/CMakeLists.txt b/examples/apple/mps/CMakeLists.txt index 9ae528668c..18d2301d97 100644 --- a/examples/apple/mps/CMakeLists.txt +++ b/examples/apple/mps/CMakeLists.txt @@ -92,8 +92,8 @@ if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$") include(${EXECUTORCH_SRCS_FILE}) target_include_directories( bundled_program - INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../../sdk/include - ${CMAKE_CURRENT_BINARY_DIR}/../../../sdk/bundled_program + INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../../dev_tools/include + ${CMAKE_CURRENT_BINARY_DIR}/../../../dev_tools/bundled_program ${EXECUTORCH_ROOT}/third-party/flatbuffers/include ${EXECUTORCH_ROOT}/third-party/flatcc/include ${_mps_schema_headers} diff --git a/examples/apple/mps/README.md b/examples/apple/mps/README.md index bebd1329be..d94da3066e 100644 --- a/examples/apple/mps/README.md +++ b/examples/apple/mps/README.md @@ -30,7 +30,7 @@ Once we have the model binary file, then let's run it with the ExecuTorch runtim # Build and install executorch cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ -DCMAKE_BUILD_TYPE=Release \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \ -DEXECUTORCH_BUILD_MPS=ON \ -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \ diff --git a/examples/apple/mps/executor_runner/mps_executor_runner.mm b/examples/apple/mps/executor_runner/mps_executor_runner.mm index 604419a620..135824d056 100644 --- a/examples/apple/mps/executor_runner/mps_executor_runner.mm +++ b/examples/apple/mps/executor_runner/mps_executor_runner.mm @@ -30,8 +30,8 @@ #include #include #include -#include -#include +#include +#include #include using namespace std::chrono; diff --git a/examples/apple/mps/executor_runner/targets.bzl b/examples/apple/mps/executor_runner/targets.bzl index fd0a7a5046..9c05f0f795 100644 --- a/examples/apple/mps/executor_runner/targets.bzl +++ b/examples/apple/mps/executor_runner/targets.bzl @@ -28,9 +28,9 @@ def define_common_targets(): "//executorch/extension/data_loader:file_data_loader", "//executorch/kernels/portable:generated_lib", "//executorch/extension/data_loader:file_data_loader", - "//executorch/sdk/etdump:etdump_flatcc", + "//executorch/dev_tools/etdump:etdump_flatcc", "//executorch/extension/data_loader:buffer_data_loader", - "//executorch/sdk/bundled_program:runtime", + "//executorch/dev_tools/bundled_program:runtime", ], external_deps = [ "gflags", diff --git a/examples/apple/mps/scripts/build_mps_executor_runner.sh b/examples/apple/mps/scripts/build_mps_executor_runner.sh index 16754588b6..c27e5aac80 100755 --- a/examples/apple/mps/scripts/build_mps_executor_runner.sh +++ b/examples/apple/mps/scripts/build_mps_executor_runner.sh @@ -41,7 +41,7 @@ rm -rf "$OUTPUT" cmake -DBUCK2="$BUCK" \ -DCMAKE_INSTALL_PREFIX=cmake-out \ -DCMAKE_BUILD_TYPE="$MODE" \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \ -DEXECUTORCH_BUILD_MPS=ON \ -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \ diff --git a/examples/apple/mps/scripts/mps_example.py b/examples/apple/mps/scripts/mps_example.py index 293c6f1404..81f4a1e234 100644 --- a/examples/apple/mps/scripts/mps_example.py +++ b/examples/apple/mps/scripts/mps_example.py @@ -24,9 +24,9 @@ from executorch.exir.backend.backend_details import CompileSpec from executorch.exir.capture._config import ExecutorchBackendConfig from executorch.extension.export_util.utils import export_to_edge, save_pte_program -from executorch.sdk import BundledProgram, generate_etrecord -from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite -from executorch.sdk.bundled_program.serialize import ( +from executorch.dev_tools import BundledProgram, generate_etrecord +from executorch.dev_tools.bundled_program.config import MethodTestCase, MethodTestSuite +from executorch.dev_tools.bundled_program.serialize import ( serialize_from_bundled_program_to_flatbuffer, ) diff --git a/examples/apple/mps/test_mps.sh b/examples/apple/mps/test_mps.sh index 55712089e0..44e87c5d09 100755 --- a/examples/apple/mps/test_mps.sh +++ b/examples/apple/mps/test_mps.sh @@ -11,14 +11,14 @@ set -e # shellcheck source=/dev/null source "$(dirname "${BASH_SOURCE[0]}")/../../../.ci/scripts/utils.sh" -cmake_install_executorch_sdk_lib() { +cmake_install_executorch.dev_tools_lib() { echo "Installing libexecutorch.a, libportable_kernels.a, libetdump.a, libbundled_program.a" rm -rf cmake-out retry cmake -DBUCK2="$BUCK" \ -DCMAKE_INSTALL_PREFIX=cmake-out \ -DCMAKE_BUILD_TYPE=Release \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_BUILD_MPS=ON \ -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \ -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \ @@ -60,5 +60,5 @@ then fi -cmake_install_executorch_sdk_lib +cmake_install_executorch.dev_tools_lib test_cmake_mps diff --git a/examples/sdk/CMakeLists.txt b/examples/dev_tools/CMakeLists.txt similarity index 79% rename from examples/sdk/CMakeLists.txt rename to examples/dev_tools/CMakeLists.txt index 5345c0b537..8519ee74c7 100644 --- a/examples/sdk/CMakeLists.txt +++ b/examples/dev_tools/CMakeLists.txt @@ -4,10 +4,10 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -# Example CMakeLists.txt for building executor_runner with sdk support. In this -# example we link sdk and bundled_program libraries into executor_runner binary +# Example CMakeLists.txt for building executor_runner with dev_tools support. In this +# example we link dev_tools and bundled_program libraries into executor_runner binary cmake_minimum_required(VERSION 3.19) -project(sdk_example) +project(dev_tools_example) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if(NOT CMAKE_CXX_STANDARD) @@ -43,15 +43,15 @@ find_package( gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party ) -add_executable(sdk_example_runner sdk_example_runner/sdk_example_runner.cpp) +add_executable(dev_tools_example_runner dev_tools_example_runner/dev_tools_example_runner.cpp) target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED) target_include_directories( - etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../sdk/include + etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../dev_tools/include ${EXECUTORCH_ROOT}/third-party/flatcc/include ) target_link_libraries( - sdk_example_runner + dev_tools_example_runner executorch gflags etdump diff --git a/examples/sdk/README.md b/examples/dev_tools/README.md similarity index 66% rename from examples/sdk/README.md rename to examples/dev_tools/README.md index 68043517fb..f25bc3a3a0 100644 --- a/examples/sdk/README.md +++ b/examples/dev_tools/README.md @@ -1,17 +1,17 @@ -# SDK Examples +# Developer Tools Examples This directory contains examples of BundledProgram and ETDump generation. ## Directory structure ```bash -examples/sdk +examples/dev_tools ├── scripts # Python scripts to illustrate export workflow of bundled program. -├── sdk_executor_runner # Contains an example for both BundledProgram to verify ExecuTorch model, and generate ETDump for runtime results. +├── dev_tools_executor_runner # Contains an example for both BundledProgram to verify ExecuTorch model, and generate ETDump for runtime results. └── README.md # Current file ``` ## BundledProgram -We will use an example model (in `torch.nn.Module`) and its representative inputs, both from [`models/`](../models) directory, to generate a [BundledProgram(`.bpte`)](../../docs/source/sdk-bundled-io.md) file using the [script](scripts/export_bundled_program.py). Then we will use [sdk_example_runner](sdk_example_runner/sdk_example_runner.cpp) to execute the `.bpte` model on the ExecuTorch runtime and verify the model on BundledProgram API. +We will use an example model (in `torch.nn.Module`) and its representative inputs, both from [`models/`](../models) directory, to generate a [BundledProgram(`.bpte`)](../../docs/source/dev_tools-bundled-io.md) file using the [script](scripts/export_bundled_program.py). Then we will use [dev_tools_example_runner](dev_tools_example_runner/dev_tools_example_runner.cpp) to execute the `.bpte` model on the ExecuTorch runtime and verify the model on BundledProgram API. 1. Sets up the basic development environment for ExecuTorch by [Setting up ExecuTorch from GitHub](https://pytorch.org/executorch/stable/getting-started-setup). @@ -22,22 +22,22 @@ We will use an example model (in `torch.nn.Module`) and its representative input cd executorch # To the top level dir # To get a list of example models -python3 -m examples.sdk.scripts.export_bundled_program -h +python3 -m examples.dev_tools.scripts.export_bundled_program -h # To generate a specific `.bpte` model -python3 -m examples.sdk.scripts.export_bundled_program -m mv2 # for MobileNetv2 +python3 -m examples.dev_tools.scripts.export_bundled_program -m mv2 # for MobileNetv2 # This should generate ./mv2_bundled.bpte file, if successful. ``` -3. Once we have the BundledProgram binary (`.bpte`) file, then let's run and verify it with ExecuTorch runtime and BundledProgram APIs using the [sdk_example_runner](sdk_example_runner/sdk_example_runner.cpp). +3. Once we have the BundledProgram binary (`.bpte`) file, then let's run and verify it with ExecuTorch runtime and BundledProgram APIs using the [dev_tools_example_runner](dev_tools_example_runner/dev_tools_example_runner.cpp). ```bash cd executorch - rm -rf cmake-out && mkdir cmake-out && cd cmake-out && cmake -DEXECUTORCH_BUILD_SDK=1 -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=1 .. + rm -rf cmake-out && mkdir cmake-out && cd cmake-out && cmake -DEXECUTORCH_BUILD_DEV_TOOLS=1 -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=1 .. cd .. - cmake --build cmake-out -j8 -t sdk_example_runner - ./cmake-out/examples/sdk/sdk_example_runner --bundled_program_path mv2_bundled.bpte --output_verification + cmake --build cmake-out -j8 -t dev_tools_example_runner + ./cmake-out/examples/dev_tools/dev_tools_example_runner --bundled_program_path mv2_bundled.bpte --output_verification ``` @@ -51,7 +51,7 @@ We offer an example runner that accepts a `BundledProgram` (`.bpte`) and runs a Running the program will generate an `ETDump` file (`.etdp`) at the location specified by `--etdump_path`. Make sure to build the program as specified below to enable the event tracer. ```bash - ./cmake-out/examples/sdk/sdk_example_runner --bundled_program_path mv2_bundled.bpte --etdump_path mv2_etdump.etdp + ./cmake-out/examples/dev_tools/dev_tools_example_runner --bundled_program_path mv2_bundled.bpte --etdump_path mv2_etdump.etdp ``` ### Parsing ETDump @@ -59,11 +59,11 @@ Running the program will generate an `ETDump` file (`.etdp`) at the location spe Once an `ETDump` has been generated, it can be viewed using the CLI inspector. This will print a tabular view of the data recorded in the ETDump. ```bash - python3 -m sdk.inspector.inspector_cli --etdump_path mv2_etdump.etdp + python3 -m dev_tools.inspector.inspector_cli --etdump_path mv2_etdump.etdp ``` ### ETDump C++ API -ETDump profiling can also be used in a custom C++ program. `ETDumpGen` is an implementation of the abstract `EventTracer` class. Include the header file located at `sdk/etdump/etdump_flatcc.h`. To initialize the ETDump generator, construct it before loading the method from the program. +ETDump profiling can also be used in a custom C++ program. `ETDumpGen` is an implementation of the abstract `EventTracer` class. Include the header file located at `dev_tools/etdump/etdump_flatcc.h`. To initialize the ETDump generator, construct it before loading the method from the program. ```cpp torch::executor::ETDumpGen etdump_gen = torch::executor::ETDumpGen(); diff --git a/examples/sdk/build_sdk_example_runner.sh b/examples/dev_tools/build_dev_tools_example_runner.sh similarity index 78% rename from examples/sdk/build_sdk_example_runner.sh rename to examples/dev_tools/build_dev_tools_example_runner.sh index 291febb36d..8b3361c437 100755 --- a/examples/sdk/build_sdk_example_runner.sh +++ b/examples/dev_tools/build_dev_tools_example_runner.sh @@ -5,7 +5,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -# Builds sdk_example_runner and prints its path. +# Builds dev_tools_example_runner and prints its path. set -euo pipefail @@ -23,12 +23,12 @@ main() { rm -rf cmake-out cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ -DCMAKE_BUILD_TYPE=Release \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \ -Bcmake-out . cmake --build cmake-out --target install --config Release - local example_dir=examples/sdk + local example_dir=examples/dev_tools local build_dir="cmake-out/${example_dir}" local cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags" rm -rf ${build_dir} @@ -38,12 +38,12 @@ main() { "${example_dir}" cmake --build "${build_dir}" --config Release - local runner="${PWD}/${build_dir}/sdk_example_runner" + local runner="${PWD}/${build_dir}/dev_tools_example_runner" if [[ ! -f "${runner}" ]]; then - echo "ERROR: Failed to build ${build_dir}/sdk_example_runner" >&2 + echo "ERROR: Failed to build ${build_dir}/dev_tools_example_runner" >&2 exit 1 else - echo "Built ${build_dir}/sdk_example_runner" + echo "Built ${build_dir}/dev_tools_example_runner" fi } diff --git a/examples/sdk/sdk_example_runner/TARGETS b/examples/dev_tools/dev_tools_example_runner/TARGETS similarity index 100% rename from examples/sdk/sdk_example_runner/TARGETS rename to examples/dev_tools/dev_tools_example_runner/TARGETS diff --git a/examples/sdk/sdk_example_runner/sdk_example_runner.cpp b/examples/dev_tools/dev_tools_example_runner/dev_tools_example_runner.cpp similarity index 98% rename from examples/sdk/sdk_example_runner/sdk_example_runner.cpp rename to examples/dev_tools/dev_tools_example_runner/dev_tools_example_runner.cpp index e2e42ab670..4cc7d910fb 100644 --- a/examples/sdk/sdk_example_runner/sdk_example_runner.cpp +++ b/examples/dev_tools/dev_tools_example_runner/dev_tools_example_runner.cpp @@ -22,13 +22,13 @@ #include +#include +#include #include #include #include #include #include -#include -#include #include static uint8_t method_allocator_pool[4 * 1024U * 1024U]; // 4MB diff --git a/examples/sdk/sdk_example_runner/targets.bzl b/examples/dev_tools/dev_tools_example_runner/targets.bzl similarity index 82% rename from examples/sdk/sdk_example_runner/targets.bzl rename to examples/dev_tools/dev_tools_example_runner/targets.bzl index a5e8feb33c..86ea141473 100644 --- a/examples/sdk/sdk_example_runner/targets.bzl +++ b/examples/dev_tools/dev_tools_example_runner/targets.bzl @@ -9,9 +9,9 @@ def define_common_targets(): # Test driver for models with bundled inputs. runtime.cxx_binary( - name = "sdk_example_runner", + name = "dev_tools_example_runner", srcs = [ - "sdk_example_runner.cpp", + "dev_tools_example_runner.cpp", ], deps = [ "//executorch/runtime/executor/test:test_backend_compiler_lib", @@ -20,8 +20,8 @@ def define_common_targets(): "//executorch/extension/data_loader:file_data_loader", "//executorch/extension/data_loader:buffer_data_loader", "//executorch/util:util", - "//executorch/sdk/etdump:etdump_flatcc", - "//executorch/sdk/bundled_program:runtime", + "//executorch/dev_tools/etdump:etdump_flatcc", + "//executorch/dev_tools/bundled_program:runtime", ], external_deps = [ "gflags", diff --git a/examples/dev_tools/scripts/TARGETS b/examples/dev_tools/scripts/TARGETS new file mode 100644 index 0000000000..08c477857f --- /dev/null +++ b/examples/dev_tools/scripts/TARGETS @@ -0,0 +1,29 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +oncall("executorch") + +runtime.python_binary( + name = "export_bundled_program", + main_function = ".export_bundled_program.main", + main_src = "export_bundled_program.py", + deps = [ + "//caffe2:torch", + "//executorch/dev_tools:lib", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools/bundled_program/serialize:lib", + "//executorch/examples/models:models", + "//executorch/extension/export_util:export_util", + ], +) + +runtime.python_binary( + name = "gen_sample_etrecord", + srcs = ["gen_sample_etrecord.py"], + main_function = "executorch.examples.dev_tools.scripts.gen_sample_etrecord.main", + deps = [ + "//executorch/dev_tools:lib", + "//executorch/dev_tools/etrecord:etrecord", + "//executorch/examples/models:models", + "//executorch/exir:lib", + ], +) diff --git a/examples/sdk/scripts/etrecord.bin b/examples/dev_tools/scripts/etrecord.bin similarity index 54% rename from examples/sdk/scripts/etrecord.bin rename to examples/dev_tools/scripts/etrecord.bin index 8476bcd4eabc5d4a03790bf7cf7aba08b4a49ad7..5c6b2f7f76d59c7014c959a9a456b9b43d4432ce 100644 GIT binary patch delta 41 pcmaD{{l0pGFArx*YFT_qetu5z<^Z16vIy?v0G<<@k7>yY0|0im5aR#< delta 29 jcmaD~{kVFAFAsBZO7>(ftrMH&cpuAvIGee&o(cm1zYz None: + """ + Exports the given eager model to bundled program. + + Args: + model_name: Name of the bundled program to export. + output_directory: Directory where the bundled program should be saved. + model: The eager model to export. + example_inputs: An example input for model's all method for single execution. + To simplify, here we assume that all inference methods have the same inputs. + """ + + print("Exporting ET program...") + + # pyre-ignore[6] + executorch_program = export_to_exec_prog(model, example_inputs) + + print("Creating bundled test cases...") + method_names = [ + method.name for method in executorch_program.executorch_program.execution_plan + ] + + # A model could have multiple entry point methods and each of them can have multiple inputs bundled for testing. + # This example demonstrates a model which has multiple entry point methods, whose name listed in method_names, to which we want + # to bundle two input test cases (example_inputs is used two times) for each inference method. + program_inputs = { + m_name: [example_inputs, example_inputs] for m_name in method_names + } + + method_test_suites: List[MethodTestSuite] = [] + for m_name in method_names: + method_inputs = program_inputs[m_name] + + # To create a bundled program, we first create every test cases from input. We leverage eager model + # to generate expected output for each test input, and use MethodTestCase to hold the information of + # each test case. We gather all MethodTestCase for same method into one MethodTestSuite, and generate + # bundled program by all MethodTestSuites. + method_test_cases: List[MethodTestCase] = [] + for method_input in method_inputs: + method_test_cases.append( + MethodTestCase( + inputs=method_input, + expected_outputs=model(*method_input), + ) + ) + + method_test_suites.append( + MethodTestSuite( + method_name=m_name, + test_cases=method_test_cases, + ) + ) + + save_bundled_program( + executorch_program, method_test_suites, f"{model_name}_bundled.bpte" + ) + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument( + "-m", + "--model_name", + required=True, + help=f"provide a model name. Valid ones: {list(MODEL_NAME_TO_MODEL.keys())}", + ) + parser.add_argument( + "-d", + "--dir", + default=".", + help="the directory to store the exported bundled program. Default is current directory.", + ) + + args = parser.parse_args() + + if args.model_name not in MODEL_NAME_TO_MODEL: + raise RuntimeError( + f"Model {args.model_name} is not a valid name. " + f"Available models are {list(MODEL_NAME_TO_MODEL.keys())}." + ) + + model, example_inputs, _ = EagerModelFactory.create_model( + *MODEL_NAME_TO_MODEL[args.model_name] + ) + + export_to_bundled_program(args.model_name, args.dir, model, example_inputs) + + +if __name__ == "__main__": + main() # pragma: no cover diff --git a/examples/dev_tools/scripts/gen_sample_etrecord.py b/examples/dev_tools/scripts/gen_sample_etrecord.py new file mode 100644 index 0000000000..857f20f915 --- /dev/null +++ b/examples/dev_tools/scripts/gen_sample_etrecord.py @@ -0,0 +1,86 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# Generate fixture files +import argparse +import copy +from typing import Any + +import torch +from executorch.dev_tools import generate_etrecord +from executorch.exir import ( + EdgeCompileConfig, + EdgeProgramManager, + ExecutorchProgramManager, + ExportedProgram, + to_edge, +) +from executorch.exir.capture._config import ExecutorchBackendConfig +from torch.export import export + +from ...models import MODEL_NAME_TO_MODEL +from ...models.model_factory import EagerModelFactory + + +DEFAULT_OUTPUT_PATH = "/tmp/etrecord.bin" + + +def gen_etrecord(model: torch.nn.Module, inputs: Any, output_path=None): + f = model + aten_dialect: ExportedProgram = export( + f, + inputs, + ) + edge_program: EdgeProgramManager = to_edge( + aten_dialect, compile_config=EdgeCompileConfig(_check_ir_validity=True) + ) + edge_program_copy = copy.deepcopy(edge_program) + et_program: ExecutorchProgramManager = edge_program_copy.to_executorch( + config=ExecutorchBackendConfig(extract_constant_segment=False) + ) + generate_etrecord( + (DEFAULT_OUTPUT_PATH if not output_path else output_path), + edge_dialect_program=edge_program, + executorch_program=et_program, + export_modules={ + "aten_dialect_output": aten_dialect, + }, + ) + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument( + "-m", + "--model_name", + required=True, + help=f"provide a model name. Valid ones: {list(MODEL_NAME_TO_MODEL.keys())}", + ) + + parser.add_argument( + "-o", + "--output_path", + required=False, + help=f"Provide an output path to save the generated etrecord. Defaults to {DEFAULT_OUTPUT_PATH}.", + ) + + args = parser.parse_args() + + if args.model_name not in MODEL_NAME_TO_MODEL: + raise RuntimeError( + f"Model {args.model_name} is not a valid name. " + f"Available models are {list(MODEL_NAME_TO_MODEL.keys())}." + ) + + model, example_inputs, _ = EagerModelFactory.create_model( + *MODEL_NAME_TO_MODEL[args.model_name] + ) + + gen_etrecord(model, example_inputs, args.output_path) + + +if __name__ == "__main__": + main() # pragma: no cover diff --git a/examples/sdk/test_sdk_example_runner.sh b/examples/dev_tools/test_dev_tools_example_runner.sh similarity index 71% rename from examples/sdk/test_sdk_example_runner.sh rename to examples/dev_tools/test_dev_tools_example_runner.sh index 5185def655..0f9c936813 100644 --- a/examples/sdk/test_sdk_example_runner.sh +++ b/examples/dev_tools/test_dev_tools_example_runner.sh @@ -5,7 +5,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -# Test the end-to-end flow of building sdk_example_runner and use it to run +# Test the end-to-end flow of building dev_tools_example_runner and use it to run # an actual model. @@ -14,23 +14,23 @@ set -e # shellcheck source=/dev/null source "$(dirname "${BASH_SOURCE[0]}")/../../.ci/scripts/utils.sh" -cmake_install_executorch_sdk_lib() { +cmake_install_executorch.dev_tools_lib() { echo "Installing libexecutorch.a, libportable_kernels.a, libetdump.a, libbundled_program.a" rm -rf cmake-out retry cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ -DCMAKE_BUILD_TYPE=Release \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \ -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \ -Bcmake-out . cmake --build cmake-out -j9 --target install --config Release } -test_cmake_sdk_example_runner() { +test_cmake_dev_tools_example_runner() { echo "Exporting MobilenetV2" - ${PYTHON_EXECUTABLE} -m examples.sdk.scripts.export_bundled_program --model_name="mv2" - local example_dir=examples/sdk + ${PYTHON_EXECUTABLE} -m examples.dev_tools.scripts.export_bundled_program --model_name="mv2" + local example_dir=examples/dev_tools local build_dir=cmake-out/${example_dir} CMAKE_PREFIX_PATH="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags" rm -rf ${build_dir} @@ -44,8 +44,8 @@ test_cmake_sdk_example_runner() { echo "Building ${example_dir}" cmake --build ${build_dir} -j9 --config Release - echo 'Running sdk_example_runner' - ${build_dir}/sdk_example_runner --bundled_program_path="./mv2_bundled.bpte" + echo 'Running dev_tools_example_runner' + ${build_dir}/dev_tools_example_runner --bundled_program_path="./mv2_bundled.bpte" } if [[ -z $PYTHON_EXECUTABLE ]]; @@ -58,5 +58,5 @@ then BUCK=buck2 fi -cmake_install_executorch_sdk_lib -test_cmake_sdk_example_runner +cmake_install_executorch.dev_tools_lib +test_cmake_dev_tools_example_runner diff --git a/examples/models/llama2/TARGETS b/examples/models/llama2/TARGETS index 319527321e..45efd75bb7 100644 --- a/examples/models/llama2/TARGETS +++ b/examples/models/llama2/TARGETS @@ -93,7 +93,7 @@ runtime.python_library( # "//executorch/extension/pybindings:aten_lib", # "//executorch/extension/pybindings:portable_lib", # "//executorch/extension/pybindings:portable_lib_plus_custom", - "//executorch/sdk/etrecord:etrecord", + "//executorch/dev_tools/etrecord:etrecord", "//executorch/util:memory_profiler", "//executorch/util:python_profiler", "fbsource//third-party/pypi/coremltools:coremltools", diff --git a/examples/models/llama2/export_llama_lib.py b/examples/models/llama2/export_llama_lib.py index cf5d1b6e6f..65bd69fccc 100644 --- a/examples/models/llama2/export_llama_lib.py +++ b/examples/models/llama2/export_llama_lib.py @@ -22,6 +22,8 @@ import torch +from executorch.dev_tools.etrecord import generate_etrecord + from executorch.examples.models.llama2.llama_transformer import ModelArgs from executorch.extension.llm.export.builder import DType, LLMEdgeManager @@ -39,8 +41,6 @@ get_pt2e_quantizers, get_qnn_quantizer, ) - -from executorch.sdk.etrecord import generate_etrecord from executorch.util.activation_memory_profiler import generate_memory_trace from ..model_factory import EagerModelFactory diff --git a/examples/models/llama2/params/demo_rand_params.pth b/examples/models/llama2/params/demo_rand_params.pth index 900663169d5c1ef78b9b474aa6a90a5cbc80e21a..755ab8d56ed9a2c205d8ee9dd193c4e34e07c052 100644 GIT binary patch delta 113 zcmexyEwSZ#VnYjK3sVbo3rh=Y3tJ0&3r7p*7A}(z&Xm-$_>%nmoZ@!#5H29*24Wr{ r<^^ItAm#^R0U#CxVj&cH0mxAm#>Q9w6ogVm=_| l2Vwyr76f7;AQlE<5g--?VzKSEA>udPLAtlg&k;{O4* #include #include -#include +#include #include #include diff --git a/examples/qualcomm/scripts/export_example.py b/examples/qualcomm/scripts/export_example.py index b12a44993d..90188039ae 100644 --- a/examples/qualcomm/scripts/export_example.py +++ b/examples/qualcomm/scripts/export_example.py @@ -20,7 +20,7 @@ from executorch.exir.backend.backend_api import to_backend, validation_disabled from executorch.exir.capture._config import ExecutorchBackendConfig from executorch.extension.export_util.utils import save_pte_program -from executorch.sdk import generate_etrecord +from executorch.dev_tools import generate_etrecord from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e diff --git a/examples/sdk/scripts/export_bundled_program.py b/examples/sdk/scripts/export_bundled_program.py index 7e118a78c1..2221202546 100644 --- a/examples/sdk/scripts/export_bundled_program.py +++ b/examples/sdk/scripts/export_bundled_program.py @@ -11,19 +11,19 @@ from typing import List import torch - -from executorch.exir import ExecutorchProgramManager -from executorch.extension.export_util.utils import export_to_exec_prog -from executorch.sdk import BundledProgram -from executorch.sdk.bundled_program.config import ( +from executorch.dev_tools import BundledProgram +from executorch.dev_tools.bundled_program.config import ( MethodInputType, MethodTestCase, MethodTestSuite, ) -from executorch.sdk.bundled_program.serialize import ( +from executorch.dev_tools.bundled_program.serialize import ( serialize_from_bundled_program_to_flatbuffer, ) +from executorch.exir import ExecutorchProgramManager +from executorch.extension.export_util.utils import export_to_exec_prog + from ...models import MODEL_NAME_TO_MODEL from ...models.model_factory import EagerModelFactory diff --git a/examples/sdk/scripts/gen_sample_etrecord.py b/examples/sdk/scripts/gen_sample_etrecord.py index c219ed4094..857f20f915 100644 --- a/examples/sdk/scripts/gen_sample_etrecord.py +++ b/examples/sdk/scripts/gen_sample_etrecord.py @@ -10,6 +10,7 @@ from typing import Any import torch +from executorch.dev_tools import generate_etrecord from executorch.exir import ( EdgeCompileConfig, EdgeProgramManager, @@ -18,7 +19,6 @@ to_edge, ) from executorch.exir.capture._config import ExecutorchBackendConfig -from executorch.sdk import generate_etrecord from torch.export import export from ...models import MODEL_NAME_TO_MODEL diff --git a/examples/xnnpack/aot_compiler.py b/examples/xnnpack/aot_compiler.py index a816c4f0e7..db402af3ad 100644 --- a/examples/xnnpack/aot_compiler.py +++ b/examples/xnnpack/aot_compiler.py @@ -12,9 +12,9 @@ import torch from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner +from executorch.dev_tools import generate_etrecord from executorch.exir import EdgeCompileConfig, ExecutorchBackendConfig from executorch.extension.export_util.utils import export_to_edge, save_pte_program -from executorch.sdk import generate_etrecord from ..models import MODEL_NAME_TO_MODEL from ..models.model_factory import EagerModelFactory diff --git a/examples/xnnpack/targets.bzl b/examples/xnnpack/targets.bzl index 30cafa56fa..64f715ede6 100644 --- a/examples/xnnpack/targets.bzl +++ b/examples/xnnpack/targets.bzl @@ -32,7 +32,7 @@ def define_common_targets(): "//executorch/examples/xnnpack/quantization:quant_utils", "//executorch/exir:lib", "//executorch/exir/backend:backend_api", - "//executorch/sdk:lib", + "//executorch/dev_tools:lib", ], ) diff --git a/exir/_serialize/TARGETS b/exir/_serialize/TARGETS index 8ddf830039..d756794b69 100644 --- a/exir/_serialize/TARGETS +++ b/exir/_serialize/TARGETS @@ -14,8 +14,8 @@ cpp_python_extension( "//executorch/backends/fb/qnnpack/...", "//executorch/backends/vulkan/...", "//executorch/backends/xnnpack/...", - "//executorch/sdk/bundled_program/...", - "//executorch/sdk/etdump/...", + "//executorch/dev_tools/bundled_program/...", + "//executorch/dev_tools/etdump/...", ], deps = [ "fbsource//third-party/flatbuffers:flatc_library", @@ -45,6 +45,10 @@ runtime.python_library( visibility = [ "//executorch/backends/...", "//executorch/codegen/...", + "//executorch/dev_tools:lib", + "//executorch/dev_tools/bundled_program/serialize:lib", + "//executorch/dev_tools/bundled_program/tests/...", + "//executorch/dev_tools/experimental/...", "//executorch/examples/async_exec:emit_program_lib", "//executorch/exir/...", "//executorch/exir/tests/...", @@ -52,10 +56,6 @@ runtime.python_library( "//executorch/extension/pybindings/test:test", "//executorch/extension/pybindings/test:test-library", "//executorch/profiler/...", - "//executorch/sdk:lib", - "//executorch/sdk/bundled_program/serialize:lib", - "//executorch/sdk/bundled_program/tests/...", - "//executorch/sdk/experimental/...", "//executorch/test/...", "@EXECUTORCH_CLIENTS", ], diff --git a/extension/pybindings/pybindings.cpp b/extension/pybindings/pybindings.cpp index 1f6d1075a1..b52b14e36d 100644 --- a/extension/pybindings/pybindings.cpp +++ b/extension/pybindings/pybindings.cpp @@ -17,6 +17,9 @@ #include #include +#include +#include +#include #include #include #include @@ -28,9 +31,6 @@ #include #include #include -#include -#include -#include #include #include diff --git a/extension/pybindings/pybindings.pyi b/extension/pybindings/pybindings.pyi index a085911672..8cd85b4834 100644 --- a/extension/pybindings/pybindings.pyi +++ b/extension/pybindings/pybindings.pyi @@ -40,7 +40,7 @@ def _load_for_executorch( Args: path: File path to the ExecuTorch program as a string. enable_etdump: If true, enables an ETDump which can store profiling information. - See documentation at https://pytorch.org/executorch/stable/sdk-etdump.html + See documentation at https://pytorch.org/executorch/stable/dev_tools-etdump.html for how to use it. debug_buffer_size: If non-zero, enables a debug buffer which can store intermediate results of each instruction in the ExecuTorch program. @@ -60,7 +60,8 @@ def _load_for_executorch_from_bundled_program( module: BundledModule, enable_etdump: bool = False, debug_buffer_size: int = 0 ) -> ExecuTorchModule: """Same as _load_for_executorch, but takes a bundled program instead of a file path. - See https://pytorch.org/executorch/stable/sdk-bundled-io.html for documentation.""" + See https://pytorch.org/executorch/stable/dev_tools-bundled-io.html for documentation. + """ ... def _load_bundled_program_from_buffer( diff --git a/kernels/README.md b/kernels/README.md index 4e9656e6e9..a27a58a167 100644 --- a/kernels/README.md +++ b/kernels/README.md @@ -356,7 +356,7 @@ cmake . \ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_BUILD_VULKAN=OFF \ -DEXECUTORCH_BUILD_XNNPACK=ON \ -Bcmake-out diff --git a/pytest.ini b/pytest.ini index 5ed1780e61..833f22243d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -13,8 +13,8 @@ addopts = --ignore-glob=backends/arm/**/* # explicitly list out tests that are running successfully in oss examples/models/test - # sdk/ - sdk/ + # dev_tools/ + dev_tools/ # examples examples/models/llama2/tests # examples/models/llava/test TODO: enable this diff --git a/runtime/core/event_tracer.h b/runtime/core/event_tracer.h index 55549ddea5..037486d167 100644 --- a/runtime/core/event_tracer.h +++ b/runtime/core/event_tracer.h @@ -97,8 +97,8 @@ struct EventTracerEntry { * EventTracer is a class that users can inherit and implement to * log/serialize/stream etc. the profiling and debugging events that are * generated at runtime for a model. An example of this is the ETDump - * implementation in the SDK codebase that serializes these events to a - * flatbuffer. + * implementation in the Developer Tools codebase that serializes these events + * to a flatbuffer. */ class EventTracer { public: diff --git a/runtime/core/targets.bzl b/runtime/core/targets.bzl index 4978e73169..f8595ac8b0 100644 --- a/runtime/core/targets.bzl +++ b/runtime/core/targets.bzl @@ -9,14 +9,14 @@ def get_event_tracer_flags(): event_tracer_flags += ["-DET_EVENT_TRACER_ENABLED"] return event_tracer_flags -def build_sdk(): - return native.read_config("executorch", "build_sdk", "false") == "true" +def build_dev_tools(): + return native.read_config("executorch", "build_dev_tools", "false") == "true" -def get_sdk_flags(): - sdk_flags = [] - if build_sdk(): - sdk_flags += ["-DEXECUTORCH_BUILD_SDK"] - return sdk_flags +def get_dev_tools_flags(): + dev_tools_flags = [] + if build_dev_tools(): + dev_tools_flags += ["-DEXECUTORCH_BUILD_DEV_TOOLS"] + return dev_tools_flags def define_common_targets(): """Defines targets that should be shared between fbcode and xplat. @@ -100,7 +100,7 @@ def define_common_targets(): "//executorch/...", "@EXECUTORCH_CLIENTS", ], - exported_preprocessor_flags = get_event_tracer_flags() + get_sdk_flags(), + exported_preprocessor_flags = get_event_tracer_flags() + get_dev_tools_flags(), exported_deps = [ "//executorch/runtime/platform:platform", "//executorch/runtime/core:evalue" + aten_suffix, diff --git a/runtime/executor/test/targets.bzl b/runtime/executor/test/targets.bzl index eaec540c27..01deffa4f0 100644 --- a/runtime/executor/test/targets.bzl +++ b/runtime/executor/test/targets.bzl @@ -19,7 +19,7 @@ def define_common_targets(is_fbcode = False): "//executorch/exir/backend/test/...", "//executorch/runtime/backend/...", "//executorch/extension/pybindings/...", - "//executorch/sdk/fb/runners/...", + "//executorch/dev_tools/fb/runners/...", "//executorch/test/...", "//executorch/examples/...", ], @@ -43,7 +43,7 @@ def define_common_targets(is_fbcode = False): "//executorch/exir/backend/test/...", "//executorch/runtime/backend/...", "//executorch/extension/pybindings/...", - "//executorch/sdk/fb/runners/...", + "//executorch/dev_tools/fb/runners/...", "//executorch/test/...", "//executorch/examples/...", ], diff --git a/schema/targets.bzl b/schema/targets.bzl index 2c797baa16..f3de98b520 100644 --- a/schema/targets.bzl +++ b/schema/targets.bzl @@ -57,7 +57,7 @@ def define_common_targets(): name = INPUT_SCALAR_TYPE, visibility = [ "//executorch/exir/_serialize/...", - "//executorch/sdk/etdump/...", + "//executorch/dev_tools/etdump/...", ], ) diff --git a/sdk/inspector/tests/TARGETS b/sdk/inspector/tests/TARGETS deleted file mode 100644 index 374d2ea753..0000000000 --- a/sdk/inspector/tests/TARGETS +++ /dev/null @@ -1,40 +0,0 @@ -load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") - -oncall("executorch") - -python_unittest( - name = "inspector_test", - srcs = ["inspector_test.py"], - deps = [ - "//executorch/exir:lib", - "//executorch/sdk:lib", - "//executorch/sdk/debug_format:et_schema", - "//executorch/sdk/etdump:schema_flatcc", - "//executorch/sdk/etrecord/tests:etrecord_test_library", - "//executorch/sdk/inspector:inspector", - "//executorch/sdk/inspector:lib", - ], -) - -python_unittest( - name = "event_blocks_test", - srcs = ["event_blocks_test.py"], - deps = [ - "//executorch/sdk/etdump:schema_flatcc", - "//executorch/sdk/inspector:inspector", - "//executorch/sdk/inspector:lib", - ], -) - -python_unittest( - name = "inspector_utils_test", - srcs = ["inspector_utils_test.py"], - deps = [ - "//executorch/sdk:lib", - "//executorch/sdk/debug_format:base_schema", - "//executorch/sdk/debug_format:et_schema", - "//executorch/sdk/etdump:schema_flatcc", - "//executorch/sdk/etrecord/tests:etrecord_test_library", - "//executorch/sdk/inspector:inspector_utils", - ], -) diff --git a/sdk/targets.bzl b/sdk/targets.bzl deleted file mode 100644 index 38c2e6e820..0000000000 --- a/sdk/targets.bzl +++ /dev/null @@ -1,8 +0,0 @@ -def build_sdk(): - return native.read_config("executorch", "build_sdk", "false") == "true" - -def get_sdk_flags(): - sdk_flags = [] - if build_sdk(): - sdk_flags += ["-DEXECUTORCH_BUILD_SDK"] - return sdk_flags diff --git a/setup.py b/setup.py index d71133b7bd..d9c0cfc03d 100644 --- a/setup.py +++ b/setup.py @@ -360,12 +360,12 @@ def run(self): ("schema/scalar_type.fbs", "exir/_serialize/scalar_type.fbs"), ("schema/program.fbs", "exir/_serialize/program.fbs"), ( - "sdk/bundled_program/schema/bundled_program_schema.fbs", - "sdk/bundled_program/serialize/bundled_program_schema.fbs", + "dev_tools/bundled_program/schema/bundled_program_schema.fbs", + "dev_tools/bundled_program/serialize/bundled_program_schema.fbs", ), ( - "sdk/bundled_program/schema/scalar_type.fbs", - "sdk/bundled_program/serialize/scalar_type.fbs", + "dev_tools/bundled_program/schema/scalar_type.fbs", + "dev_tools/bundled_program/serialize/scalar_type.fbs", ), ] for src, dst in src_to_dst: @@ -595,8 +595,8 @@ def get_ext_modules() -> List[Extension]: "executorch/exir": "exir", "executorch/extension": "extension", "executorch/schema": "schema", - "executorch/sdk": "sdk", - "executorch/sdk/bundled_program": "sdk/bundled_program", + "executorch/dev_tools": "dev_tools", + "executorch/dev_tools/bundled_program": "dev_tools/bundled_program", "executorch/util": "util", # Note: This will install a top-level module called "serializer", # which seems too generic and might conflict with other pip packages. diff --git a/shim/xplat/executorch/build/env_interface.bzl b/shim/xplat/executorch/build/env_interface.bzl index 27d2887b66..82275f36ed 100644 --- a/shim/xplat/executorch/build/env_interface.bzl +++ b/shim/xplat/executorch/build/env_interface.bzl @@ -69,7 +69,7 @@ def _start_with_et_targets(target): return False def _patch_platforms(kwargs): - """Platforms and apple_sdks are not supported yet, so pop them out from kwargs. + """Platforms and apple_dev_toolss are not supported yet, so pop them out from kwargs. Args: kwargs: The `kwargs` parameter from a rule. @@ -79,8 +79,8 @@ def _patch_platforms(kwargs): """ if "platforms" in kwargs: kwargs.pop("platforms") - if "apple_sdks" in kwargs: - kwargs.pop("apple_sdks") + if "apple_dev_toolss" in kwargs: + kwargs.pop("apple_dev_toolss") return kwargs def _patch_deps(kwargs, dep_type): diff --git a/shim/xplat/executorch/extension/pybindings/pybindings.bzl b/shim/xplat/executorch/extension/pybindings/pybindings.bzl index f62c567ba4..c744cd1157 100644 --- a/shim/xplat/executorch/extension/pybindings/pybindings.bzl +++ b/shim/xplat/executorch/extension/pybindings/pybindings.bzl @@ -10,29 +10,29 @@ MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB = [ PORTABLE_MODULE_DEPS = [ "//executorch/runtime/kernel:operator_registry", "//executorch/runtime/executor:program", - "//executorch/sdk/bundled_program/schema:bundled_program_schema_fbs", + "//executorch/dev_tools/bundled_program/schema:bundled_program_schema_fbs", "//executorch/extension/aten_util:aten_bridge", - "//executorch/sdk/bundled_program:runtime", + "//executorch/dev_tools/bundled_program:runtime", "//executorch/extension/data_loader:buffer_data_loader", "//executorch/extension/data_loader:mmap_data_loader", "//executorch/extension/memory_allocator:malloc_memory_allocator", "//executorch/util:util", "//executorch/runtime/executor/test:test_backend_compiler_lib", - "//executorch/sdk/etdump:etdump_flatcc", + "//executorch/dev_tools/etdump:etdump_flatcc", ] + get_all_cpu_backend_targets() ATEN_MODULE_DEPS = [ "//executorch/runtime/kernel:operator_registry", "//executorch/runtime/executor:program_aten", "//executorch/runtime/core/exec_aten:lib", - "//executorch/sdk/bundled_program/schema:bundled_program_schema_fbs", + "//executorch/dev_tools/bundled_program/schema:bundled_program_schema_fbs", "//executorch/extension/data_loader:buffer_data_loader", "//executorch/extension/data_loader:mmap_data_loader", "//executorch/extension/memory_allocator:malloc_memory_allocator", "//executorch/util:read_file", - "//executorch/sdk/bundled_program:runtime_aten", + "//executorch/dev_tools/bundled_program:runtime_aten", "//executorch/runtime/executor/test:test_backend_compiler_lib_aten", - "//executorch/sdk/etdump:etdump_flatcc", + "//executorch/dev_tools/etdump:etdump_flatcc", ] # Generated lib for all ATen ops with aten kernel used by models in model inventory diff --git a/test/end2end/TARGETS b/test/end2end/TARGETS index 8c0885e32e..6bdf1b4fad 100644 --- a/test/end2end/TARGETS +++ b/test/end2end/TARGETS @@ -42,6 +42,9 @@ python_unittest( ":exported_module", ":register_scratch_meta_fns", "//caffe2:torch", + "//executorch/dev_tools:lib", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools/bundled_program/serialize:lib", "//executorch/exir:dynamic_shape", "//executorch/exir:lib", "//executorch/exir:memory", @@ -57,9 +60,6 @@ python_unittest( "//executorch/exir/tests:transformer", "//executorch/extension/pybindings:aten_lib", "//executorch/extension/pytree:pybindings", - "//executorch/sdk:lib", - "//executorch/sdk/bundled_program:config", - "//executorch/sdk/bundled_program/serialize:lib", ], ) @@ -73,6 +73,9 @@ python_unittest( ":exported_module", ":register_scratch_meta_fns", "//caffe2:torch", + "//executorch/dev_tools:lib", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools/bundled_program/serialize:lib", "//executorch/exir:dynamic_shape", "//executorch/exir:lib", "//executorch/exir:memory", @@ -88,8 +91,5 @@ python_unittest( "//executorch/exir/tests:transformer", "//executorch/extension/pybindings:portable_lib", "//executorch/extension/pytree:pybindings", - "//executorch/sdk:lib", - "//executorch/sdk/bundled_program:config", - "//executorch/sdk/bundled_program/serialize:lib", ], ) diff --git a/test/models/generate_linear_out_bundled_program.py b/test/models/generate_linear_out_bundled_program.py index 9201e43adf..a5b58f6887 100644 --- a/test/models/generate_linear_out_bundled_program.py +++ b/test/models/generate_linear_out_bundled_program.py @@ -17,15 +17,15 @@ from typing import List import torch +from executorch.dev_tools import BundledProgram +from executorch.dev_tools.bundled_program.config import MethodTestCase, MethodTestSuite +from executorch.dev_tools.bundled_program.serialize import ( + serialize_from_bundled_program_to_flatbuffer, +) from executorch.exir import ExecutorchBackendConfig, to_edge from executorch.exir.passes import MemoryPlanningPass, ToOutVarPass from executorch.exir.print_program import pretty_print -from executorch.sdk import BundledProgram -from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite -from executorch.sdk.bundled_program.serialize import ( - serialize_from_bundled_program_to_flatbuffer, -) from executorch.test.models.linear_model import LinearModel from torch.export import export diff --git a/test/models/targets.bzl b/test/models/targets.bzl index e44c6eb0c7..8ebad02e79 100644 --- a/test/models/targets.bzl +++ b/test/models/targets.bzl @@ -22,9 +22,9 @@ def define_common_targets(): deps = [ ":linear_model", "//caffe2:torch", - "//executorch/sdk/bundled_program:config", - "//executorch/sdk:lib", - "//executorch/sdk/bundled_program/serialize:lib", + "//executorch/dev_tools/bundled_program:config", + "//executorch/dev_tools:lib", + "//executorch/dev_tools/bundled_program/serialize:lib", "//executorch/exir:lib", "//executorch/exir/_serialize:lib", ], diff --git a/test/run_oss_cpp_tests.sh b/test/run_oss_cpp_tests.sh index 0cb766738a..ed1a45e7e2 100755 --- a/test/run_oss_cpp_tests.sh +++ b/test/run_oss_cpp_tests.sh @@ -35,7 +35,7 @@ build_executorch() { -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ - -DEXECUTORCH_BUILD_SDK=ON \ + -DEXECUTORCH_BUILD_DEV_TOOLS=ON \ -DEXECUTORCH_BUILD_VULKAN=$BUILD_VULKAN \ -DEXECUTORCH_BUILD_XNNPACK=ON \ -Bcmake-out @@ -119,7 +119,7 @@ probe_tests() { kernels runtime schema - sdk + dev_tools test )