Skip to content

Commit 0544a49

Browse files
ezyangfacebook-github-bot
authored andcommitted
Revert D15499749: [pytorch][PR] Add Tensor.T attribute to reverse dimensions
Differential Revision: D15499749 Original commit changeset: f3306b496667 fbshipit-source-id: 7f50431d2ea37bc41bfed62f386ddedea1412878
1 parent 3038cf8 commit 0544a49

File tree

11 files changed

+0
-49
lines changed

11 files changed

+0
-49
lines changed

aten/src/ATen/core/Tensor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ class CAFFE2_API Tensor {
465465
Tensor narrow_copy(int64_t dim, int64_t start, int64_t length) const;
466466
Tensor narrow(int64_t dim, int64_t start, int64_t length) const;
467467
Tensor permute(IntArrayRef dims) const;
468-
Tensor T() const;
469468
Tensor pin_memory() const;
470469
Tensor pinverse(double rcond=1e-15) const;
471470
Tensor reciprocal() const;

aten/src/ATen/core/TensorMethods.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,6 @@ inline Tensor Tensor::narrow(int64_t dim, int64_t start, int64_t length) const {
452452
inline Tensor Tensor::permute(IntArrayRef dims) const {
453453
return dispatch_type().permute(*this, dims);
454454
}
455-
inline Tensor Tensor::T() const {
456-
return dispatch_type().T(*this);
457-
}
458455
inline Tensor Tensor::pin_memory() const {
459456
return dispatch_type().pin_memory(*this);
460457
}

aten/src/ATen/core/Type.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ struct CAFFE2_API Type {
274274
virtual Tensor narrow_copy(const Tensor & self, int64_t dim, int64_t start, int64_t length) const = 0;
275275
virtual Tensor narrow(const Tensor & self, int64_t dim, int64_t start, int64_t length) const = 0;
276276
virtual Tensor permute(const Tensor & self, IntArrayRef dims) const = 0;
277-
virtual Tensor T(const Tensor & self) const = 0;
278277
virtual Tensor pin_memory(const Tensor & self) const = 0;
279278
virtual Tensor pinverse(const Tensor & self, double rcond) const = 0;
280279
virtual Tensor reciprocal(const Tensor & self) const = 0;

aten/src/ATen/native/TensorShape.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -853,17 +853,6 @@ std::vector<Tensor> meshgrid(TensorList tensors) {
853853
}
854854
return grids;
855855
}
856-
857-
// Numpy-style `a.T`: returns the tensor
858-
// with dims reversed
859-
Tensor T(const Tensor &self) {
860-
int64_t n = self.dim();
861-
DimVector transpose_dims;
862-
for (int64_t i = n - 1; i >= 0; --i) {
863-
transpose_dims.push_back(i);
864-
}
865-
return self.permute(transpose_dims);
866-
}
867856
}
868857

869858
}

aten/src/ATen/native/native_functions.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,9 +1405,6 @@
14051405
- func: permute(Tensor(a) self, int[] dims) -> Tensor(a)
14061406
variants: method # This is method-only to match the previous tensor API. In the future we could make this a function too.
14071407

1408-
- func: T(Tensor(a) self) -> Tensor(a)
1409-
variants: method
1410-
14111408
- func: pixel_shuffle(Tensor self, int upscale_factor) -> Tensor
14121409

14131410
- func: pin_memory(Tensor self) -> Tensor

docs/source/tensors.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ view of a storage and defines numeric operations on it.
148148
.. autoattribute:: device
149149
.. autoattribute:: grad
150150
.. autoattribute:: ndim
151-
.. autoattribute:: T
152151

153152
.. automethod:: abs
154153
.. automethod:: abs_

test/test_torch.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11523,16 +11523,6 @@ def test_ndim(self):
1152311523
c = torch.randn(1, 0)
1152411524
self.assertEqual(2, c.ndim)
1152511525

11526-
def test_T(self):
11527-
a = torch.randn(2, 3, 4)
11528-
t1 = a.T
11529-
t2 = a.permute(2, 1, 0)
11530-
self.assertEqual(t2, t1)
11531-
b = torch.randn(10)
11532-
self.assertEqual(b, b.T)
11533-
scalar = torch.tensor(5)
11534-
self.assertEqual(scalar, scalar.T)
11535-
1153611526
# Functions to test negative dimension wrapping
1153711527
METHOD = 1
1153811528
INPLACE_METHOD = 2

tools/autograd/gen_autograd.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
# 1. name of the argument that all outputs are view of
3434
# 2. map: output idx => name of the argument that this result is view of
3535
VIEW_FUNCTIONS = {
36-
'T': 'self',
3736
'alias': 'self',
3837
'as_strided': 'self',
3938
'diagonal': 'self',

tools/autograd/gen_python_functions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
'slice', 'randint(_out)?',
3232
'item', '_local_scalar_dense', 'to',
3333
'copy_sparse_to_sparse_', 'copy_',
34-
'T', # this needs to be an attribute in Python, not a function
3534
]
3635

3736
# These function signatures are not exposed to Python. Note that this signature

torch/_tensor_docs.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,11 +3196,3 @@ def callable(a, b) -> number
31963196
r"""
31973197
Alias for :meth:`~Tensor.dim()`
31983198
""")
3199-
3200-
add_docstr_all('T',
3201-
r"""
3202-
Is this Tensor with its dimensions reversed.
3203-
3204-
If ``n`` is the number of dimensions in ``x``,
3205-
``x.T`` is equivalent to ``x.permute(n-1, n-2, ..., 0)``.
3206-
""")

0 commit comments

Comments
 (0)