Skip to content

Commit 3deb479

Browse files
ezyangfacebook-github-bot
authored andcommitted
Replace 'struct Tensor' with 'class Tensor'. (pytorch#12034)
Summary: Pull Request resolved: pytorch#12034 We need ATen and Caffe2 to line up, and the rule is that if you have any private/protected members, you should declare it as a class. Class we go. (There are some other obvious candidates for this treatment, but I've kept this patch just to Tensor) Reviewed By: gchanan, mingzhe09088 Differential Revision: D10024467 fbshipit-source-id: 17cfe2741ba9c3f56cb87d6f5d1afd3c61a8e4fe
1 parent fcb3ccf commit 3deb479

File tree

12 files changed

+16
-14
lines changed

12 files changed

+16
-14
lines changed

aten/src/ATen/Context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
namespace at {
2424

25-
struct Tensor;
25+
class Tensor;
2626

2727
class CAFFE2_API Context {
2828
public:

aten/src/ATen/core/Scalar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace at {
1414

15-
struct Tensor;
15+
class Tensor;
1616

1717
class CAFFE2_API Scalar {
1818
public:

aten/src/ATen/core/ScalarType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static inline ScalarType promoteTypes(ScalarType a, ScalarType b) {
188188
return _promoteTypesLookup[static_cast<int>(a)][static_cast<int>(b)];
189189
}
190190

191-
struct Tensor;
191+
class Tensor;
192192
typedef ArrayRef<int64_t> IntList;
193193
typedef ArrayRef<Tensor> TensorList;
194194

aten/src/ATen/core/SparseTensorRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace at {
44

5-
struct Tensor;
5+
class Tensor;
66
struct SparseTensorRef {
77
explicit SparseTensorRef(const Tensor& t): tref(t) {}
88
const Tensor& tref;

aten/src/ATen/core/Tensor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace at {
1616
struct Generator;
1717
struct Type;
18-
struct Tensor;
18+
class Tensor;
1919
struct TensorOptions;
2020
} // namespace at
2121

@@ -37,7 +37,8 @@ namespace at {
3737
//
3838
// Note that Tensor can also be NULL, i.e. it is not associated with any underlying TensorImpl, and
3939
// special care must be taken to handle this.
40-
struct CAFFE2_API Tensor {
40+
class CAFFE2_API Tensor {
41+
public:
4142
Tensor(){};
4243
Tensor(c10::intrusive_ptr<TensorImpl, UndefinedTensorImpl> tensor_impl)
4344
: impl_(std::move(tensor_impl)) {

aten/src/ATen/core/TensorImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace at {
1616
class Scalar;
1717
struct Type;
1818
struct Storage;
19-
struct Tensor;
19+
class Tensor;
2020
} // namespace at
2121

2222
namespace at {

aten/src/ATen/core/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Context;
3333
struct Allocator;
3434
struct Generator;
3535
struct Storage;
36-
struct Tensor;
36+
class Tensor;
3737

3838
static inline void noop_deleter(void*) {}
3939

aten/src/ATen/templates/NativeFunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
namespace at {
1717
struct Generator;
1818
class Scalar;
19-
struct Tensor;
19+
class Tensor;
2020
struct Type;
2121
} // namespace at
2222

aten/src/ATen/templates/Tensor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace at {
1616
struct Generator;
1717
struct Type;
18-
struct Tensor;
18+
class Tensor;
1919
struct TensorOptions;
2020
} // namespace at
2121

@@ -37,7 +37,8 @@ namespace at {
3737
//
3838
// Note that Tensor can also be NULL, i.e. it is not associated with any underlying TensorImpl, and
3939
// special care must be taken to handle this.
40-
struct CAFFE2_API Tensor {
40+
class CAFFE2_API Tensor {
41+
public:
4142
Tensor(){};
4243
Tensor(c10::intrusive_ptr<TensorImpl, UndefinedTensorImpl> tensor_impl)
4344
: impl_(std::move(tensor_impl)) {

aten/src/ATen/templates/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Context;
3333
struct Allocator;
3434
struct Generator;
3535
struct Storage;
36-
struct Tensor;
36+
class Tensor;
3737

3838
static inline void noop_deleter(void*) {}
3939

0 commit comments

Comments
 (0)