diff --git a/CMakeLists.txt b/CMakeLists.txt index 156fb24e6b6..bf829951b01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,7 +324,9 @@ message(STATUS "Using python executable '${PYTHON_EXECUTABLE}'") set(_common_compile_options -Wno-deprecated-declarations -fPIC) # Let files say "include ". -set(_common_include_directories ${CMAKE_CURRENT_SOURCE_DIR}/..) +find_package(Torch CONFIG REQUIRED) + +set(_common_include_directories ${CMAKE_CURRENT_SOURCE_DIR}/.. ${TORCH_INCLUDE_DIRS}) # # The `__srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}. @@ -680,7 +682,6 @@ if(EXECUTORCH_BUILD_PYBIND) endif() # find pytorch lib, to allow pybind to take at::Tensor as input/output - find_package(Torch CONFIG REQUIRED) find_library( TORCH_PYTHON_LIBRARY torch_python PATHS "${TORCH_INSTALL_PREFIX}/lib" ) diff --git a/runtime/platform/compiler.h b/runtime/platform/compiler.h index 2ef2c62e4b4..1430518b0b7 100644 --- a/runtime/platform/compiler.h +++ b/runtime/platform/compiler.h @@ -13,6 +13,8 @@ #pragma once +#include + /* * Compiler support checks. Follows the logic used by pytorch/c10/util/C++17.h * but may support older versions. @@ -55,9 +57,9 @@ */ #define ET_NORETURN [[noreturn]] -#define ET_NOINLINE __attribute__((noinline)) -#define ET_INLINE __attribute__((always_inline)) inline -#define ET_INLINE_ATTRIBUTE __attribute__((always_inline)) +#define ET_NOINLINE C10_NOINLINE +#define ET_INLINE C10_ALWAYS_INLINE +#define ET_INLINE_ATTRIBUTE C10_ALWAYS_INLINE_ATTRIBUTE #if defined(__GNUC__) @@ -88,14 +90,14 @@ // do something // } #if (__cplusplus) >= 202002L - +// TODO: backport these to c10 and remove ET definition #define ET_LIKELY(expr) (expr) [[likely]] #define ET_UNLIKELY(expr) (expr) [[unlikely]] #else -#define ET_LIKELY(expr) (expr) -#define ET_UNLIKELY(expr) (expr) +#define ET_LIKELY(expr) C10_LIKELY(expr) +#define ET_UNLIKELY(expr) C10_UNLIKELY(expr) #endif // (__cplusplus) >= 202002L diff --git a/runtime/platform/targets.bzl b/runtime/platform/targets.bzl index 42bb851e2cf..6c2dfe664a8 100644 --- a/runtime/platform/targets.bzl +++ b/runtime/platform/targets.bzl @@ -122,6 +122,9 @@ def define_common_targets(): exported_headers = [ "compiler.h", ], + exported_deps = [ + "//caffe2/c10:c10", + ] if not runtime.is_oss else [], visibility = [ "//executorch/...", "@EXECUTORCH_CLIENTS",