Revert D33172665: [LTC] Upstream utils to extract BackendDevice from at::Tensor
Test Plan: revert-hammer
Differential Revision:
D33172665 (https://github.com/pytorch/pytorch/commit/121d06799954b0c0ba24f084f2d78b1a81a4e4ec)
Original commit changeset: b334ee358ea7
Original Phabricator Diff: D33172665 (https://github.com/pytorch/pytorch/commit/121d06799954b0c0ba24f084f2d78b1a81a4e4ec)
fbshipit-source-id: 8bff43cddfc5d30483ec5cea8eff037aab9d1cfa
diff --git a/test/cpp/lazy/test_backend_device.cpp b/test/cpp/lazy/test_backend_device.cpp
index 46d4640..cd738b2 100644
--- a/test/cpp/lazy/test_backend_device.cpp
+++ b/test/cpp/lazy/test_backend_device.cpp
@@ -4,7 +4,6 @@
#include <c10/core/Device.h>
#include <torch/csrc/lazy/backend/backend_device.h>
-#include <torch/torch.h>
namespace torch {
namespace lazy {
@@ -86,17 +85,5 @@
EXPECT_EQ(device.index(), 0);
}
-// TODO(alanwaketan): Update the following test once we have TorchScript backend upstreamed.
-TEST(BackendDeviceTest, GetBackendDevice1) {
- auto tensor = torch::rand({0, 1, 3, 0});
- EXPECT_FALSE(GetBackendDevice(tensor));
-}
-
-TEST(BackendDeviceTest, GetBackendDevice2) {
- auto tensor1 = torch::rand({0, 1, 3, 0});
- auto tensor2 = torch::rand({0, 1, 3, 0});
- EXPECT_FALSE(GetBackendDevice(tensor1, tensor2));
-}
-
} // namespace lazy
} // namespace torch
diff --git a/torch/csrc/lazy/backend/backend_device.cpp b/torch/csrc/lazy/backend/backend_device.cpp
index 5259efb..6e5f07c 100644
--- a/torch/csrc/lazy/backend/backend_device.cpp
+++ b/torch/csrc/lazy/backend/backend_device.cpp
@@ -3,7 +3,6 @@
#include <c10/core/Device.h>
#include <c10/util/Exception.h>
#include <c10/util/StringUtil.h>
-#include <torch/csrc/lazy/core/tensor.h>
#include <torch/csrc/lazy/backend/backend_interface.h>
namespace torch {
@@ -54,16 +53,5 @@
return c10::Device(at::kLazy, device.ordinal());
}
-c10::optional<BackendDevice> GetBackendDevice(const at::Tensor& tensor) {
- if (auto lt = TryGetLtcTensor(tensor)) {
- return lt.GetDevice();
- }
- return c10::nullopt;
-}
-
-c10::optional<BackendDevice> GetBackendDevice() {
- return c10::nullopt;
-}
-
} // namespace lazy
} // namespace torch
diff --git a/torch/csrc/lazy/backend/backend_device.h b/torch/csrc/lazy/backend/backend_device.h
index 4c14f3c..d31481f 100644
--- a/torch/csrc/lazy/backend/backend_device.h
+++ b/torch/csrc/lazy/backend/backend_device.h
@@ -4,10 +4,8 @@
#include <memory>
#include <string>
-#include <ATen/Tensor.h>
#include <c10/macros/Export.h>
#include <c10/util/Deprecated.h>
-#include <c10/util/Optional.h>
namespace c10 {
struct Device;
@@ -57,21 +55,5 @@
TORCH_API BackendDevice atenDeviceToBackendDevice(const c10::Device& device);
TORCH_API c10::Device backendDeviceToAtenDevice(const BackendDevice& device);
-// Tries to extract the backend device out of the lazy tensor. Returns nullopt if the
-// input is not a lazy tensor.
-TORCH_API c10::optional<BackendDevice> GetBackendDevice(const at::Tensor& tensor);
-
-// For variadic template.
-c10::optional<BackendDevice> GetBackendDevice();
-
-template<typename T, typename... Args>
-TORCH_API c10::optional<BackendDevice> GetBackendDevice(const T& tensor, const Args&... forward_tensors) {
- auto optional_device = GetBackendDevice(tensor);
- if (optional_device) {
- return optional_device;
- }
- return GetBackendDevice(forward_tensors...);
-}
-
} // namespace lazy
} // namespace torch