mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Revert D23490149: [pytorch][PR] Compile less legacy code when BUILD_CAFFE2 is set to False
Test Plan: revert-hammer
Differential Revision:
D23490149 (15e99b6ff6)
Original commit changeset: a76382c30d83
fbshipit-source-id: 75057fa9af2c19eb976962552118bf0a99911b38
This commit is contained in:
parent
618b4dd763
commit
d07a36e0c1
5 changed files with 8 additions and 34 deletions
|
|
@ -106,12 +106,10 @@ endif()
|
|||
add_subdirectory(core)
|
||||
add_subdirectory(serialize)
|
||||
add_subdirectory(utils)
|
||||
if(BUILD_CAFFE2)
|
||||
add_subdirectory(perfkernels)
|
||||
endif()
|
||||
add_subdirectory(perfkernels)
|
||||
|
||||
# Skip modules that are not used by libtorch mobile yet.
|
||||
if(BUILD_CAFFE2 AND (NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE))
|
||||
if(NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
||||
add_subdirectory(contrib)
|
||||
add_subdirectory(predictor)
|
||||
add_subdirectory(predictor/emulator)
|
||||
|
|
@ -149,9 +147,6 @@ if(BUILD_CAFFE2 AND (NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE))
|
|||
# add_subdirectory(test) # todo: use caffe2_gtest_main instead of gtest_main because we will need to call GlobalInit
|
||||
add_subdirectory(transforms)
|
||||
endif()
|
||||
if(NOT BUILD_CAFFE2)
|
||||
add_subdirectory(proto)
|
||||
endif()
|
||||
|
||||
# Advanced: if we have allow list specified, we will do intersections for all
|
||||
# main lib srcs.
|
||||
|
|
@ -468,21 +463,11 @@ if(NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
|||
${TORCH_SRC_DIR}/csrc/jit/serialization/onnx.cpp
|
||||
${TORCH_SRC_DIR}/csrc/jit/serialization/export.cpp
|
||||
${TORCH_SRC_DIR}/csrc/jit/serialization/export_module.cpp
|
||||
${TORCH_SRC_DIR}/csrc/jit/serialization/import_legacy.cpp
|
||||
${TORCH_SRC_DIR}/csrc/jit/codegen/fuser/cpu/fused_kernel.cpp
|
||||
${TORCH_SRC_DIR}/csrc/jit/api/module_save.cpp
|
||||
${TORCH_SRC_DIR}/csrc/utils/byte_order.cpp
|
||||
)
|
||||
# Disable legacy import of building without Caffe2 support
|
||||
if(BUILD_CAFFE2)
|
||||
list(APPEND TORCH_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/jit/serialization/import_legacy.cpp
|
||||
)
|
||||
else()
|
||||
set_source_files_properties(
|
||||
${TORCH_SRC_DIR}/csrc/jit/serialization/import.cpp
|
||||
PROPERTIES COMPILE_FLAGS "-DC10_DISABLE_LEGACY_IMPORT"
|
||||
)
|
||||
endif()
|
||||
if(USE_DISTRIBUTED)
|
||||
append_filelist("libtorch_distributed_sources" TORCH_SRCS)
|
||||
endif()
|
||||
|
|
@ -1396,7 +1381,6 @@ if(BUILD_PYTHON)
|
|||
endif()
|
||||
|
||||
# ---[ Python.
|
||||
if(BUILD_CAFFE2)
|
||||
add_library(caffe2_pybind11_state MODULE ${Caffe2_CPU_PYTHON_SRCS})
|
||||
if(NOT MSVC)
|
||||
set_target_properties(caffe2_pybind11_state PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
|
||||
|
|
@ -1508,7 +1492,6 @@ if(BUILD_PYTHON)
|
|||
# Create a custom target that copies all python files.
|
||||
file(GLOB_RECURSE PYTHON_SRCS RELATIVE ${PROJECT_SOURCE_DIR}
|
||||
"${PROJECT_SOURCE_DIR}/caffe2/*.py")
|
||||
endif()
|
||||
|
||||
# generated pb files are copied from build/caffe2 to caffe2
|
||||
# if we copied them back to build this would create a build cycle
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
if((NOT BUILD_CAFFE2) OR (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE))
|
||||
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
||||
list(APPEND Caffe2_CPU_SRCS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/common.cc"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
if(BUILD_CAFFE2)
|
||||
file(GLOB Caffe2_PROTOBUF_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.proto")
|
||||
else()
|
||||
set(Caffe2_PROTOBUF_FILES "${CMAKE_CURRENT_SOURCE_DIR}/torch.proto;${CMAKE_CURRENT_SOURCE_DIR}/caffe2.proto")
|
||||
endif()
|
||||
file(GLOB Caffe2_PROTOBUF_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.proto")
|
||||
|
||||
caffe2_protobuf_generate_cpp_py(Caffe2_PROTO_SRCS Caffe2_PROTO_HEADERS Caffe2_PROTO_PY ${Caffe2_PROTOBUF_FILES})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
if((NOT BUILD_CAFFE2) OR (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE))
|
||||
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
||||
list(APPEND Caffe2_CPU_SRCS
|
||||
utils/string_utils.cc
|
||||
utils/threadpool/pthreadpool-cpp.cc
|
||||
utils/threadpool/ThreadPool.cc
|
||||
)
|
||||
if(NOT BUILD_CAFFE2)
|
||||
list(APPEND Caffe2_CPU_SRCS
|
||||
utils/proto_wrap.cc
|
||||
)
|
||||
endif()
|
||||
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <ATen/core/ivalue_inl.h>
|
||||
#include <c10/util/Exception.h>
|
||||
#include <torch/csrc/jit/serialization/import_export_helpers.h>
|
||||
#if !defined(C10_MOBILE) && !defined(C10_DISABLE_LEGACY_IMPORT)
|
||||
#ifndef C10_MOBILE
|
||||
#include <torch/csrc/jit/serialization/import_legacy.h>
|
||||
#endif
|
||||
#include <torch/csrc/jit/frontend/script_type_parser.h>
|
||||
|
|
@ -256,7 +256,7 @@ Module ScriptModuleDeserializer::deserialize(
|
|||
}
|
||||
}
|
||||
if (reader_->hasRecord("model.json")) {
|
||||
#if !defined(C10_MOBILE) && !defined(C10_DISABLE_LEGACY_IMPORT)
|
||||
#ifndef C10_MOBILE
|
||||
return torch::jit::LEGACY_deserialize(
|
||||
compilation_unit_, std::move(reader_), device_);
|
||||
#else
|
||||
|
|
|
|||
Loading…
Reference in a new issue