Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backends/vulkan/runtime/gen_vulkan_spv.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,12 @@ def escape(line: str) -> str:
def preprocess(
input_text: str, variables: Dict[str, Any], input_path: str = "codegen"
) -> str:
# Normalize line endings first. Templates checked out with CRLF (common on
# Windows) otherwise break the trailing-backslash handling below: in
# re.MULTILINE, $ matches immediately before \n, so a CR would sit between a
# trailing \ and the line end and defeat the r"\\$" match, leaving a lone
# backslash that escape() turns into an unterminated Python string literal.
input_text = input_text.replace("\r\n", "\n").replace("\r", "\n")
# Workaround to handle source files using \ to extend mecros to a new line
input_text = re.sub(r"\\$", r"\\\\", input_text, flags=re.MULTILINE)

Expand Down
13 changes: 13 additions & 0 deletions examples/models/llama/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,21 @@ if(ANDROID)
list(APPEND link_libraries log)
endif()

# ETDump profiling support (OSS build). The llama runner does not link etdump or
# define ET_EVENT_TRACER_ENABLED by default. When the core libs are built with
# EXECUTORCH_BUILD_DEVTOOLS=ON + EXECUTORCH_ENABLE_EVENT_TRACER=ON, find_package
# imports the etdump target; linking it and defining the macro enables ETDump
# collection and makes the Vulkan delegate emit per-dispatch GPU timestamps.
if(TARGET etdump)
list(APPEND link_libraries etdump)
endif()

add_executable(llama_main ${_srcs})

if(TARGET etdump)
target_compile_definitions(llama_main PRIVATE ET_EVENT_TRACER_ENABLED)
endif()

# Copy MLX metallib for runtime if MLX delegate is enabled
if(TARGET mlxdelegate)
executorch_target_copy_mlx_metallib(llama_main)
Expand Down
19 changes: 19 additions & 0 deletions third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ else()
set(_flatbuffers_ep_additional_args)
endif()

# Allow reusing a prebuilt host flatc instead of building it from source. This is
# required when cross-compiling with the Ninja generator on Windows: the WIN32
# branch above only supports the Visual Studio generator (it passes the VS-only
# CMAKE_GENERATOR_PLATFORM), and the flatbuffers_ep host sub-build otherwise
# fails under Ninja. Pass -DFLATC_EXECUTABLE=<path to a host flatc(.exe)>.
if(FLATC_EXECUTABLE)
add_executable(flatc IMPORTED GLOBAL)
set_target_properties(flatc PROPERTIES IMPORTED_LOCATION "${FLATC_EXECUTABLE}")
else()
# We use ExternalProject to build flatc from source to force it target the host.
# Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android).
ExternalProject_Add(
Expand Down Expand Up @@ -86,6 +95,7 @@ else()
flatc PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/flatc
)
endif()
endif()

# TODO: re-enable once flatbuffers is added as a subdirectory.
# set(FLATBUFFERS_BUILD_FLATC OFF) set(FLATBUFFERS_INSTALL OFF)
Expand All @@ -104,6 +114,14 @@ else()
set(_flatcc_extra_cmake_args)
endif()

# Allow reusing a prebuilt host flatcc (see the flatc note above). Needed for the
# Ninja-on-Windows cross-compile, where the flatcc_ep host sub-build fails. Pass
# -DFLATCC_EXECUTABLE=<path to a host flatcc(.exe)>. flatcc_cli is only consumed
# by devtools/etdump, so this imported target is unused when devtools is off.
if(FLATCC_EXECUTABLE)
add_executable(flatcc_cli IMPORTED GLOBAL)
set_target_properties(flatcc_cli PROPERTIES IMPORTED_LOCATION "${FLATCC_EXECUTABLE}")
else()
# Similar to flatbuffers, we want to build flatcc for the host. See inline
# comments in the flatbuffers ExternalProject_Add for more details.
ExternalProject_Add(
Expand Down Expand Up @@ -142,6 +160,7 @@ else()
flatcc_cli PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/flatcc
)
endif()
endif()

set(FLATCC_RTONLY
ON
Expand Down
Loading