Skip to content

Commit 04d4ec2

Browse files
bwastifacebook-github-bot
authored andcommitted
Cleanup namespace that were moved to ATen accidentally (pytorch#12680)
Summary: Pull Request resolved: pytorch#12680 torch::jit shouldn't live in aten Reviewed By: ezyang Differential Revision: D10389502 fbshipit-source-id: f38582e61a275edccf22845c7d709a201f6a0be1
1 parent eb02a1d commit 04d4ec2

11 files changed

+90
-51
lines changed

aten/src/ATen/core/interned_strings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "ATen/core/interned_strings_class.h"
1212
#include "c10/util/Optional.h"
1313

14-
namespace torch { namespace jit {
14+
namespace c10 {
1515

1616
Symbol InternedStrings::symbol(const std::string& s) {
1717
std::lock_guard<std::mutex> guard(mutex_);
@@ -117,4 +117,4 @@ Symbol Symbol::fromDomainAndUnqualString(const std::string & d, const std::strin
117117
return fromQualString(qualString);
118118
}
119119

120-
}}
120+
} // namespace c10

aten/src/ATen/core/interned_strings.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <ATen/core/aten_interned_strings.h>
99
#include <ATen/core/Macros.h>
1010

11-
namespace torch { namespace jit {
11+
namespace c10 {
1212

1313
#if !AT_MOBILE
1414
#define FORALL_NS_SYMBOLS(_) \
@@ -157,10 +157,9 @@ namespace torch { namespace jit {
157157
// 1. Symbol namespace is split up into namespaces.
158158
//
159159
// 2. The intended access pattern for built-in symbols is onnx::MatMul
160-
// in the torch::jit namespace (this is a Symbol).
160+
// in the c10 namespace (this is a Symbol).
161161
//
162162

163-
164163
// Built-in constant definition strategy:
165164
// - Enum is the most convenient way to generate a contiguous sequence
166165
// of numbers for an identifier.
@@ -267,16 +266,16 @@ inline bool Symbol::is_aten() const { return ns() == namespaces::aten; }
267266
inline bool Symbol::is_prim() const { return ns() == namespaces::prim; }
268267
inline bool Symbol::is_onnx() const { return ns() == namespaces::onnx; }
269268

270-
}} // namespace torch::jit
269+
} // namespace c10
271270

272271
// make symbol behave like an integer in hash tables
273272
namespace std {
274-
template<>
275-
struct hash<torch::jit::Symbol> {
276-
size_t operator()(torch::jit::Symbol s) const {
277-
return std::hash<uint32_t>()(static_cast<uint32_t>(s));
278-
}
279-
};
273+
template <>
274+
struct hash<c10::Symbol> {
275+
size_t operator()(c10::Symbol s) const {
276+
return std::hash<uint32_t>()(static_cast<uint32_t>(s));
277+
}
278+
};
280279
}
281280

282281

aten/src/ATen/core/interned_strings_class.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
#include "ATen/core/interned_strings.h"
1010
#include <cstring>
1111

12-
namespace torch {
13-
namespace jit {
12+
namespace c10 {
1413

1514
struct CAFFE2_API InternedStrings {
1615
InternedStrings();
@@ -34,5 +33,4 @@ struct CAFFE2_API InternedStrings {
3433
std::mutex mutex_;
3534
};
3635

37-
} // namespace jit
38-
} // namespace torch
36+
} // namespace c10

aten/src/ATen/core/ivalue.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
#include <ATen/core/Formatting.h>
33

44
#define TORCH_FORALL_TAGS(_) \
5-
_(None) \
6-
_(Tensor) \
7-
_(Double) \
8-
_(Int) \
9-
_(Bool) \
10-
_(Tuple) \
11-
_(IntList) \
12-
_(DoubleList) \
13-
_(BoolList) \
14-
_(String) \
15-
_(TensorList) \
16-
_(Blob) \
17-
_(GenericList) \
18-
_(World) \
5+
_(None) \
6+
_(Tensor) \
7+
_(Double) \
8+
_(Int) \
9+
_(Bool) \
10+
_(Tuple) \
11+
_(IntList) \
12+
_(DoubleList) \
13+
_(BoolList) \
14+
_(String) \
15+
_(TensorList) \
16+
_(Blob) \
17+
_(GenericList) \
18+
_(World)
1919

20-
namespace torch { namespace jit {
20+
namespace c10 {
2121

2222
CAFFE2_API c10::intrusive_ptr<ConstantString> ConstantString::create(
2323
std::string str_) {
@@ -72,4 +72,4 @@ std::ostream& operator<<(std::ostream & out, const IValue & v) {
7272

7373
#undef TORCH_FORALL_TAGS
7474

75-
}}
75+
} // namespace c10

aten/src/ATen/core/ivalue.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include <type_traits>
1111

12-
namespace torch { namespace jit {
12+
namespace c10 {
1313

1414
template <typename T>
1515
using Shared = c10::intrusive_ptr<T>;
@@ -561,5 +561,4 @@ inline const std::vector<IValue>& IValue::toGenericListRef() const {
561561
return toGenericList()->elements();
562562
}
563563

564-
565-
}}
564+
} // namespace c10

aten/src/ATen/core/register_symbols.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
// This file is compiled with -O0 because the fully-macro-expanded
44
// function is huge and only called once at startup.
55

6-
namespace torch {
7-
namespace jit {
6+
namespace c10 {
87
InternedStrings::InternedStrings()
98
: sym_to_info_(static_cast<size_t>(_keys::num_symbols)) {
109
#define REGISTER_SYMBOL(n, s) \
@@ -14,5 +13,4 @@ InternedStrings::InternedStrings()
1413
FORALL_NS_SYMBOLS(REGISTER_SYMBOL)
1514
#undef REGISTER_SYMBOL
1615
}
17-
} // namespace jit
18-
} // namespace torch
16+
} // namespace c10

torch/csrc/jit/interned_strings.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
#include <ATen/core/interned_strings.h>
2+
3+
namespace torch {
4+
namespace jit {
5+
6+
namespace prim {
7+
using namespace ::c10::prim;
8+
}
9+
namespace attr {
10+
using namespace ::c10::attr;
11+
}
12+
namespace aten {
13+
using namespace ::c10::aten;
14+
}
15+
namespace onnx {
16+
using namespace ::c10::onnx;
17+
}
18+
using ::c10::Symbol;
19+
} // namespace jit
20+
} // namespace torch

torch/csrc/jit/interpreter.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
namespace at {
99
class Tensor;
1010
}
11+
namespace c10 {
12+
struct IValue;
13+
}
1114
namespace torch { namespace jit {
1215

1316
// The interpreter run Graphs with Tensor inputs and Tensor outputs
@@ -20,8 +23,7 @@ struct CodeImpl;
2023
struct InterpreterStateImpl;
2124
struct Graph;
2225
struct Node;
23-
struct IValue;
24-
using Stack = std::vector<IValue>;
26+
using Stack = std::vector<c10::IValue>;
2527

2628
struct TORCH_API Code {
2729
Code()

torch/csrc/jit/ir.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -996,15 +996,18 @@ inline Block::Block(Graph* graph_, Node* node_)
996996
#define IR_IFM_CONST(x,Kind) GENERIC_IF(const,prim::Kind,x,Kind)
997997
#define IR_ELSEIFM_CONST(Kind) GENERIC_ELSEIF(const,prim::Kind,Kind)
998998

999-
#define IR_IF(x, Kind) \
1000-
auto && __match_key = x; \
1001-
switch(__match_key->kind()) { \
1002-
case ::torch::jit::prim::Kind: { \
1003-
auto * value = __match_key; (void) value;
1004-
#define IR_ELSEIF(Kind) \
1005-
} break; \
1006-
case ::torch::jit::prim::Kind: { \
1007-
auto * value = __match_key; (void) value;
999+
#define IR_IF(x, Kind) \
1000+
auto&& __match_key = x; \
1001+
switch (__match_key->kind()) { \
1002+
case ::c10::prim::Kind: { \
1003+
auto* value = __match_key; \
1004+
(void)value;
1005+
#define IR_ELSEIF(Kind) \
1006+
} \
1007+
break; \
1008+
case ::c10::prim::Kind: { \
1009+
auto* value = __match_key; \
1010+
(void)value;
10081011

10091012
#define IR_ELSE() GENERIC_ELSE()
10101013
#define IR_END() GENERIC_END()

torch/csrc/jit/ivalue.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
11
#include <ATen/core/ivalue.h>
2+
3+
namespace torch {
4+
namespace jit {
5+
6+
using ::c10::List;
7+
using ::c10::Shared;
8+
using ::c10::World;
9+
10+
using ::c10::IValue;
11+
using ::c10::Tuple;
12+
13+
using ::c10::BoolList;
14+
using ::c10::DoubleList;
15+
using ::c10::GenericList;
16+
using ::c10::IntList;
17+
using ::c10::TensorList;
18+
19+
using ::c10::ConstantString;
20+
21+
} // namespace jit
22+
} // namespace torch

torch/csrc/jit/pybind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ template <> struct type_caster<torch::jit::IValue> {
3333
}
3434

3535
static handle cast(torch::jit::IValue src, return_value_policy /* policy */, handle /* parent */) {
36-
return toPyObject(std::move(src)).release();
36+
return torch::jit::toPyObject(std::move(src)).release();
3737
}
3838
};
3939

0 commit comments

Comments
 (0)