Skip to content

Commit

Permalink
Revert D20194092: Add support to dump unsupported ops. Add lite_inter…
Browse files Browse the repository at this point in the history
…pter_load test.

Test Plan: revert-hammer

Differential Revision:
D20194092

Original commit changeset: 0d596cd02043

fbshipit-source-id: 17b4bae27543f231bd6c12d90368d399ca55ebdf
  • Loading branch information
mrshenli authored and facebook-github-bot committed Mar 4, 2020
1 parent 17a5c67 commit d59e036
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 54 deletions.
30 changes: 0 additions & 30 deletions binaries/lite_interpreter_model_load.cc

This file was deleted.

7 changes: 2 additions & 5 deletions torch/csrc/jit/mobile/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void Function::append_instruction(OpCode op, int X, int N) {
code_->instructions_.emplace_back(op, X, N);
}

bool Function::append_operator(const std::string& name,
void Function::append_operator(const std::string& name,
const std::string& overload_name) {
// Keep the original opname in code_
code_->op_names_.emplace_back(name, overload_name);
Expand All @@ -29,16 +29,13 @@ bool Function::append_operator(const std::string& name,
opname.name = "_" + opname.name;
}
auto op = c10::Dispatcher::singleton().findSchema(opname);
if (not op.has_value()) {
return false;
}
TORCH_CHECK(op.has_value(), opname.name, ".", opname.overload_name, " cannot be found.");
// TODO: operator.h now does not depend on Node* so we can also look up operators from
// that registry for use in mobile as a way to share implementations.
auto fn = [op](Stack& stack) {
c10::Dispatcher::singleton().callBoxed(*op, &stack);
};
code_->operators_.emplace_back(fn);
return true;
}

void Function::append_constant(const c10::IValue& constant) {
Expand Down
2 changes: 1 addition & 1 deletion torch/csrc/jit/mobile/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Function{
const std::string& name() const;
const c10::QualifiedName& qualname() const;
void append_instruction(OpCode op, int X, int N);
bool append_operator(const std::string& name,
void append_operator(const std::string& name,
const std::string& overload_name);
void append_constant(const c10::IValue& constant);
void append_type(const c10::TypePtr& type);
Expand Down
19 changes: 1 addition & 18 deletions torch/csrc/jit/mobile/import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ IValue expect_field(IValue tup, const std::string& expected_name, size_t entry){
return row->elements().at(1);
}

void print_unsupported_ops_and_throw(const std::unordered_set<std::string>& unsupported_ops) {
std::string error_message("{");
for (const auto& op_name : unsupported_ops) {
error_message += op_name + ", ";
}
error_message += "}";
TORCH_CHECK(false, "Following ops cannot be found:", error_message);
}

void parseMethods(const std::vector<IValue>& vals, mobile::CompilationUnit& mcu) {
for (const auto& element : vals) {
const auto& m_tuple = element.toTuple()->elements();
Expand All @@ -81,22 +72,14 @@ void parseMethods(const std::vector<IValue>& vals, mobile::CompilationUnit& mcu)
function->append_instruction(op_code, X, N);
}

std::unordered_set<std::string> unsupported_op_names;
for (const auto& op : ops_list) {
auto op_item = op.toTuple()->elements();
TORCH_CHECK(op_item.size() == 2,
"There should be two parts in an operator name.");
auto op_found = function->append_operator(op_item[0].toString()->string(),
function->append_operator(op_item[0].toString()->string(),
op_item[1].toString()->string());
if (not op_found) {
unsupported_op_names.emplace(op_item[0].toString()->string() + "." + op_item[1].toString()->string());
}
}

if (not unsupported_op_names.empty()) {
print_unsupported_ops_and_throw(unsupported_op_names);
};

for (const auto& constant : consts_list) {
function->append_constant(constant);
}
Expand Down

0 comments on commit d59e036

Please # to comment.