Skip to content

Commit

Permalink
[libkineto] trying KINETO=off
Browse files Browse the repository at this point in the history
  • Loading branch information
luncliff committed Oct 24, 2024
1 parent cf7858d commit 8bfe3fd
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
39 changes: 39 additions & 0 deletions ports/libtorch/fix-cmake.patch
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,42 @@ index 257c0bd..4788bcf 100644

if(NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG ${OLD_CMAKE_C_FLAGS_DEBUG})
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8d3253c..7502685 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -781,7 +781,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

# The below means we are cross compiling for arm64 or x86_64 on MacOSX
-if(NOT IOS
+if(BUILD_CUSTOM_PROTOBUF AND NOT IOS
AND CMAKE_SYSTEM_NAME STREQUAL "Darwin"
AND CMAKE_OSX_ARCHITECTURES MATCHES "^(x86_64|arm64)$")
set(CROSS_COMPILING_MACOSX TRUE)
diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt
index b5aaeba..d55ffe7 100644
--- a/caffe2/CMakeLists.txt
+++ b/caffe2/CMakeLists.txt
@@ -88,7 +88,7 @@ endif()
# addressed yet.

if(NOT MSVC AND USE_XNNPACK)
- if(NOT TARGET fxdiv)
+ if(NOT TARGET fxdiv AND NOT USE_SYSTEM_FXDIV)
set(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
set(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
add_subdirectory(
@@ -399,6 +399,12 @@ list(APPEND LITE_PROFILER_SRCS "")
if(USE_LITE_INTERPRETER_PROFILER)
append_filelist("libtorch_edge_profiler_sources " LITE_PROFILER_SRCS)
endif()
+if(NOT USE_KINETO)
+ list(REMOVE_ITEM LITE_PROFILER_SRCS
+ "${TORCH_SRC_DIR}/csrc/profiler/kineto_shim.cpp"
+ "${TORCH_SRC_DIR}/csrc/autograd/profiler_kineto.cpp"
+ )
+endif()

# Switch between the full jit interpreter and lite interpreter
if(BUILD_LITE_INTERPRETER)
29 changes: 29 additions & 0 deletions ports/libtorch/fix-sources.patch
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,32 @@ index 9e8a995..2c54558 100644
#include <chrono>
#include <cmath>
#include <fstream>
diff --git a/c10/util/Logging.cpp b/c10/util/Logging.cpp
index b328d25..ab58966 100644
--- a/c10/util/Logging.cpp
+++ b/c10/util/Logging.cpp
@@ -257,23 +257,13 @@ C10_DEFINE_int(
google::GLOG_WARNING,
"The minimum log level that caffe2 will output.");

-// Google glog's api does not have an external function that allows one to check
-// if glog is initialized or not. It does have an internal function - so we are
-// declaring it here. This is a hack but has been used by a bunch of others too
-// (e.g. Torch).
-namespace google {
-namespace glog_internal_namespace_ {
-bool IsGoogleLoggingInitialized();
-} // namespace glog_internal_namespace_
-} // namespace google
-
namespace c10 {
namespace {

void initGoogleLogging(char const* name) {
#if !defined(_MSC_VER)
// This trick can only be used on UNIX platforms
- if (!::google::glog_internal_namespace_::IsGoogleLoggingInitialized())
+ if (!::google::IsGoogleLoggingInitialized())
#endif
{
::google::InitGoogleLogging(name);
9 changes: 8 additions & 1 deletion ports/libtorch/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ find_path(SITE_PACKAGES_DIR
PATHS "${PYTHON_ROOT}/Lib/site-packages"
"${PYTHON_ROOT}/lib/python3.11/site-packages"
"${PYTHON_ROOT}/lib/python3.12/site-packages"
"${PYTHON_ROOT}/lib/python3.13/site-packages"
REQUIRED
)
get_filename_component(pybind11_DIR "${SITE_PACKAGES_DIR}/pybind11/share/cmake/pybind11" ABSOLUTE)
Expand Down Expand Up @@ -104,6 +105,12 @@ else()
set(IS_APPLE OFF)
endif()

if(VCPKG_TARGET_IS_OSX)
set(KINETO_AVAILABLE OFF)
else()
set(KINETO_AVAILABLE ON)
endif()

string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME)

vcpkg_cmake_configure(
Expand All @@ -126,7 +133,7 @@ vcpkg_cmake_configure(
-DUSE_XNNPACK=ON
-DUSE_ITT=OFF
-DUSE_OBSERVERS=OFF
-DUSE_KINETO=ON
-DUSE_KINETO=${KINETO_AVAILABLE}
-DUSE_LITE_INTERPRETER_PROFILER=OFF
-DBUILD_LITE_INTERPRETER=OFF
-DUSE_NUMA=${VCPKG_TARGET_IS_LINUX}
Expand Down

0 comments on commit 8bfe3fd

Please sign in to comment.