diff --git a/CMakeLists.txt b/CMakeLists.txt index ad1f5d2019a..83335cd674d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -373,7 +373,7 @@ if(NOT "${_repo_dir_name}" STREQUAL "executorch") "fix for this restriction." ) endif() -set(_common_include_directories ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/runtime/core/portable_type) +set(_common_include_directories ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/runtime/core/portable_type/c10) # # The `__srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}. diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index 70daed7d065..01fe9d0f59a 100644 --- a/backends/apple/coreml/CMakeLists.txt +++ b/backends/apple/coreml/CMakeLists.txt @@ -134,7 +134,7 @@ target_include_directories( coremldelegate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util ) target_include_directories(coremldelegate PRIVATE ${EXECUTORCH_ROOT}/..) -target_include_directories(coremldelegate PRIVATE ${EXECUTORCH_ROOT}/runtime/core/portable_type) +target_include_directories(coremldelegate PRIVATE ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) target_compile_definitions(coremldelegate PRIVATE C10_USING_CUSTOM_GENERATED_MACROS) target_link_libraries(coremldelegate PRIVATE executorch_core) diff --git a/backends/apple/coreml/runtime/workspace/executorchcoreml.xcodeproj/project.pbxproj b/backends/apple/coreml/runtime/workspace/executorchcoreml.xcodeproj/project.pbxproj index 2115f5a4806..198faebb9d7 100644 --- a/backends/apple/coreml/runtime/workspace/executorchcoreml.xcodeproj/project.pbxproj +++ b/backends/apple/coreml/runtime/workspace/executorchcoreml.xcodeproj/project.pbxproj @@ -922,7 +922,7 @@ "$(SRCROOT)/../kvstore", "$(SRCROOT)/../inmemoryfs", "$(SRCROOT)/../include", - "$(SRCROOT)/../include/executorch/runtime/core/portable_type", + "$(SRCROOT)/../include/executorch/runtime/core/portable_type/c10", "$(SRCROOT)/../sdk", "$(SRCROOT)/../util", "$(SRCROOT)/../../third-party/nlohmann_json/single_include", @@ -954,7 +954,7 @@ "$(SRCROOT)/../kvstore", "$(SRCROOT)/../inmemoryfs", "$(SRCROOT)/../include", - "$(SRCROOT)/../include/executorch/runtime/core/portable_type", + "$(SRCROOT)/../include/executorch/runtime/core/portable_type/c10", "$(SRCROOT)/../sdk", "$(SRCROOT)/../util", "$(SRCROOT)/../../third-party/nlohmann_json/single_include", diff --git a/backends/arm/CMakeLists.txt b/backends/arm/CMakeLists.txt index 58d0389ea71..d91d3051a55 100644 --- a/backends/arm/CMakeLists.txt +++ b/backends/arm/CMakeLists.txt @@ -14,7 +14,7 @@ endif() include(${EXECUTORCH_ROOT}/build/Utils.cmake) -set(_common_include_directories ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type) +set(_common_include_directories ${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS) # Third-party folder and Ethos-U driver inclued diff --git a/backends/qualcomm/CMakeLists.txt b/backends/qualcomm/CMakeLists.txt index 81d61fb0659..aefa929ee9f 100644 --- a/backends/qualcomm/CMakeLists.txt +++ b/backends/qualcomm/CMakeLists.txt @@ -74,7 +74,7 @@ endif() include_directories( BEFORE ${_common_include_directories} ${QNN_SDK_ROOT}/include/QNN ${EXECUTORCH_SOURCE_DIR}/third-party/flatbuffers/include - ${EXECUTORCH_SOURCE_DIR}/runtime/core/portable_type + ${EXECUTORCH_SOURCE_DIR}/runtime/core/portable_type/c10 ) set(_qnn_schema__srcs diff --git a/build/build_apple_frameworks.sh b/build/build_apple_frameworks.sh index 7ebfe2d9492..4d793ace0ab 100755 --- a/build/build_apple_frameworks.sh +++ b/build/build_apple_frameworks.sh @@ -207,11 +207,11 @@ check_command "$BUCK2" # So, just patch our generated framework to do that. sed -i '' '1i\ #define C10_USING_CUSTOM_GENERATED_MACROS -' $HEADERS_PATH/executorch/runtime/core/portable_type/c10/macros/Macros.h +' $HEADERS_PATH/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h sed -i '' '1i\ #define C10_USING_CUSTOM_GENERATED_MACROS -' $HEADERS_PATH/executorch/runtime/core/portable_type/c10/macros/Export.h -cp -r $HEADERS_PATH/executorch/runtime/core/portable_type/c10 "$HEADERS_PATH/" +' $HEADERS_PATH/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +cp -r $HEADERS_PATH/executorch/runtime/core/portable_type/c10/c10 "$HEADERS_PATH/" cp "$SOURCE_ROOT_DIR/extension/apple/ExecuTorch/Exported/"*.h "$HEADERS_PATH/executorch" diff --git a/build/executorch-config.cmake b/build/executorch-config.cmake index 40c28d0b961..d14a1227cd9 100644 --- a/build/executorch-config.cmake +++ b/build/executorch-config.cmake @@ -29,7 +29,7 @@ cmake_minimum_required(VERSION 3.19) set(_root "${CMAKE_CURRENT_LIST_DIR}/../../..") set(required_lib_list executorch executorch_core portable_kernels) set(EXECUTORCH_LIBRARIES) -set(EXECUTORCH_INCLUDE_DIRS ${_root}/include ${_root}/include/executorch/runtime/core/portable_type ${_root}/lib) +set(EXECUTORCH_INCLUDE_DIRS ${_root}/include ${_root}/include/executorch/runtime/core/portable_type/c10 ${_root}/lib) foreach(lib ${required_lib_list}) set(lib_var "LIB_${lib}") add_library(${lib} STATIC IMPORTED) @@ -40,7 +40,7 @@ foreach(lib ${required_lib_list}) ) set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION "${${lib_var}}") target_compile_definitions(${lib} INTERFACE C10_USING_CUSTOM_GENERATED_MACROS) - target_include_directories(${lib} INTERFACE ${_root}/include ${_root}/include/executorch/runtime/core/portable_type ${_root}/lib) + target_include_directories(${lib} INTERFACE ${_root}/include ${_root}/include/executorch/runtime/core/portable_type/c10 ${_root}/lib) list(APPEND EXECUTORCH_LIBRARIES ${lib}) endforeach() @@ -110,7 +110,7 @@ foreach(lib ${lib_list}) add_library(${lib} STATIC IMPORTED) endif() set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION "${${lib_var}}") - target_include_directories(${lib} INTERFACE ${_root}/include ${_root}/include/executorch/runtime/core/portable_type ${_root}/lib) + target_include_directories(${lib} INTERFACE ${_root}/include ${_root}/include/executorch/runtime/core/portable_type/c10 ${_root}/lib) list(APPEND EXECUTORCH_LIBRARIES ${lib}) endif() endforeach() diff --git a/examples/apple/coreml/executor_runner/coreml_executor_runner.xcodeproj/project.pbxproj b/examples/apple/coreml/executor_runner/coreml_executor_runner.xcodeproj/project.pbxproj index 71301f113b2..a4d22670f68 100644 --- a/examples/apple/coreml/executor_runner/coreml_executor_runner.xcodeproj/project.pbxproj +++ b/examples/apple/coreml/executor_runner/coreml_executor_runner.xcodeproj/project.pbxproj @@ -298,7 +298,7 @@ ENABLE_HARDENED_RUNTIME = YES; HEADER_SEARCH_PATHS = ( "$(SRCROOT)/include", - "$(SRCROOT)/include/executorch/runtime/core/portable_type", + "$(SRCROOT)/include/executorch/runtime/core/portable_type/c10", ); IPHONEOS_DEPLOYMENT_TARGET = 16.0; LIBRARY_SEARCH_PATHS = ( @@ -320,7 +320,7 @@ ENABLE_HARDENED_RUNTIME = YES; HEADER_SEARCH_PATHS = ( "$(SRCROOT)/include", - "$(SRCROOT)/include/executorch/runtime/core/portable_type", + "$(SRCROOT)/include/executorch/runtime/core/portable_type/c10", ); IPHONEOS_DEPLOYMENT_TARGET = 16.0; LIBRARY_SEARCH_PATHS = ( diff --git a/examples/arm/executor_runner/CMakeLists.txt b/examples/arm/executor_runner/CMakeLists.txt index 54da4659a02..d43a7047080 100644 --- a/examples/arm/executor_runner/CMakeLists.txt +++ b/examples/arm/executor_runner/CMakeLists.txt @@ -384,7 +384,7 @@ target_link_options( arm_executor_runner PUBLIC LINKER:-Map=arm_executor_runner. # ET headers and generated headers includes target_include_directories( - arm_executor_runner PRIVATE ${ET_INCLUDE_PATH} ${ET_DIR_PATH}/runtime/core/portable_type ${CMAKE_CURRENT_BINARY_DIR} + arm_executor_runner PRIVATE ${ET_INCLUDE_PATH} ${ET_DIR_PATH}/runtime/core/portable_type/c10 ${CMAKE_CURRENT_BINARY_DIR} ) target_compile_definitions(arm_executor_runner PRIVATE C10_USING_CUSTOM_GENERATED_MACROS) diff --git a/kernels/optimized/cpu/targets.bzl b/kernels/optimized/cpu/targets.bzl index c556803313e..1c62b683b8f 100644 --- a/kernels/optimized/cpu/targets.bzl +++ b/kernels/optimized/cpu/targets.bzl @@ -38,7 +38,7 @@ _OPTIMIZED_ATEN_OPS = ( name = "op_gelu", deps = [ "//executorch/kernels/portable/cpu/util:activation_ops_util", - "//executorch/runtime/core/portable_type/c10:aten_headers_for_executorch", + "//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch", ], ), op_target( diff --git a/runtime/core/portable_type/c10/README.md b/runtime/core/portable_type/c10/README.md new file mode 100644 index 00000000000..df14d22a4cf --- /dev/null +++ b/runtime/core/portable_type/c10/README.md @@ -0,0 +1,7 @@ +We added an extra c10 directory so that runtime/core/portable_type/c10 +can be the directory to put on your include path, rather than +runtime/core/portable_type, because using runtime/core/portable_type +would cause all headers in that directory to be includeable with +`#include `. In particular, that includes +runtime/core/portable_type/complex.h, which would shadow the C99 +complex.h standard header. diff --git a/runtime/core/portable_type/c10/TARGETS b/runtime/core/portable_type/c10/c10/TARGETS similarity index 100% rename from runtime/core/portable_type/c10/TARGETS rename to runtime/core/portable_type/c10/c10/TARGETS diff --git a/runtime/core/portable_type/c10/macros/Export.h b/runtime/core/portable_type/c10/c10/macros/Export.h similarity index 100% rename from runtime/core/portable_type/c10/macros/Export.h rename to runtime/core/portable_type/c10/c10/macros/Export.h diff --git a/runtime/core/portable_type/c10/macros/Macros.h b/runtime/core/portable_type/c10/c10/macros/Macros.h similarity index 100% rename from runtime/core/portable_type/c10/macros/Macros.h rename to runtime/core/portable_type/c10/c10/macros/Macros.h diff --git a/runtime/core/portable_type/c10/targets.bzl b/runtime/core/portable_type/c10/c10/targets.bzl similarity index 100% rename from runtime/core/portable_type/c10/targets.bzl rename to runtime/core/portable_type/c10/c10/targets.bzl diff --git a/runtime/core/portable_type/c10/util/BFloat16-inl.h b/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h similarity index 100% rename from runtime/core/portable_type/c10/util/BFloat16-inl.h rename to runtime/core/portable_type/c10/c10/util/BFloat16-inl.h diff --git a/runtime/core/portable_type/c10/util/BFloat16-math.h b/runtime/core/portable_type/c10/c10/util/BFloat16-math.h similarity index 100% rename from runtime/core/portable_type/c10/util/BFloat16-math.h rename to runtime/core/portable_type/c10/c10/util/BFloat16-math.h diff --git a/runtime/core/portable_type/c10/util/BFloat16.h b/runtime/core/portable_type/c10/c10/util/BFloat16.h similarity index 100% rename from runtime/core/portable_type/c10/util/BFloat16.h rename to runtime/core/portable_type/c10/c10/util/BFloat16.h diff --git a/runtime/core/portable_type/c10/util/Half-inl.h b/runtime/core/portable_type/c10/c10/util/Half-inl.h similarity index 100% rename from runtime/core/portable_type/c10/util/Half-inl.h rename to runtime/core/portable_type/c10/c10/util/Half-inl.h diff --git a/runtime/core/portable_type/c10/util/Half.h b/runtime/core/portable_type/c10/c10/util/Half.h similarity index 100% rename from runtime/core/portable_type/c10/util/Half.h rename to runtime/core/portable_type/c10/c10/util/Half.h diff --git a/runtime/core/portable_type/c10/util/TypeSafeSignMath.h b/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h similarity index 100% rename from runtime/core/portable_type/c10/util/TypeSafeSignMath.h rename to runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h diff --git a/runtime/core/portable_type/c10/util/bit_cast.h b/runtime/core/portable_type/c10/c10/util/bit_cast.h similarity index 100% rename from runtime/core/portable_type/c10/util/bit_cast.h rename to runtime/core/portable_type/c10/c10/util/bit_cast.h diff --git a/runtime/core/portable_type/c10/util/floating_point_utils.h b/runtime/core/portable_type/c10/c10/util/floating_point_utils.h similarity index 100% rename from runtime/core/portable_type/c10/util/floating_point_utils.h rename to runtime/core/portable_type/c10/c10/util/floating_point_utils.h diff --git a/runtime/core/portable_type/targets.bzl b/runtime/core/portable_type/targets.bzl index 725418cb4ea..43efeca208c 100644 --- a/runtime/core/portable_type/targets.bzl +++ b/runtime/core/portable_type/targets.bzl @@ -52,7 +52,7 @@ def define_common_targets(): "bits_types.h", ], exported_deps = [ - "//executorch/runtime/core/portable_type/c10:c10", + "//executorch/runtime/core/portable_type/c10/c10:c10", ], visibility = [ "//executorch/extension/...", diff --git a/runtime/core/portable_type/test/CMakeLists.txt b/runtime/core/portable_type/test/CMakeLists.txt index 6922a8c8fa9..f21e4fc791c 100644 --- a/runtime/core/portable_type/test/CMakeLists.txt +++ b/runtime/core/portable_type/test/CMakeLists.txt @@ -19,8 +19,14 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) include(${EXECUTORCH_ROOT}/build/Test.cmake) -set(_test_srcs optional_test.cpp tensor_test.cpp half_test.cpp scalar_test.cpp - tensor_impl_test.cpp bfloat16_test.cpp +set(_test_srcs + bfloat16_test.cpp + dont_shadow_complex_test.c + half_test.cpp + optional_test.cpp + scalar_test.cpp + tensor_impl_test.cpp + tensor_test.cpp ) et_cxx_test(runtime_core_portable_type_test SOURCES ${_test_srcs} EXTRA_LIBS) diff --git a/runtime/core/portable_type/test/dont_shadow_complex_test.c b/runtime/core/portable_type/test/dont_shadow_complex_test.c new file mode 100644 index 00000000000..56542166456 --- /dev/null +++ b/runtime/core/portable_type/test/dont_shadow_complex_test.c @@ -0,0 +1,9 @@ +// This include statement should get the C99 standard header +// complex.h. At one point we messed up our c10 include setup such +// that it instead included runtime/core/portable_type/complex.h. This +// is a regression test for that issue. +#include + +#ifndef complex +#warning "complex.h does not define complex" +#endif diff --git a/test/utils/OSSTestConfig.json b/test/utils/OSSTestConfig.json index 2229b255401..6eff74eec86 100644 --- a/test/utils/OSSTestConfig.json +++ b/test/utils/OSSTestConfig.json @@ -61,12 +61,13 @@ { "directory": "runtime/core/portable_type/test", "sources": [ - "optional_test.cpp", - "tensor_test.cpp", + "bfloat16_test.cpp", + "dont_shadow_complex_test.c", "half_test.cpp", + "optional_test.cpp", "scalar_test.cpp", "tensor_impl_test.cpp", - "bfloat16_test.cpp" + "tensor_test.cpp" ] }, {