Cleanup since FEATURE_TORCH_MOBILE is always true. (#55835)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55835
Now that https://github.com/pytorch/pytorch/pull/55238 is landed for a
week and no complains. It seems safe to say FEATURE_TORCH_MOBILE is
always true and we can do some cleanup.
Test Plan: Imported from OSS
Reviewed By: ezyang, walterddr
Differential Revision: D27721284
Pulled By: ailzhang
fbshipit-source-id: 4896bc5f736373d0922cfbe8eed0d16df62f0fa1
diff --git a/BUILD.bazel b/BUILD.bazel
index fc49fe4..d9a42cb 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -33,7 +33,6 @@
out = "c10/macros/cmake_macros.h",
substitutions = {
"cmakedefine": "define",
- "#define FEATURE_TORCH_MOBILE": "/* #undef FEATURE_TORCH_MOBILE */",
"#define C10_USE_NUMA": "/* #undef C10_USE_NUMA */",
},
)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8eaf138..2e5f572 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -511,7 +511,6 @@
set(BUILD_PYTHON OFF)
set(BUILD_CAFFE2_OPS OFF)
set(USE_DISTRIBUTED OFF)
- set(FEATURE_TORCH_MOBILE ON)
set(NO_API ON)
set(USE_FBGEMM OFF)
set(USE_QNNPACK OFF)
diff --git a/aten/src/ATen/VmapMode.cpp b/aten/src/ATen/VmapMode.cpp
index c692d8e..4f0a241 100644
--- a/aten/src/ATen/VmapMode.cpp
+++ b/aten/src/ATen/VmapMode.cpp
@@ -3,12 +3,6 @@
namespace at {
namespace impl {
-/// thread_local is a feature that is not enabled by Caffe2 mobile
-/// build (e.g. iOS). Therefore, we only provide `at::VmapMode`
-/// when we are not in mobile build or when FEATURE_TORCH_MOBILE
-/// is on.
-#if !defined(C10_MOBILE) || defined(FEATURE_TORCH_MOBILE)
-
thread_local int64_t VmapMode_current_vmap_level = 0;
int64_t VmapMode::current_vmap_level() {
@@ -30,22 +24,5 @@
}
return VmapMode_current_vmap_level;
}
-
-#else
-
-int64_t VmapMode::current_nesting_level() {
- TORCH_CHECK(false, "VmapMode is not supported on mobile");
-}
-
-int64_t VmapMode::increment_nesting() {
- TORCH_CHECK(false, "VmapMode is not supported on mobile");
-}
-
-int64_t VmapMode::decrement_nesting() {
- TORCH_CHECK(false, "VmapMode is not supported on mobile");
-}
-
-#endif
-
} // namespace impl
} // namespace at
diff --git a/aten/src/ATen/core/grad_mode.cpp b/aten/src/ATen/core/grad_mode.cpp
index 87473ca..a3a7788 100644
--- a/aten/src/ATen/core/grad_mode.cpp
+++ b/aten/src/ATen/core/grad_mode.cpp
@@ -4,12 +4,6 @@
namespace at {
-/// thread_local is a feature that is not enabled by Caffe2 mobile
-/// build (e.g. iOS). Therefore, we only provide `at::GradMode`
-/// when we are not in mobile build or when FEATURE_TORCH_MOBILE
-/// is on.
-#if !defined(C10_MOBILE) || defined(FEATURE_TORCH_MOBILE)
-
thread_local bool GradMode_enabled = true;
bool GradMode::is_enabled() {
@@ -19,17 +13,4 @@
void GradMode::set_enabled(bool enabled) {
GradMode_enabled = enabled;
}
-
-#else
-
-bool GradMode::is_enabled() {
- return false;
-}
-
-void GradMode::set_enabled(bool enabled) {
- throw std::runtime_error("GradMode::set_enabled is not supported on mobile");
-}
-
-#endif
-
} // namespace at
diff --git a/aten/src/ATen/core/interned_strings.h b/aten/src/ATen/core/interned_strings.h
index c0e3f6d..8692013 100644
--- a/aten/src/ATen/core/interned_strings.h
+++ b/aten/src/ATen/core/interned_strings.h
@@ -7,13 +7,10 @@
#include <c10/macros/Macros.h>
-#if !defined(C10_MOBILE) || defined(FEATURE_TORCH_MOBILE)
#include <ATen/core/aten_interned_strings.h>
-#endif
namespace c10 {
-#if !defined(C10_MOBILE) || defined(FEATURE_TORCH_MOBILE)
#define FORALL_NS_SYMBOLS(_) \
_(namespaces, prim) \
_(namespaces, aten) \
@@ -425,19 +422,6 @@
_(attr, cache_id) \
_(attr, new_axis) \
_(attr, warn_id)
-#else
-#define FORALL_NS_SYMBOLS(_) \
- _(namespaces, prim) \
- _(namespaces, aten) \
- _(namespaces, cuda) \
- _(namespaces, onnx) \
- _(namespaces, attr) \
- _(namespaces, scope) \
- _(namespaces, user) \
- _(namespaces, _caffe2) \
- _(namespaces, dimname) \
- _(namespaces, namespaces)
-#endif
// 'prim' symbols are synthetic operators that occur only in the IR
// and don't have corresponding implementations in ATen.
diff --git a/c10/macros/cmake_macros.h.in b/c10/macros/cmake_macros.h.in
index 2845fa1..a1e4fd8 100644
--- a/c10/macros/cmake_macros.h.in
+++ b/c10/macros/cmake_macros.h.in
@@ -10,9 +10,4 @@
#cmakedefine C10_USE_NUMA
#cmakedefine C10_USE_MSVC_STATIC_RUNTIME
-// Used by libtorch mobile build to enable features that are not enabled by
-// caffe2 mobile build. Should only use it when necessary as we are committed
-// to converging libtorch and caffe2 mobile builds and removing it eventually.
-#cmakedefine FEATURE_TORCH_MOBILE
-
#endif // C10_MACROS_CMAKE_MACROS_H_