Skip to content

Commit

Permalink
Add flatbuffers to third_party to avoid issues with top-level build (#…
Browse files Browse the repository at this point in the history
…138)

Fixes #137
  • Loading branch information
rdspring1 authored Apr 6, 2023
1 parent 7b24fa8 commit 2c6d0cf
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git
[submodule "third_party/flatbuffers"]
path = third_party/flatbuffers
url = https://github.com/google/flatbuffers
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ if (PROJECT_IS_TOP_LEVEL)
set(ATEN_CUDA_ROOT "${TORCH_INSTALL_PREFIX}/include/ATen")
# CXX flags is necessary since https://github.com/pytorch/pytorch/issues/98093
string(APPEND CMAKE_CXX_FLAGS ${TORCH_CXX_FLAGS})
include(cmake/FlatBuffers.cmake)
if(BUILD_NVFUSER_BENCHMARK)
include(Dependencies.cmake)
include(cmake/Dependencies.cmake)
endif()
set(NVFUSER_LIB_DIR "${NVFUSER_ROOT}/nvfuser/lib")
file(MAKE_DIRECTORY ${NVFUSER_LIB_DIR})
Expand Down
10 changes: 5 additions & 5 deletions Dependencies.cmake → cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ set(BUILD_GMOCK ON CACHE BOOL "Build gmock." FORCE)
# this shouldn't be necessary anymore.
get_property(INC_DIR_temp DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/third_party/googletest)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest)
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${INC_DIR_temp})

include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/third_party/googletest/googletest/include)
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/third_party/googletest/googlemock/include)
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/include)
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googlemock/include)

# We will not need to test benchmark lib itself.
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark testing as we don't need it.")
# We will not need to install benchmark since we link it statically.
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Disable benchmark install to avoid overwriting vendor install.")

if(NOT USE_SYSTEM_BENCHMARK)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/third_party/benchmark)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/benchmark)
else()
add_library(benchmark SHARED IMPORTED)
find_library(BENCHMARK_LIBRARY benchmark)
Expand All @@ -41,7 +41,7 @@ endif()
message("-- Found benchmark: ${BENCHMARK_LIBRARY}")
set_property(TARGET benchmark PROPERTY IMPORTED_LOCATION ${BENCHMARK_LIBRARY})
endif()
include_directories(${CMAKE_CURRENT_LIST_DIR}/third_party/benchmark/include)
include_directories(${CMAKE_CURRENT_LIST_DIR}/../third_party/benchmark/include)

# Recover build options.
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
Expand Down
11 changes: 11 additions & 0 deletions cmake/FlatBuffers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(FlatBuffers_Include ${PROJECT_SOURCE_DIR}/../third_party/flatbuffers/include)
file(GLOB FlatBuffers_Library_SRCS
${FlatBuffers_Include}/flatbuffers/*.h
)
add_library(flatbuffers INTERFACE)
target_sources(
flatbuffers
INTERFACE ${FlatBuffers_Library_SRCS}
)
target_include_directories(flatbuffers INTERFACE ${FlatBuffers_Include})
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/flatbuffers/include)
2 changes: 0 additions & 2 deletions csrc/python_frontend/fusion_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -2727,8 +2727,6 @@ struct RandomOpRecord : RecordFunctor {
for (auto& it : output_shape_) {
fb_shape.push_back(serde::State(it.index, it.stype));
}
auto shape_fb =
builder.CreateVectorOfStructs(fb_shape.data(), fb_shape.size());
return {
serde::RecordData_TensorCreationSymbolic,
serde::CreateTensorCreationSymbolicDirect(
Expand Down
1 change: 1 addition & 0 deletions third_party/flatbuffers
Submodule flatbuffers added at d0cede
1 change: 1 addition & 0 deletions tools/update_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"./version.txt",
"./test/main.cpp",
"Dependencies.cmake",
"FlatBuffers.cmake",
# lint adapters are taken from pytorch
"tools/linter/adapters/black_linter.py",
"tools/linter/adapters/clangformat_linter.py",
Expand Down

0 comments on commit 2c6d0cf

Please sign in to comment.