From 87a75bd6050723833ca11b995c7b8fcd462277e0 Mon Sep 17 00:00:00 2001 From: Tao Xu Date: Wed, 31 Jul 2019 10:26:58 -0700 Subject: [PATCH] remove ONNX & Turn on `NO_API` for mobile build (#23546) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: ### Summary The iOS build was broken after this PR 👉 [23195](https://github.com/pytorch/pytorch/pull/23195/files) was merged, as there are two files still have dependency on ONNX. - `test.cpp` in `test/cpp/jit` - `export.cpp` in `torch/csrc/jit` This PR is to remove ONNX completely from mobile build. Pull Request resolved: https://github.com/pytorch/pytorch/pull/23546 Test Plan: - The `build_ios.sh` finished successfully. - The `libtorch.a` can be compiled and run on iOS devices Differential Revision: D16558236 Pulled By: xta0 fbshipit-source-id: b7ff1db750698cfd5a72d5cb0b9f2f378e315077 --- CMakeLists.txt | 1 + caffe2/CMakeLists.txt | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7657b0c7b17..8018d9a63a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,6 +221,7 @@ if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE) set(BUILD_CAFFE2_OPS OFF) set(USE_DISTRIBUTED OFF) set(FEATURE_TORCH_MOBILE ON) + set(NO_API ON) endif() if (BUILD_ATEN_ONLY) diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt index baf030dfb90..3e0d93d54f3 100644 --- a/caffe2/CMakeLists.txt +++ b/caffe2/CMakeLists.txt @@ -366,7 +366,6 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE) ${TORCH_SRC_DIR}/csrc/jit/autodiff.cpp ${TORCH_SRC_DIR}/csrc/jit/attributes.cpp ${TORCH_SRC_DIR}/csrc/jit/argument_spec.cpp - ${TORCH_SRC_DIR}/csrc/jit/export.cpp ${TORCH_SRC_DIR}/csrc/jit/pass_manager.cpp ${TORCH_SRC_DIR}/csrc/jit/pickler.cpp ${TORCH_SRC_DIR}/csrc/jit/graph_executor.cpp @@ -430,7 +429,6 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE) ${TORCH_SRC_DIR}/csrc/jit/register_special_ops.cpp ${TORCH_SRC_DIR}/csrc/jit/scope.cpp ${TORCH_SRC_DIR}/csrc/jit/script/compiler.cpp - ${TORCH_SRC_DIR}/csrc/api/src/jit.cpp ${TORCH_SRC_DIR}/csrc/jit/testing/file_check.cpp ${TORCH_SRC_DIR}/csrc/jit/script/convert_to_ssa.cpp ${TORCH_SRC_DIR}/csrc/jit/script/exit_transforms.cpp @@ -457,14 +455,19 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE) ${TORCH_SRC_DIR}/csrc/jit/fuser/codegen.cpp ${TORCH_SRC_DIR}/csrc/jit/fuser/fallback.cpp ${TORCH_SRC_DIR}/csrc/jit/function.cpp - ${TORCH_ROOT}/test/cpp/jit/test.cpp ) - if (NOT WIN32 AND NOT INTERN_BUILD_MOBILE) - list(APPEND TORCH_SRCS - ${TORCH_SRC_DIR}/csrc/jit/fuser/cpu/fused_kernel.cpp + if (NOT INTERN_BUILD_MOBILE) + list(APPEND TORCH_SRCS + ${TORCH_SRC_DIR}/csrc/api/src/jit.cpp + ${TORCH_SRC_DIR}/csrc/jit/export.cpp + ${TORCH_ROOT}/test/cpp/jit/test.cpp ) - endif () + if (NOT WIN32) + list(APPEND TORCH_SRCS + ${TORCH_SRC_DIR}/csrc/jit/fuser/cpu/fused_kernel.cpp) + endif() + endif() if (USE_CUDA) if (NOT USE_ROCM)