Skip to content

Commit 69dcfe0

Browse files
dbortfacebook-github-bot
authored andcommitted
Set FLATBUFFERS_MAX_ALIGNMENT=1024 (#4215)
Summary: I noticed a [build failure](https://github.com/pytorch/executorch/actions/runs/9883069353/job/27297116628#step:12:12476) during a flatc execution step, complaining about a `force_align` value that was larger than FLATBUFFERS_MAX_ALIGNMENT (default 32): ``` Exported ModuleAddMul and wrote program data to cmake-out/ModuleAddMul.pte Exported ModuleAddMul and wrote program data to cmake-out/ModuleAddMul-da1024.pte Exported ModuleAddMul and wrote program data to cmake-out/ModuleAddMul-nosegments.pte error: /tmp/tmpslmqnrmb/data.json:1: 2248: error: unexpected force_align value '1024', alignment must be a power of two integer ranging from the type's natural alignment 1 to 32 ``` The error message is printed by https://github.com/google/flatbuffers/blob/fb9afbafc7dfe226b9db54d4923bfb8839635274/src/idl_parser.cpp#L1694 exir lets users set the alignment of tensor data embedded in the flatbuffer, and some users need an alignment larger than the default. So, increase the default to a "large" power of 2 when building `flatc` and when building the runtime. Pull Request resolved: #4215 Test Plan: CI jobs pass. I looked at the makefiles generated by cmake, and verified that FLATBUFFERS_MAX_ALIGNMENT is only being set while building `flatc` and `executorch_no_prim_ops`: ``` find . -name flags.make | xargs grep MAX_ALIGNMENT ./CMakeFiles/executorch_no_prim_ops.dir/flags.make:CXX_DEFINES = -DET_ENABLE_PROGRAM_VERIFICATION=0 -DET_MIN_LOG_LEVEL=Info -DFLATBUFFERS_MAX_ALIGNMENT=1024 ./third-party/flatbuffers/CMakeFiles/flatc.dir/flags.make:CXX_DEFINES = -DET_ENABLE_PROGRAM_VERIFICATION=0 -DET_MIN_LOG_LEVEL=Info -DFLATBUFFERS_LOCALE_INDEPENDENT=0 -DFLATBUFFERS_MAX_ALIGNMENT=1024 ``` Reviewed By: tarun292 Differential Revision: D59645222 Pulled By: dbort fbshipit-source-id: e692ead83d08757c067a9d636853614ea3eb2eca
1 parent 56120f9 commit 69dcfe0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ if(EXECUTORCH_BUILD_FLATC)
424424
CACHE BOOL ""
425425
)
426426
add_subdirectory(third-party/flatbuffers)
427+
428+
# exir lets users set the alignment of tensor data embedded in the flatbuffer,
429+
# and some users need an alignment larger than the default, which is typically
430+
# 32.
431+
target_compile_definitions(flatc PRIVATE FLATBUFFERS_MAX_ALIGNMENT=1024)
427432
endif()
428433
if(NOT FLATC_EXECUTABLE)
429434
message(

schema/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ function(generate_program_schema _schema_srcs _schema_name)
4444

4545
add_library(${_schema_name} INTERFACE ${_schema_outputs})
4646
set_target_properties(${_schema_name} PROPERTIES LINKER_LANGUAGE CXX)
47+
48+
# exir lets users set the alignment of tensor data embedded in the flatbuffer,
49+
# and some users need an alignment larger than the default, which is typically
50+
# 32.
51+
target_compile_definitions(
52+
${_schema_name} INTERFACE FLATBUFFERS_MAX_ALIGNMENT=1024)
53+
4754
target_include_directories(
4855
${_schema_name}
4956
INTERFACE ${_program_schema__include_dir}

0 commit comments

Comments
 (0)