Skip to content

Commit a5b4d78

Browse files
zdevitofacebook-github-bot
authored andcommitted
Revert D18499600: Add overload name to JIT prim operators.
Test Plan: revert-hammer Differential Revision: D18499600 Original commit changeset: a1b49e64c908 fbshipit-source-id: 73e27b72f53799c0133850d2352ae8cd8a82d87c
1 parent 2a442f5 commit a5b4d78

File tree

5 files changed

+30
-76
lines changed

5 files changed

+30
-76
lines changed

test/cpp/jit/test_lite_interpreter.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,5 @@ void testLiteInterpreterTuple() {
112112
auto output = bc.run_method("forward", inputs);
113113
AT_ASSERT(output.toTuple()->elements()[1].toInt() == 2);
114114
}
115-
116-
void testLiteInterpreterPrimOverload() {
117-
script::Module m("m");
118-
m.define(R"JIT(
119-
def forward(self, x):
120-
result = [1, 2]
121-
result.append(3)
122-
return result
123-
)JIT");
124-
std::stringstream ss;
125-
m._save_for_mobile(ss);
126-
mobile::Module bc = _load_for_mobile(ss);
127-
std::vector<torch::jit::IValue> inputs({torch::ones({})});
128-
auto output = bc.run_method("forward", inputs);
129-
AT_ASSERT(output.toIntList()[2] == 3);
130-
}
131115
} // namespace torch
132116
} // namespace jit

