-
Notifications
You must be signed in to change notification settings - Fork 625
create and validate build_variables.bzl #8326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
swolchok
wants to merge
52
commits into
main
Choose a base branch
from
gh/swolchok/240/head
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 48 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
07adf1a
Update
swolchok bc3fd39
Update
swolchok 00ce927
Update
swolchok 6440d3d
Update
swolchok e62191a
Update
swolchok 630bdd0
Update
swolchok 098432f
Update
swolchok 773ff37
Update
swolchok 87513d8
Update
swolchok b61319b
Update
swolchok d4aaa36
Update
swolchok 15bc325
Update
swolchok 6b9b4cc
Update
swolchok ca4c14e
Update
swolchok a0e9eb9
Update
swolchok 4878a6b
Update
swolchok da6fd97
Update
swolchok e9d552e
Update
swolchok 8ed9894
Update
swolchok 3f80407
Update
swolchok 8016e33
Update
swolchok a947148
Update
swolchok e3ae7b5
Update
swolchok a826c40
Update
swolchok 6601683
Update
swolchok 7a8397f
Update
swolchok f7c1205
Update
swolchok 4b35d1e
Update
swolchok fe6b9c7
Update
swolchok ff128f7
Update
swolchok f06ee2f
Update
swolchok a1b9a76
Update
swolchok 59355b9
Update
swolchok 95cfe7d
Update
swolchok cb0234b
Update
swolchok 0d53925
Update
swolchok 3b24ef4
Update
swolchok 9d8e434
Update
swolchok 3a2d555
Update
swolchok b8f2a5b
Update
swolchok 719b63d
Update
swolchok f02844b
Update
swolchok 1b47bf0
Update
swolchok 61f045d
Update
swolchok 4eb72d3
Update
swolchok 9c7b3d1
Update
swolchok 25a26e2
Update
swolchok aafa130
Update
swolchok 71ef8af
Update
swolchok b52f223
Update
swolchok 8df2f1d
Update
swolchok 7f5cfd3
Update
swolchok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
# Selective build. See codegen/tools/gen_oplist.py for how to use these | ||
# arguments. | ||
include(${EXECUTORCH_ROOT}/build/Utils.cmake) | ||
include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake) | ||
|
||
function(gen_selected_ops) | ||
set(arg_names LIB_NAME OPS_SCHEMA_YAML ROOT_OPS INCLUDE_ALL_OPS) | ||
|
@@ -97,7 +97,7 @@ function(generate_bindings_for_kernels) | |
--tags-path=${site-packages-out}/torchgen/packaged/ATen/native/tags.yaml | ||
--aten-yaml-path=${site-packages-out}/torchgen/packaged/ATen/native/native_functions.yaml | ||
--op-selection-yaml-path=${_oplist_yaml} | ||
) | ||
) | ||
if(GEN_ADD_EXCEPTION_BOUNDARY) | ||
set(_gen_command "${_gen_command}" --add-exception-boundary) | ||
endif() | ||
|
@@ -217,3 +217,127 @@ function(merge_yaml) | |
WORKING_DIRECTORY ${EXECUTORCH_ROOT} | ||
) | ||
endfunction() | ||
|
||
# Append the file list in the variable named `name` in build/build_variables.bzl | ||
# to the variable named `outputvar` in the caller's scope. | ||
function(append_filelist name outputvar) | ||
# configure_file adds its input to the list of CMAKE_RERUN dependencies | ||
configure_file( | ||
${PROJECT_SOURCE_DIR}/build/build_variables.bzl | ||
${PROJECT_BINARY_DIR}/build_variables.bzl COPYONLY | ||
) | ||
execute_process( | ||
COMMAND | ||
"${PYTHON_EXECUTABLE}" -c | ||
"exec(open('${PROJECT_SOURCE_DIR}/build/build_variables.bzl').read());print(';'.join(${name}))" | ||
WORKING_DIRECTORY "${_rootdir}" | ||
RESULT_VARIABLE _retval | ||
OUTPUT_VARIABLE _tempvar | ||
ERROR_VARIABLE _stderr | ||
) | ||
if(NOT _retval EQUAL 0) | ||
message( | ||
FATAL_ERROR | ||
"Failed to fetch filelist ${name} from build_variables.bzl with output ${_tempvar} and stderr ${_stderr}" | ||
) | ||
endif() | ||
string(REPLACE "\n" "" _tempvar "${_tempvar}") | ||
list(APPEND ${outputvar} ${_tempvar}) | ||
set(${outputvar} | ||
"${${outputvar}}" | ||
PARENT_SCOPE | ||
) | ||
endfunction() | ||
|
||
# Fail the build if the src lists in build_variables.bzl do not match the src | ||
# lists extracted from Buck and placed into EXECUTORCH_SRCS_FILE. This is | ||
# intended to be a safety mechanism while we are in the process of removing Buck | ||
# from the CMake build and replacing it with build_variables.bzl; if you are | ||
# seeing failures after you have intentionally changed Buck srcs, then simply | ||
# update build_variables.bzl. If you are seeing failures after changing | ||
# something about the build system, make sure your changes will work both before | ||
# and after we finish replacing Buck with build_variables.bzl, which should | ||
# involve getting these lists to match! | ||
function(validate_build_variables) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment on this explaining what it does, and to help future authors understand when they need to add/remove elements in these lists. |
||
include(${EXECUTORCH_SRCS_FILE}) | ||
set(BUILD_VARIABLES_FILELISTS | ||
EXECUTORCH_SRCS | ||
EXECUTORCH_CORE_SRCS | ||
PORTABLE_KERNELS_SRCS | ||
OPTIMIZED_KERNELS_SRCS | ||
QUANTIZED_KERNELS_SRCS | ||
PROGRAM_SCHEMA_SRCS | ||
OPTIMIZED_CPUBLAS_SRCS | ||
OPTIMIZED_NATIVE_CPU_OPS_OSS_SRCS | ||
EXTENSION_DATA_LOADER_SRCS | ||
EXTENSION_MODULE_SRCS | ||
EXTENSION_RUNNER_UTIL_SRCS | ||
EXTENSION_LLM_RUNNER_SRCS | ||
EXTENSION_TENSOR_SRCS | ||
EXTENSION_THREADPOOL_SRCS | ||
EXTENSION_TRAINING_SRCS | ||
TRAIN_XOR_SRCS | ||
EXECUTOR_RUNNER_SRCS | ||
SIZE_TEST_SRCS | ||
MPS_EXECUTOR_RUNNER_SRCS | ||
MPS_BACKEND_SRCS | ||
MPS_SCHEMA_SRCS | ||
XNN_EXECUTOR_RUNNER_SRCS | ||
XNNPACK_BACKEND_SRCS | ||
XNNPACK_SCHEMA_SRCS | ||
VULKAN_SCHEMA_SRCS | ||
CUSTOM_OPS_SRCS | ||
LLAMA_RUNNER_SRCS | ||
) | ||
set(BUILD_VARIABLES_VARNAMES | ||
_executorch__srcs | ||
_executorch_core__srcs | ||
_portable_kernels__srcs | ||
_optimized_kernels__srcs | ||
_quantized_kernels__srcs | ||
_program_schema__srcs | ||
_optimized_cpublas__srcs | ||
_optimized_native_cpu_ops_oss__srcs | ||
_extension_data_loader__srcs | ||
_extension_module__srcs | ||
_extension_runner_util__srcs | ||
_extension_llm_runner__srcs | ||
_extension_tensor__srcs | ||
_extension_threadpool__srcs | ||
_extension_training__srcs | ||
_train_xor__srcs | ||
_executor_runner__srcs | ||
_size_test__srcs | ||
_mps_executor_runner__srcs | ||
_mps_backend__srcs | ||
_mps_schema__srcs | ||
_xnn_executor_runner__srcs | ||
_xnnpack_backend__srcs | ||
_xnnpack_schema__srcs | ||
_vulkan_schema__srcs | ||
_custom_ops__srcs | ||
_llama_runner__srcs | ||
) | ||
foreach(filelist_and_varname IN ZIP_LISTS BUILD_VARIABLES_FILELISTS | ||
BUILD_VARIABLES_VARNAMES | ||
) | ||
if("${filelist_and_varname_1}" STREQUAL "_custom_ops__srcs") | ||
continue() | ||
endif() | ||
append_filelist( | ||
${filelist_and_varname_0} | ||
"${filelist_and_varname_1}_from_build_variables" | ||
) | ||
if(NOT ${filelist_and_varname_1} STREQUAL | ||
${filelist_and_varname_1}_from_build_variables | ||
) | ||
message( | ||
FATAL_ERROR | ||
"Buck-generated ${filelist_and_varname_1} does not match hardcoded " | ||
"${filelist_and_varname_0} in build_variables.bzl. Left: " | ||
"${${filelist_and_varname_1}}\n " | ||
"Right: ${${filelist_and_varname_1}_from_build_variables}" | ||
) | ||
endif() | ||
endforeach() | ||
endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining what this does and what it expects for (and will do to)
outputvar