Skip to content

Commit f5493c4

Browse files
committed
Revert "Grid sampler: nearest interpolation & reflection padding (#10051)"
This reverts commit 6a55238.
1 parent 3efc089 commit f5493c4

File tree

15 files changed

+1042
-1404
lines changed

15 files changed

+1042
-1404
lines changed

aten/src/ATen/Device.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ Device::Device(const std::string& device_string) : Device(Type::CPU) {
7575
}
7676
}
7777

78+
} // namespace at
79+
7880
std::ostream& operator<<(std::ostream& stream, const at::Device& device) {
7981
stream << device.type();
8082
if (device.has_index()) {
8183
stream << ":" << device.index();
8284
}
8385
return stream;
8486
}
85-
86-
} // namespace at

aten/src/ATen/Device.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,9 @@ struct Device {
111111
DeviceType type_;
112112
int32_t index_ = -1;
113113
};
114-
115-
AT_API std::ostream& operator<<(std::ostream& stream, const at::Device& device);
116-
117114
} // namespace at
118115

116+
AT_API std::ostream& operator<<(std::ostream& stream, const at::Device& device);
119117

120118
namespace std {
121119
template<> struct hash<at::Device>

aten/src/ATen/Layout.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ inline Layout layout_from_backend(Backend backend) {
2020
return Layout::Strided;
2121
}
2222
}
23+
} // namespace at
2324

2425
inline std::ostream& operator<<(std::ostream& stream, at::Layout layout) {
2526
switch (layout) {
@@ -31,5 +32,3 @@ inline std::ostream& operator<<(std::ostream& stream, at::Layout layout) {
3132
AT_ERROR("Unknown layout");
3233
}
3334
}
34-
35-
} // namespace at

aten/src/ATen/TensorGeometry.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
namespace at {
66

77
bool TensorGeometry::is_contiguous() const {
8-
if (numel_ == 0) {
9-
return true;
10-
}
118
int64_t dim = sizes_.size();
129
int64_t expected_stride = 1;
1310
for (int64_t i = dim - 1; i >= 0; i--) {

aten/src/ATen/TensorGeometry.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ struct AT_API TensorGeometry {
1818
strides_[i] = expected_stride;
1919
expected_stride *= sizes_[i];
2020
}
21-
numel_ = expected_stride;
2221
}
2322

2423
explicit TensorGeometry(const Tensor& t)
2524
: sizes_(t.sizes().vec())
2625
, strides_(t.strides().vec())
27-
, storage_offset_(t.storage_offset())
28-
, numel_(t.numel()) {}
26+
, storage_offset_(t.storage_offset()) {}
2927

3028
// true if the tensor is contiguous
3129
bool is_contiguous() const;
@@ -45,7 +43,13 @@ struct AT_API TensorGeometry {
4543
}
4644
IntList strides() const { return IntList{ strides_ }; }
4745
int64_t storage_offset() const { return storage_offset_; }
48-
int64_t numel() const { return numel_; }
46+
int64_t numel() const {
47+
int64_t r = 1;
48+
for (auto s : sizes()) {
49+
r *= s;
50+
}
51+
return r;
52+
}
4953

5054
TensorGeometry transpose(int64_t dim0, int64_t dim1) {
5155
TensorGeometry r = *this; // copy
@@ -59,7 +63,6 @@ struct AT_API TensorGeometry {
5963
std::vector<int64_t> sizes_;
6064
std::vector<int64_t> strides_;
6165
int64_t storage_offset_;
62-
int64_t numel_;
6366
};
6467

6568
} // namespace at

aten/src/ATen/TensorUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void checkSameGPU(CheckedFrom c, const TensorArg& t1, const TensorArg& t2) {
118118
oss << "Tensor for " << t2 << " is on CPU, ";
119119
}
120120
oss << "but expected " << ((!(t1->is_cuda() || t2->is_cuda())) ? "them" : "it")
121-
<< " to be on GPU (while checking arguments for " << c << ")";
121+
<< " to be on GPU (while checking arguments for " << c << ")";
122122
AT_ERROR(oss.str());
123123
}
124124
AT_CHECK(

aten/src/ATen/core/DeviceType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ std::string DeviceTypeName(at::DeviceType d, bool lower_case) {
3434
}
3535
}
3636

37+
} // namespace at
38+
3739
std::ostream& operator<<(std::ostream& stream, at::DeviceType type) {
3840
stream << at::DeviceTypeName(type, /* lower case */ true);
3941
return stream;
4042
}
41-
42-
} // namespace at

aten/src/ATen/core/DeviceType.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ AT_CORE_API std::string DeviceTypeName(
2727
at::DeviceType d,
2828
bool lower_case = false);
2929

30-
AT_CORE_API std::ostream& operator<<(std::ostream& stream, at::DeviceType type);
31-
3230
} // namespace at
31+
32+
AT_CORE_API std::ostream& operator<<(std::ostream& stream, at::DeviceType type);

aten/src/ATen/cuda/detail/KernelUtils.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#pragma once
2-
3-
#include "ATen/ATen.h"
4-
52
// Contents of this file are copied from THCUNN/common.h for the ease of porting
63
// THCUNN functions into ATen.
74

@@ -17,7 +14,6 @@ constexpr int CUDA_NUM_THREADS = 1024;
1714
// CUDA: number of blocks for threads.
1815
inline int GET_BLOCKS(const int N)
1916
{
20-
AT_ASSERTM(N > 0, "CUDA kernel launch blocks must be positive, but got N=", N);
2117
return (N + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS;
2218
}
2319

0 commit comments

Comments
 (0)