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
This commit is contained in:
Vitaly Fedyunin 2019-11-18 05:32:23 -08:00 committed by Facebook Github Bot
parent 9f3b347874
commit 026a2a4ec4
2 changed files with 2 additions and 20 deletions

View File

@ -23,7 +23,8 @@ static inline Tensor to_impl(const Tensor& self, const TensorOptions& options, b
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;

View File

@ -144,25 +144,6 @@ struct C10_API TensorOptions {
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 {