Skip to content

Commit 35c82db

Browse files
Natalia Gimelsheinfacebook-github-bot
authored andcommitted
[THC] remove TensorTypeUtils and TensorInfo (#64965)
Summary: per title Pull Request resolved: #64965 Reviewed By: mruberry Differential Revision: D30916754 Pulled By: ngimel fbshipit-source-id: b24020d6a7ce8a05a5ab6c579d176dd94dd3b1d7
1 parent 816048e commit 35c82db

File tree

8 files changed

+4
-407
lines changed

8 files changed

+4
-407
lines changed

aten/src/ATen/native/cuda/IndexKernel.cu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <ATen/native/cuda/Loops.cuh>
1717
#include <ATen/native/cuda/KernelUtils.cuh>
1818
#include <c10/util/MaybeOwned.h>
19-
#include <THC/THCTensorInfo.cuh>
2019

2120
namespace at { namespace native {
2221

aten/src/ATen/native/cuda/Indexing.cu

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include <THC/THCDeviceUtils.cuh>
1616
#include <THC/THCGeneral.h>
17-
#include <THC/THCTensorInfo.cuh>
1817
#include <ATen/cuda/CUDAContext.h>
1918
#include <ATen/cuda/cub.cuh>
2019
#include <c10/util/irange.h>
@@ -479,9 +478,9 @@ Tensor& index_add_cuda_(Tensor & self, int64_t dim, const Tensor & index, const
479478
Tensor self_ = (self.dim() == 0) ? self.view(1) : self;
480479
Tensor source_ = (source.dim() == 0) ? source.view(1) : source;
481480

482-
TORCH_CHECK(self.dim() <= MAX_CUTORCH_DIMS, CUTORCH_DIM_WARNING);
483-
TORCH_CHECK(source.dim() <= MAX_CUTORCH_DIMS, CUTORCH_DIM_WARNING);
484-
TORCH_CHECK(index.dim() <= MAX_CUTORCH_DIMS, CUTORCH_DIM_WARNING);
481+
TORCH_CHECK(self.dim() <= MAX_TENSORINFO_DIMS, "tensor has too many (>", MAX_TENSORINFO_DIMS, ") dims");
482+
TORCH_CHECK(source.dim() <= MAX_TENSORINFO_DIMS, "tensor has too many (>", MAX_TENSORINFO_DIMS, ") dims" );
483+
TORCH_CHECK(index.dim() <= MAX_TENSORINFO_DIMS, "tensor has too many (>", MAX_TENSORINFO_DIMS, ") dims");
485484

486485
at::assert_no_internal_overlap(self);
487486
at::assert_no_partial_overlap(self, index);

aten/src/THC/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ install(FILES
5757
THCGenerateComplexDoubleType.h
5858
THCIntegerDivider.cuh
5959
THCNumerics.cuh
60-
THCTensorInfo.cuh
61-
THCTensorTypeUtils.cuh
6260
THCThrustAllocator.cuh
6361
# See Note [TH abstraction violation]
6462
THCTensor.hpp

aten/src/THC/THCTensor.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include <THC/generic/THCTensor.cpp>
1717
#include <THC/THCGenerateBFloat16Type.h>
1818

19-
#include <THC/THCTensorInfo.cuh>
20-
2119
#include <ATen/native/cuda/Resize.cuh>
2220

2321
int THCTensor_nDimension(THCState *state, const THCTensor *self) {
@@ -326,51 +324,3 @@ int compareSizeAndStride(const void* a, const void* b) {
326324
}
327325

328326
}
329-
330-
/* Returns false if there is no possibility that the tensor */
331-
/* has "overlapping" indices and true otherwise. */
332-
/* "Overlapping" indices are two+ valid indices that specify */
333-
/* the same offset within the tensor. */
334-
/* The function does this by checking for a sufficient but not */
335-
/* necessary condition of no overlap. In particular, that */
336-
/* that there exists an ordering of the tensor's dimensions */
337-
/* that is nicely "nested," with each dimension contained */
338-
/* within the next one. */
339-
bool THCTensor_maybeOverlappingIndices(THCState* state, const THCTensor* t) {
340-
/* Extract size/stride arrays; only consider size >1 dims. */
341-
SizeAndStride info[MAX_CUTORCH_DIMS];
342-
343-
int dims = THCTensor_nDimensionLegacyAll(state, t);
344-
int nonSize1Dims = 0;
345-
for (int i = 0; i < dims; ++i) {
346-
int64_t size = THCTensor_sizeLegacyNoScalars(state, t, i);
347-
348-
if (size > 1) {
349-
info[nonSize1Dims].size = size;
350-
info[nonSize1Dims].stride =
351-
THCTensor_stride(state, t, i);
352-
353-
if (info[nonSize1Dims].stride < 1) {
354-
return true;
355-
}
356-
357-
++nonSize1Dims;
358-
}
359-
}
360-
361-
/* Short-circuits if tensor is a single element. */
362-
if (nonSize1Dims == 0) {
363-
return false;
364-
}
365-
366-
/* Ascending order (innermost dimension in sorted view is at [0]) */
367-
qsort(info, nonSize1Dims, sizeof(SizeAndStride), compareSizeAndStride);
368-
369-
for (int i = 0; i < (nonSize1Dims - 1); ++i) {
370-
if (((info[i].size - 1) * info[i].stride) >= info[i + 1].stride) {
371-
return true;
372-
}
373-
}
374-
375-
return false;
376-
}

aten/src/THC/THCTensor.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ TORCH_CUDA_CU_API void THCTensor_preserveReduceDimSemantics(
110110
int in_dims,
111111
int64_t dimension,
112112
int keepdim);
113-
/* Returns false if there is no possibility that the tensor */
114-
/* has more than one index that references the same datapoint, */
115-
/* true otherwise. */
116-
TORCH_CUDA_CU_API bool THCTensor_maybeOverlappingIndices(
117-
THCState* state,
118-
const THCTensor* t);
119113

120114
#include <THC/generic/THCTensor.hpp>
121115
#include <THC/THCGenerateAllTypes.h>

aten/src/THC/THCTensorCopy.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <THC/THCTensorTypeUtils.cuh>
1+
#include <THC/THCTensor.hpp>
22
#include <THC/THCTensorCopy.h>
33
#include <THC/THCTensorCopy.hpp>
44

aten/src/THC/THCTensorInfo.cuh

Lines changed: 0 additions & 260 deletions
This file was deleted.

0 commit comments

Comments
 (0)