Kill `operator==` of TensorOptions as confusing one
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/28076
Test Plan: Imported from OSS
Differential Revision: D17980306
Pulled By: VitalyFedyunin
fbshipit-source-id: 2f206d5069ce0bd828d4e96f2e98cf2baa1dfec7
diff --git a/aten/src/ATen/native/TensorConversions.cpp b/aten/src/ATen/native/TensorConversions.cpp
index db46b8c..b257e61 100644
--- a/aten/src/ATen/native/TensorConversions.cpp
+++ b/aten/src/ATen/native/TensorConversions.cpp
@@ -23,7 +23,8 @@
auto memory_format =
optional_memory_format.value_or(MemoryFormat::Contiguous);
- if (self.options() == options && !copy &&
+ if (self.dtype() == options.dtype() && self.layout() == options.layout() &&
+ self.device() == options.device() && !copy &&
(memory_format == MemoryFormat::Preserve ||
self.suggest_memory_format() == memory_format)) {
return self;
diff --git a/c10/core/TensorOptions.h b/c10/core/TensorOptions.h
index 90eb7e2..7d20e45 100644
--- a/c10/core/TensorOptions.h
+++ b/c10/core/TensorOptions.h
@@ -144,25 +144,6 @@
this->set_dtype(dtype);
}
- /// True if all elements of the `TensorOptions` match that of the other.
- bool operator==(const TensorOptions& other) const noexcept {
- return
- has_dtype_ == other.has_dtype_ &&
- has_layout_ == other.has_layout_ &&
- has_device_ == other.has_device_ &&
- has_requires_grad_ == other.has_requires_grad_ &&
- (!has_dtype_ || dtype_ == other.dtype_) &&
- (!has_layout_ || layout_ == other.layout_) &&
- (!has_device_ || device_ == other.device_) &&
- (!requires_grad_ || requires_grad_ == other.requires_grad_);
- }
-
- /// True if any of the elements of this `TensorOptions` do not match that of
- /// the other.
- bool operator!=(const TensorOptions& other) const noexcept {
- return !(*this == other);
- }
-
/// Return a copy of `TensorOptions` with `device` set to the given one, or
/// cleared if `device` is `nullopt`.
C10_NODISCARD TensorOptions device(c10::optional<Device> device) const noexcept {