Skip to content

Commit 3a0b7cb

Browse files
authored
Merge branch 'main' into export-D84284541
2 parents d142cfd + 8d51b0f commit 3a0b7cb

15 files changed

+55
-16
lines changed

backends/vulkan/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ file(GLOB_RECURSE vulkan_runtime_utils_cpp ${RUNTIME_PATH}/utils/*.cpp)
111111

112112
# vulkan_backend
113113

114+
# Try to find boost to log stack traces when throwing exceptions
115+
find_package(Boost 1.89 COMPONENTS stacktrace_basic stacktrace_addr2line)
116+
114117
file(GLOB vulkan_backend_cpp ${RUNTIME_PATH}/*.cpp)
115118
list(APPEND vulkan_backend_cpp ${vulkan_graph_cpp})
116119
list(APPEND vulkan_backend_cpp ${vulkan_standard_shaders_cpp})
@@ -121,6 +124,14 @@ target_include_directories(
121124
vulkan_backend PRIVATE ${SCHEMA_INCLUDE_DIR} ${COMMON_INCLUDES}
122125
)
123126
target_link_libraries(vulkan_backend PRIVATE vulkan_schema executorch_core)
127+
# Optionally link boost for stacktraces if boost is available
128+
if(DEFINED Boost_STACKTRACE_BASIC_LIBRARY)
129+
target_link_libraries(
130+
vulkan_backend PRIVATE ${Boost_STACKTRACE_LIBRARY}
131+
${Boost_STACKTRACE_ADDR2LINE_LIBRARY}
132+
)
133+
list(APPEND VULKAN_CXX_FLAGS "-DETVK_BOOST_STACKTRACE_AVAILABLE")
134+
endif()
124135
target_compile_options(vulkan_backend PRIVATE ${VULKAN_CXX_FLAGS})
125136
# Link this library with --whole-archive due to dynamic backend registration
126137
executorch_target_link_options_shared_lib(vulkan_backend)

backends/vulkan/runtime/vk_api/Exception.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
#include <sstream>
1212

13+
#ifdef ETVK_BOOST_STACKTRACE_AVAILABLE
14+
#ifndef _GNU_SOURCE
15+
#define _GNU_SOURCE
16+
#endif // _GNU_SOURCE
17+
#include <boost/stacktrace.hpp>
18+
#endif // ETVK_BOOST_STACKTRACE_AVAILABLE
19+
1320
namespace vkcompute {
1421
namespace vkapi {
1522

@@ -65,6 +72,11 @@ Error::Error(SourceLocation source_location, std::string msg)
6572
std::ostringstream oss;
6673
oss << "Exception raised from " << source_location_ << ": ";
6774
oss << msg_;
75+
#ifdef ETVK_BOOST_STACKTRACE_AVAILABLE
76+
oss << "\n";
77+
oss << "Stack trace:\n";
78+
oss << boost::stacktrace::stacktrace();
79+
#endif // ETVK_BOOST_STACKTRACE_AVAILABLE
6880
what_ = oss.str();
6981
}
7082

@@ -74,6 +86,11 @@ Error::Error(SourceLocation source_location, const char* cond, std::string msg)
7486
oss << "Exception raised from " << source_location_ << ": ";
7587
oss << "(" << cond << ") is false! ";
7688
oss << msg_;
89+
#ifdef ETVK_BOOST_STACKTRACE_AVAILABLE
90+
oss << "\n";
91+
oss << "Stack trace:\n";
92+
oss << boost::stacktrace::stacktrace();
93+
#endif // ETVK_BOOST_STACKTRACE_AVAILABLE
7794
what_ = oss.str();
7895
}
7996

backends/vulkan/targets.bzl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def get_vulkan_preprocessor_flags(no_volk, is_fbcode):
1919
default_flags = []
2020
android_flags = []
2121

22+
debug_mode = read_config("etvk", "debug", "0") == "1"
23+
2224
if not no_volk:
2325
for flags in [default_flags, android_flags]:
2426
flags.append("-DUSE_VULKAN_WRAPPER")
@@ -32,6 +34,10 @@ def get_vulkan_preprocessor_flags(no_volk, is_fbcode):
3234
if link_moltenvk:
3335
mac_flags = []
3436

37+
if debug_mode:
38+
mac_flags.append("-DETVK_BOOST_STACKTRACE_AVAILABLE")
39+
default_flags.append("-DETVK_BOOST_STACKTRACE_AVAILABLE")
40+
3541
VK_API_PREPROCESSOR_FLAGS += select({
3642
"DEFAULT": default_flags,
3743
"ovr_config//os:android": android_flags,
@@ -59,7 +65,6 @@ def get_vulkan_preprocessor_flags(no_volk, is_fbcode):
5965
if etvk_default_cache_path != "":
6066
VK_API_PREPROCESSOR_FLAGS += ["-DETVK_DEFAULT_CACHE_PATH={}".format(etvk_default_cache_path)]
6167

62-
debug_mode = read_config("etvk", "debug", "0") == "1"
6368
if debug_mode:
6469
VK_API_PREPROCESSOR_FLAGS += ["-DVULKAN_DEBUG"]
6570

@@ -136,6 +141,8 @@ def vulkan_spv_shader_lib(name, spv_filegroups, is_fbcode = False, no_volk = Fal
136141
)
137142

138143
def define_common_targets(is_fbcode = False):
144+
debug_mode = read_config("etvk", "debug", "0") == "1"
145+
139146
runtime.python_library(
140147
name = "gen_vulkan_spv_lib",
141148
srcs = [
@@ -200,6 +207,10 @@ def define_common_targets(is_fbcode = False):
200207
"//third-party/khronos:moltenVK_static"
201208
]
202209

210+
if debug_mode:
211+
mac_deps.append("fbsource//third-party/boost:boost")
212+
default_deps.append("fbsource//third-party/boost:boost")
213+
203214
VK_API_DEPS += select({
204215
"DEFAULT": default_deps,
205216
"ovr_config//os:android": android_deps,

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ To build the documentation locally:
4343
git clone -b viable/strict https://github.com/pytorch/executorch.git && cd executorch
4444
```
4545

46-
1. If you don't have it already, start either a Python virtual envitonment:
46+
1. If you don't have it already, start either a Python virtual environment:
4747

4848
```bash
4949
python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip
@@ -111,7 +111,7 @@ You can use the variables in both regular text and code blocks.
111111
## Including READMEs to the Documentation Build
112112

113113
You might want to include some of the `README.md` files from various directories
114-
in this repositories in your documentation build. To do that, create an `.md`
114+
in this repository in your documentation build. To do that, create an `.md`
115115
file and use the `{include}` directive to insert your `.md` files. Example:
116116

117117
````
@@ -177,7 +177,7 @@ file:
177177
````
178178

179179
In the `index.md` file, I would add `tutorials/selective-build-tutorial` in
180-
both the `toctree` and the `cusotmcarditem` sections.
180+
both the `toctree` and the `customcarditem` sections.
181181

182182
# Auto-generated API documentation
183183

docs/source/backends-coreml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The Core ML partitioner API allows for configuration of the model delegation to
6161
- `skip_ops_for_coreml_delegation`: Allows you to skip ops for delegation by Core ML. By default, all ops that Core ML supports will be delegated. See [here](https://github.com/pytorch/executorch/blob/14ff52ff89a89c074fc6c14d3f01683677783dcd/backends/apple/coreml/test/test_coreml_partitioner.py#L42) for an example of skipping an op for delegation.
6262
- `compile_specs`: A list of `CompileSpec`s for the Core ML backend. These control low-level details of Core ML delegation, such as the compute unit (CPU, GPU, ANE), the iOS deployment target, and the compute precision (FP16, FP32). These are discussed more below.
6363
- `take_over_mutable_buffer`: A boolean that indicates whether PyTorch mutable buffers in stateful models should be converted to [Core ML `MLState`](https://developer.apple.com/documentation/coreml/mlstate). If set to `False`, mutable buffers in the PyTorch graph are converted to graph inputs and outputs to the Core ML lowered module under the hood. Generally, setting `take_over_mutable_buffer` to true will result in better performance, but using `MLState` requires iOS >= 18.0, macOS >= 15.0, and Xcode >= 16.0.
64-
- `take_over_constant_data`: A boolean that indicates whether PyTorch constant data like model weights should be consumed by the Core ML delegate. If set to False, constant data is passed to the Core ML delegate as inputs. By deafault, take_over_constant_data=True.
64+
- `take_over_constant_data`: A boolean that indicates whether PyTorch constant data like model weights should be consumed by the Core ML delegate. If set to False, constant data is passed to the Core ML delegate as inputs. By default, take_over_constant_data=True.
6565
- `lower_full_graph`: A boolean that indicates whether the entire graph must be lowered to Core ML. If set to True and Core ML does not support an op, an error is raised during lowering. If set to False and Core ML does not support an op, the op is executed on the CPU by ExecuTorch. Although setting `lower_full_graph`=False can allow a model to lower where it would otherwise fail, it can introduce performance overhead in the model when there are unsupported ops. You will see warnings about unsupported ops during lowering if there are any. By default, `lower_full_graph`=False.
6666

6767

docs/source/backends-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Backends are the bridge between your exported model and the hardware it runs on.
3131
| [OpenVINO](build-run-openvino) | Embedded | CPU/GPU/NPU | Intel SoCs |
3232
| [NXP](backends-nxp) | Embedded | NPU | NXP SoCs |
3333
| [Cadence](backends-cadence) | Embedded | DSP | DSP-optimized workloads |
34-
| [Samsung Exynos](backends-samsung-exynos)| Android | NPU | Samsung Socs |
34+
| [Samsung Exynos](backends-samsung-exynos)| Android | NPU | Samsung SoCs |
3535

3636
**Tip:** For best performance, export a `.pte` file for each backend you plan to support.
3737

docs/source/backends-xnnpack.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ To perform 8-bit quantization with the PT2E flow, perform the following steps pr
8282
1) Create an instance of the `XnnpackQuantizer` class. Set quantization parameters.
8383
2) Use `torch.export.export` to prepare for quantization.
8484
3) Call `prepare_pt2e` to prepare the model for quantization.
85-
4) For static quantization, run the prepared model with representative samples to calibrate the quantizated tensor activation ranges.
85+
4) For static quantization, run the prepared model with representative samples to calibrate the quantized tensor activation ranges.
8686
5) Call `convert_pt2e` to quantize the model.
8787
6) Export and lower the model using the standard flow.
8888

docs/source/devtools-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ More details are available in the [ETDump documentation](etdump.md) on how to ge
4141

4242

4343
### Inspector APIs
44-
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.
44+
The Inspector Python APIs are the main user entry 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.
4545

4646
More details are available in the [Inspector API documentation](model-inspector.rst) on how to use the Inspector APIs.

docs/source/getting-started-architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ _Executor_ is the entry point to load the program and execute it. The execution
8989

9090
## Developer Tools
9191

92-
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](devtools-overview.md) to improve productivity. The Developer Tools are not in the diagram. Instead it's a tool set that covers the developer workflow in all three phases.
92+
It should be efficient for users to go from research to production using the flow above. Productivity is especially important, for users to author, optimize and deploy their models. We provide [ExecuTorch Developer Tools](devtools-overview.md) to improve productivity. The Developer Tools are not in the diagram. Instead it's a tool set that covers the developer workflow in all three phases.
9393

9494
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.

docs/source/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ input_tensor: torch.Tensor = torch.randn(1, 3, 224, 224)
8989
program = runtime.load_program("model.pte")
9090
method = program.load_method("forward")
9191
output: List[torch.Tensor] = method.execute([input_tensor])
92-
print("Run succesfully via executorch")
92+
print("Run successfully via executorch")
9393

9494
from torchvision.models.mobilenetv2 import MobileNet_V2_Weights
9595
import torchvision.models as models

0 commit comments

Comments
 (0)