提交 fa1db5eb 编写于 作者: Y Yu-Cheng Ling

Refactoring: Remove a redundant map from model.h.

Cherry picking this into TFLite r0.1.7 release for a compatibility issue.
The original Piper ID: 194306629
上级 690b8e84
......@@ -88,7 +88,9 @@ struct TensorData {
class SingleOpResolver : public OpResolver {
public:
SingleOpResolver(const BuiltinOperator op, TfLiteRegistration* registration)
: op_(op), registration_(registration) {}
: op_(op), registration_(registration) {
registration_->builtin_code = op;
}
TfLiteRegistration* FindOp(BuiltinOperator op) const override {
if (op == op_) {
return registration_;
......
......@@ -191,7 +191,6 @@ TfLiteStatus InterpreterBuilder::BuildLocalIndexToRegistrationMapping() {
builtin_code);
status = kTfLiteError;
} else if (builtin_code != BuiltinOperator_CUSTOM) {
flatbuffer_op_index_to_registration_types_.push_back(builtin_code);
registration = op_resolver_.FindOp(builtin_code);
if (registration == nullptr) {
error_reporter_->Report("Didn't find op for builtin opcode '%s'\n",
......@@ -205,8 +204,6 @@ TfLiteStatus InterpreterBuilder::BuildLocalIndexToRegistrationMapping() {
} else {
const char* name = opcode->custom_code()->c_str();
registration = op_resolver_.FindOp(name);
flatbuffer_op_index_to_registration_types_.push_back(
BuiltinOperator_CUSTOM);
if (registration == nullptr) {
error_reporter_->Report("Didn't find custom op for name '%s'\n", name);
status = kTfLiteError;
......@@ -685,8 +682,7 @@ TfLiteStatus InterpreterBuilder::ParseNodes(
continue;
}
auto op_type =
flatbuffer_op_index_to_registration_types_[op->opcode_index()];
BuiltinOperator op_type = static_cast<BuiltinOperator>(reg->builtin_code);
if (op_type != BuiltinOperator_CUSTOM && op->custom_options()) {
error_reporter_->Report(
"Found builtin operator %s with custom options.\n",
......
......@@ -188,7 +188,6 @@ class InterpreterBuilder {
ErrorReporter* error_reporter_;
std::vector<TfLiteRegistration*> flatbuffer_op_index_to_registration_;
std::vector<BuiltinOperator> flatbuffer_op_index_to_registration_types_;
const Allocation* allocation_ = nullptr;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册