Skip to content

Commit

Permalink
Revert D18499600: Add overload name to JIT prim operators.
Browse files Browse the repository at this point in the history
Test Plan: revert-hammer

Differential Revision:
D18499600

Original commit changeset: a1b49e64c908

fbshipit-source-id: 73e27b72f53799c0133850d2352ae8cd8a82d87c
  • Loading branch information
zdevito authored and facebook-github-bot committed Nov 16, 2019
1 parent 2a442f5 commit a5b4d78
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 76 deletions.
16 changes: 0 additions & 16 deletions test/cpp/jit/test_lite_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,5 @@ void testLiteInterpreterTuple() {
auto output = bc.run_method("forward", inputs);
AT_ASSERT(output.toTuple()->elements()[1].toInt() == 2);
}

void testLiteInterpreterPrimOverload() {
script::Module m("m");
m.define(R"JIT(
def forward(self, x):
result = [1, 2]
result.append(3)
return result
)JIT");
std::stringstream ss;
m._save_for_mobile(ss);
mobile::Module bc = _load_for_mobile(ss);
std::vector<torch::jit::IValue> inputs({torch::ones({})});
auto output = bc.run_method("forward", inputs);
AT_ASSERT(output.toIntList()[2] == 3);
}
} // namespace torch
} // namespace jit
1 change: 0 additions & 1 deletion test/cpp/jit/tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ namespace jit {
_(LiteInterpreterConv) \
_(LiteInterpreterInline) \
_(LiteInterpreterTuple) \
_(LiteInterpreterPrimOverload) \
_(CommonAncestor)

#define TH_FORALL_TESTS_CUDA(_) \
Expand Down
7 changes: 1 addition & 6 deletions torch/csrc/jit/mobile/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ void listConstruct(Stack& stack, int num_inputs) {
bool InterpreterState::run(Stack& stack) {
size_t pc = 0;
while (true) {
Instruction inst = code_->instructions_[pc];

// std::cout << "RUNNING " << pc << " " << code_->instructions_[pc];
// if (inst.op == OP) {
// std::cout << ", " << code_->op_names_[inst.X].name << "." <<
// code_->op_names_[inst.X].overload_name;
// }
// std::cout << std::endl;
// for (auto val : stack) {
// if (val.isTensor()) {
Expand All @@ -40,6 +34,7 @@ bool InterpreterState::run(Stack& stack) {
// std::cout << val << std::endl;
// }
// }
Instruction inst = code_->instructions_[pc];
switch (inst.op) {
case OP: {
c10::Dispatcher::singleton().callBoxed(*code_->operators_[inst.X], &stack);
Expand Down
24 changes: 0 additions & 24 deletions torch/csrc/jit/mobile/register_mobile_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ using Stack = std::vector<c10::IValue>;
using torch::jit::peek;
using torch::jit::drop;
using torch::jit::pack;
using torch::jit::push;
using torch::jit::pop;

namespace {
at::Tensor toOptionalTensor(const c10::IValue& v) {
Expand All @@ -20,15 +18,6 @@ at::Tensor toOptionalTensor(const c10::IValue& v) {
at::Tensor optional_to_tensor(c10::optional<at::Tensor> v) {
return v.has_value() ? *v : at::Tensor();
}

template <typename T>
void listAppend(Stack& stack) {
T el = pop(stack).to<T>();
c10::List<T> list = pop(stack).to<c10::List<T>>();

list.push_back(std::move(el));
push(stack, std::move(list));
}
}

static auto registry0 = torch::RegisterOperators().op(
Expand Down Expand Up @@ -326,17 +315,4 @@ static auto registry0 = torch::RegisterOperators().op(
torch::RegisterOperators::options().catchAllKernel(
[]() {
})
).op(
"_aten::append.Tensor(Tensor self) -> void",
torch::RegisterOperators::options().kernel(c10::TensorTypeId::CPUTensorId,
[](c10::OperatorKernel* kernel, Stack* stack) {
listAppend<at::Tensor>(*stack);
})
).op(
"_aten::append.int(int self) -> void",
torch::RegisterOperators::options().catchAllKernel(
[](c10::OperatorKernel* kernel, Stack* stack) {
listAppend<int64_t>(*stack);
})
);

58 changes: 29 additions & 29 deletions torch/csrc/jit/register_prim_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2400,36 +2400,36 @@ RegisterOperators reg2({
// Mutable ops for lists containing mutable types.
#define CREATE_MUTABLE_LIST_OPS(decl_type, value_type) \
Operator( \
"aten::select." decl_type "( " decl_type "[](a) list, int idx) -> " decl_type "(*)", \
"aten::select(" decl_type "[](a) list, int idx) -> " decl_type "(*)", \
listSelect<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::__getitem__." decl_type "( " decl_type "[](a) list, int idx) -> " decl_type \
"aten::__getitem__(" decl_type "[](a) list, int idx) -> " decl_type \
"(*)", \
listSelect<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::append." decl_type "( " decl_type "[](a!) self, " decl_type \
"aten::append( " decl_type "[](a!) self, " decl_type \
"(c -> *) el) -> " decl_type "[](a!)", \
listAppend<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::reverse." decl_type "( " decl_type "[](a!) self) -> ()", \
"aten::reverse( " decl_type "[](a!) self) -> ()", \
listReverse<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::extend." decl_type "( " decl_type "[](a!) self, " decl_type \
"aten::extend(" decl_type "[](a!) self, " decl_type \
" [] other) -> ()", \
listExtend<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::copy." decl_type "( " decl_type \
"aten::copy(" decl_type \
"[](a) self)" \
" -> " decl_type "[]", \
listCopy<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::_set_item." decl_type "( " decl_type "[](a!) l, int idx, " decl_type \
"aten::_set_item(" decl_type "[](a!) l, int idx, " decl_type \
"(b -> *) el) -> " decl_type "[](a!)", \
listSetItem<value_type>, \
aliasAnalysisFromSchema()), \
Expand All @@ -2444,7 +2444,7 @@ RegisterOperators reg2({
listInsert<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::pop." decl_type "( " decl_type \
"aten::pop(" decl_type \
"[](a!) self, int idx=-1) \
-> " decl_type "(*)", \
listPop<value_type>, \
Expand All @@ -2468,51 +2468,51 @@ RegisterOperators reg2({
// Mutable ops for lists containing immutable types.
#define CREATE_IMMUTABLE_LIST_OPS(decl_type, value_type) \
Operator( \
"aten::select." decl_type "( " decl_type "[] a, int b) -> " decl_type, \
"aten::select(" decl_type "[] a, int b) -> " decl_type, \
listSelect<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::__getitem__." decl_type "( " decl_type "[](a) list, int idx) -> " decl_type, \
"aten::__getitem__(" decl_type "[](a) list, int idx) -> " decl_type, \
listSelect<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"prim::min.lr" decl_type "( " decl_type "[] l, " decl_type "[] r) -> " decl_type "[]",\
"prim::min(" decl_type "[] l, " decl_type "[] r) -> " decl_type "[]",\
minList<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"prim::max.lr" decl_type "( " decl_type "[] l, " decl_type "[] r) -> " decl_type "[]",\
"prim::max(" decl_type "[] l, " decl_type "[] r) -> " decl_type "[]",\
maxList<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::append." decl_type "( " decl_type "[](a!) self, " decl_type \
"aten::append(" decl_type "[](a!) self, " decl_type \
" el) -> " decl_type "[](a!)", \
listAppend<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::reverse." decl_type "( " decl_type "[](a!) self) -> ()", \
"aten::reverse(" decl_type "[](a!) self) -> ()", \
listReverse<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"prim::min." decl_type "( " decl_type "[] self) -> " decl_type, \
"prim::min(" decl_type "[] self) -> " decl_type, \
listMin<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"prim::max." decl_type "( " decl_type "[] self) -> " decl_type, \
"prim::max(" decl_type "[] self) -> " decl_type, \
listMax<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::extend." decl_type "( " decl_type "[](a!) self, " decl_type \
"aten::extend(" decl_type "[](a!) self, " decl_type \
" [] other) -> ()", \
listExtend<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::copy." decl_type "( " decl_type \
"aten::copy(" decl_type \
"[](a) self)" \
" -> " decl_type "[]", \
listCopy<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::_set_item." decl_type "( " decl_type "[](a!) l, int idx, " decl_type \
"aten::_set_item(" decl_type "[](a!) l, int idx, " decl_type \
" el) -> " decl_type "[](a!)", \
listSetItem<value_type>, \
aliasAnalysisFromSchema()), \
Expand All @@ -2527,25 +2527,25 @@ RegisterOperators reg2({
listInsert<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::remove." decl_type "( " decl_type \
"aten::remove(" decl_type \
"[](a!) self, \
" decl_type " el) -> ()", \
listRemove<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::index." decl_type "( " decl_type \
"aten::index(" decl_type \
"[] self, \
" decl_type " el) -> int", \
listIndex<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::count." decl_type "( " decl_type \
"aten::count(" decl_type \
"[] self, \
" decl_type " el) -> int", \
listCount<value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::pop." decl_type "( " decl_type \
"aten::pop(" decl_type \
"[](a!) self, int idx=-1) \
-> " decl_type, \
listPop<value_type>, \
Expand All @@ -2572,31 +2572,31 @@ RegisterOperators reg2({

#define CREATE_LIST_OPS(decl_type, c_type) \
Operator( \
"aten::len." decl_type "( " decl_type "[] a) -> int", \
"aten::len(" decl_type "[] a) -> int", \
listLen<c_type::value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::add." decl_type "( " decl_type "[] a, " decl_type "[] b) -> " decl_type \
"aten::add(" decl_type "[] a, " decl_type "[] b) -> " decl_type \
"[]", \
listAdd<c_type::value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::add_." decl_type "( " decl_type "[](a!) self, " decl_type \
"aten::add_(" decl_type "[](a!) self, " decl_type \
"[] b) -> " decl_type "[]", \
listInplaceAdd<c_type::value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::slice." decl_type "( " decl_type \
"aten::slice(" decl_type \
"[] l, int start, int end=9223372036854775807, int step=1) -> " decl_type \
"[]", \
listSlice<c_type::value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::list." decl_type "( " decl_type "[] l) -> " decl_type "[]", \
"aten::list(" decl_type "[] l) -> " decl_type "[]", \
listList<c_type::value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
"aten::mul." decl_type "( " decl_type "[] l, int n) -> " decl_type "[]", \
"aten::mul(" decl_type "[] l, int n) -> " decl_type "[]", \
listMulIntLeft<c_type::value_type>, \
aliasAnalysisFromSchema()), \
Operator( \
Expand Down

0 comments on commit a5b4d78

Please sign in to comment.