test/cpp/jit/tests.h

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ namespace jit {
7070
_(LiteInterpreterConv) \
7171
_(LiteInterpreterInline) \
7272
_(LiteInterpreterTuple) \
73-
_(LiteInterpreterPrimOverload) \
7473
_(CommonAncestor)
7574

7675
#define TH_FORALL_TESTS_CUDA(_) \

torch/csrc/jit/mobile/interpreter.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ void listConstruct(Stack& stack, int num_inputs) {
2525
bool InterpreterState::run(Stack& stack) {
2626
size_t pc = 0;
2727
while (true) {
28-
Instruction inst = code_->instructions_[pc];
29-
3028
// std::cout << "RUNNING " << pc << " " << code_->instructions_[pc];
31-
// if (inst.op == OP) {
32-
// std::cout << ", " << code_->op_names_[inst.X].name << "." <<
33-
// code_->op_names_[inst.X].overload_name;
34-
// }
3529
// std::cout << std::endl;
3630
// for (auto val : stack) {
3731
// if (val.isTensor()) {
@@ -40,6 +34,7 @@ bool InterpreterState::run(Stack& stack) {
4034
// std::cout << val << std::endl;
4135
// }
4236
// }
37+
Instruction inst = code_->instructions_[pc];
4338
switch (inst.op) {
4439
case OP: {
4540
c10::Dispatcher::singleton().callBoxed(*code_->operators_[inst.X], &stack);

torch/csrc/jit/mobile/register_mobile_ops.cpp

-24
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ using Stack = std::vector<c10::IValue>;
66
using torch::jit::peek;
77
using torch::jit::drop;
88
using torch::jit::pack;
9-
using torch::jit::push;
10-
using torch::jit::pop;
119

1210
namespace {
1311
at::Tensor toOptionalTensor(const c10::IValue& v) {
@@ -20,15 +18,6 @@ at::Tensor toOptionalTensor(const c10::IValue& v) {
2018
at::Tensor optional_to_tensor(c10::optional<at::Tensor> v) {
2119
return v.has_value() ? *v : at::Tensor();
2220
}
23-
24-
template <typename T>
25-
void listAppend(Stack& stack) {
26-
T el = pop(stack).to<T>();
27-
c10::List<T> list = pop(stack).to<c10::List<T>>();
28-
29-
list.push_back(std::move(el));
30-
push(stack, std::move(list));
31-
}
3221
}
3322

3423
static auto registry0 = torch::RegisterOperators().op(
@@ -326,17 +315,4 @@ static auto registry0 = torch::RegisterOperators().op(
326315
torch::RegisterOperators::options().catchAllKernel(
327316
[]() {
328317
})
329-
).op(
330-
"_aten::append.Tensor(Tensor self) -> void",
331-
torch::RegisterOperators::options().kernel(c10::TensorTypeId::CPUTensorId,
332-
[](c10::OperatorKernel* kernel, Stack* stack) {
333-
listAppend<at::Tensor>(*stack);
334-
})
335-
).op(
336-
"_aten::append.int(int self) -> void",
337-
torch::RegisterOperators::options().catchAllKernel(
338-
[](c10::OperatorKernel* kernel, Stack* stack) {
339-
listAppend<int64_t>(*stack);
340-
})
341318
);
342-

torch/csrc/jit/register_prim_ops.cpp

+29-29
Original file line numberDiff line numberDiff line change
@@ -2400,36 +2400,36 @@ RegisterOperators reg2({
24002400
// Mutable ops for lists containing mutable types.
24012401
#define CREATE_MUTABLE_LIST_OPS(decl_type, value_type) \
24022402
Operator( \
2403-
"aten::select." decl_type "( " decl_type "[](a) list, int idx) -> " decl_type "(*)", \
2403+
"aten::select(" decl_type "[](a) list, int idx) -> " decl_type "(*)", \
24042404
listSelect<value_type>, \
24052405
aliasAnalysisFromSchema()), \
24062406
Operator( \
2407-
"aten::__getitem__." decl_type "( " decl_type "[](a) list, int idx) -> " decl_type \
2407+
"aten::__getitem__(" decl_type "[](a) list, int idx) -> " decl_type \
24082408
"(*)", \
24092409
listSelect<value_type>, \
24102410
aliasAnalysisFromSchema()), \
24112411
Operator( \
2412-
"aten::append." decl_type "( " decl_type "[](a!) self, " decl_type \
2412+
"aten::append( " decl_type "[](a!) self, " decl_type \
24132413
"(c -> *) el) -> " decl_type "[](a!)", \
24142414
listAppend<value_type>, \
24152415
aliasAnalysisFromSchema()), \
24162416
Operator( \
2417-
"aten::reverse." decl_type "( " decl_type "[](a!) self) -> ()", \
2417+
"aten::reverse( " decl_type "[](a!) self) -> ()", \
24182418
listReverse<value_type>, \
24192419
aliasAnalysisFromSchema()), \
24202420
Operator( \
2421-
"aten::extend." decl_type "( " decl_type "[](a!) self, " decl_type \
2421+
"aten::extend(" decl_type "[](a!) self, " decl_type \
24222422
" [] other) -> ()", \
24232423
listExtend<value_type>, \
24242424
aliasAnalysisFromSchema()), \
24252425
Operator( \
2426-
"aten::copy." decl_type "( " decl_type \
2426+
"aten::copy(" decl_type \
24272427
"[](a) self)" \
24282428
" -> " decl_type "[]", \
24292429
listCopy<value_type>, \
24302430
aliasAnalysisFromSchema()), \
24312431
Operator( \
2432-
"aten::_set_item." decl_type "( " decl_type "[](a!) l, int idx, " decl_type \
2432+
"aten::_set_item(" decl_type "[](a!) l, int idx, " decl_type \
24332433
"(b -> *) el) -> " decl_type "[](a!)", \
24342434
listSetItem<value_type>, \
24352435
aliasAnalysisFromSchema()), \
@@ -2444,7 +2444,7 @@ RegisterOperators reg2({
24442444
listInsert<value_type>, \
24452445
aliasAnalysisFromSchema()), \
24462446
Operator( \
2447-
"aten::pop." decl_type "( " decl_type \
2447+
"aten::pop(" decl_type \
24482448
"[](a!) self, int idx=-1) \
24492449
-> " decl_type "(*)", \
24502450
listPop<value_type>, \
@@ -2468,51 +2468,51 @@ RegisterOperators reg2({
24682468
// Mutable ops for lists containing immutable types.
24692469
#define CREATE_IMMUTABLE_LIST_OPS(decl_type, value_type) \
24702470
Operator( \
2471-
"aten::select." decl_type "( " decl_type "[] a, int b) -> " decl_type, \
2471+
"aten::select(" decl_type "[] a, int b) -> " decl_type, \
24722472
listSelect<value_type>, \
24732473
aliasAnalysisFromSchema()), \
24742474
Operator( \
2475-
"aten::__getitem__." decl_type "( " decl_type "[](a) list, int idx) -> " decl_type, \
2475+
"aten::__getitem__(" decl_type "[](a) list, int idx) -> " decl_type, \
24762476
listSelect<value_type>, \
24772477
aliasAnalysisFromSchema()), \
24782478
Operator( \
2479-
"prim::min.lr" decl_type "( " decl_type "[] l, " decl_type "[] r) -> " decl_type "[]",\
2479+
"prim::min(" decl_type "[] l, " decl_type "[] r) -> " decl_type "[]",\
24802480
minList<value_type>, \
24812481
aliasAnalysisFromSchema()), \
24822482
Operator( \
2483-
"prim::max.lr" decl_type "( " decl_type "[] l, " decl_type "[] r) -> " decl_type "[]",\
2483+
"prim::max(" decl_type "[] l, " decl_type "[] r) -> " decl_type "[]",\
24842484
maxList<value_type>, \
24852485
aliasAnalysisFromSchema()), \
24862486
Operator( \
2487-
"aten::append." decl_type "( " decl_type "[](a!) self, " decl_type \
2487+
"aten::append(" decl_type "[](a!) self, " decl_type \
24882488
" el) -> " decl_type "[](a!)", \
24892489
listAppend<value_type>, \
24902490
aliasAnalysisFromSchema()), \
24912491
Operator( \
2492-
"aten::reverse." decl_type "( " decl_type "[](a!) self) -> ()", \
2492+
"aten::reverse(" decl_type "[](a!) self) -> ()", \
24932493
listReverse<value_type>, \
24942494
aliasAnalysisFromSchema()), \
24952495
Operator( \
2496-
"prim::min." decl_type "( " decl_type "[] self) -> " decl_type, \
2496+
"prim::min(" decl_type "[] self) -> " decl_type, \
24972497
listMin<value_type>, \
24982498
aliasAnalysisFromSchema()), \
24992499
Operator( \
2500-
"prim::max." decl_type "( " decl_type "[] self) -> " decl_type, \
2500+
"prim::max(" decl_type "[] self) -> " decl_type, \
25012501
listMax<value_type>, \
25022502
aliasAnalysisFromSchema()), \
25032503
Operator( \
2504-
"aten::extend." decl_type "( " decl_type "[](a!) self, " decl_type \
2504+
"aten::extend(" decl_type "[](a!) self, " decl_type \
25052505
" [] other) -> ()", \
25062506
listExtend<value_type>, \
25072507
aliasAnalysisFromSchema()), \
25082508
Operator( \
2509-
"aten::copy." decl_type "( " decl_type \
2509+
"aten::copy(" decl_type \
25102510
"[](a) self)" \
25112511
" -> " decl_type "[]", \
25122512
listCopy<value_type>, \
25132513
aliasAnalysisFromSchema()), \
25142514
Operator( \
2515-
"aten::_set_item." decl_type "( " decl_type "[](a!) l, int idx, " decl_type \
2515+
"aten::_set_item(" decl_type "[](a!) l, int idx, " decl_type \
25162516
" el) -> " decl_type "[](a!)", \
25172517
listSetItem<value_type>, \
25182518
aliasAnalysisFromSchema()), \
@@ -2527,25 +2527,25 @@ RegisterOperators reg2({
25272527
listInsert<value_type>, \
25282528
aliasAnalysisFromSchema()), \
25292529
Operator( \
2530-
"aten::remove." decl_type "( " decl_type \
2530+
"aten::remove(" decl_type \
25312531
"[](a!) self, \
25322532
" decl_type " el) -> ()", \
25332533
listRemove<value_type>, \
25342534
aliasAnalysisFromSchema()), \
25352535
Operator( \
2536-
"aten::index." decl_type "( " decl_type \
2536+
"aten::index(" decl_type \
25372537
"[] self, \
25382538
" decl_type " el) -> int", \
25392539
listIndex<value_type>, \
25402540
aliasAnalysisFromSchema()), \
25412541
Operator( \
2542-
"aten::count." decl_type "( " decl_type \
2542+
"aten::count(" decl_type \
25432543
"[] self, \
25442544
" decl_type " el) -> int", \
25452545
listCount<value_type>, \
25462546
aliasAnalysisFromSchema()), \
25472547
Operator( \
2548-
"aten::pop." decl_type "( " decl_type \
2548+
"aten::pop(" decl_type \
25492549
"[](a!) self, int idx=-1) \
25502550
-> " decl_type, \
25512551
listPop<value_type>, \
@@ -2572,31 +2572,31 @@ RegisterOperators reg2({
25722572

25732573
#define CREATE_LIST_OPS(decl_type, c_type) \
25742574
Operator( \
2575-
"aten::len." decl_type "( " decl_type "[] a) -> int", \
2575+
"aten::len(" decl_type "[] a) -> int", \
25762576
listLen<c_type::value_type>, \
25772577
aliasAnalysisFromSchema()), \
25782578
Operator( \
2579-
"aten::add." decl_type "( " decl_type "[] a, " decl_type "[] b) -> " decl_type \
2579+
"aten::add(" decl_type "[] a, " decl_type "[] b) -> " decl_type \
25802580
"[]", \
25812581
listAdd<c_type::value_type>, \
25822582
aliasAnalysisFromSchema()), \
25832583
Operator( \
2584-
"aten::add_." decl_type "( " decl_type "[](a!) self, " decl_type \
2584+
"aten::add_(" decl_type "[](a!) self, " decl_type \
25852585
"[] b) -> " decl_type "[]", \
25862586
listInplaceAdd<c_type::value_type>, \
25872587
aliasAnalysisFromSchema()), \
25882588
Operator( \
2589-
"aten::slice." decl_type "( " decl_type \
2589+
"aten::slice(" decl_type \
25902590
"[] l, int start, int end=9223372036854775807, int step=1) -> " decl_type \
25912591
"[]", \
25922592
listSlice<c_type::value_type>, \
25932593
aliasAnalysisFromSchema()), \
25942594
Operator( \
2595-
"aten::list." decl_type "( " decl_type "[] l) -> " decl_type "[]", \
2595+
"aten::list(" decl_type "[] l) -> " decl_type "[]", \
25962596
listList<c_type::value_type>, \
25972597
aliasAnalysisFromSchema()), \
25982598
Operator( \
2599-
"aten::mul." decl_type "( " decl_type "[] l, int n) -> " decl_type "[]", \
2599+
"aten::mul(" decl_type "[] l, int n) -> " decl_type "[]", \
26002600
listMulIntLeft<c_type::value_type>, \
26012601
aliasAnalysisFromSchema()), \
26022602
Operator( \

0 commit comments

Comments
 (0)