Skip to content

Commit fa1db5e

Browse files
committed
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
1 parent 690b8e8 commit fa1db5e

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

tensorflow/contrib/lite/kernels/test_util.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ struct TensorData {
8888
class SingleOpResolver : public OpResolver {
8989
public:
9090
SingleOpResolver(const BuiltinOperator op, TfLiteRegistration* registration)
91-
: op_(op), registration_(registration) {}
91+
: op_(op), registration_(registration) {
92+
registration_->builtin_code = op;
93+
}
9294
TfLiteRegistration* FindOp(BuiltinOperator op) const override {
9395
if (op == op_) {
9496
return registration_;

tensorflow/contrib/lite/model.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ TfLiteStatus InterpreterBuilder::BuildLocalIndexToRegistrationMapping() {
191191
builtin_code);
192192
status = kTfLiteError;
193193
} else if (builtin_code != BuiltinOperator_CUSTOM) {
194-
flatbuffer_op_index_to_registration_types_.push_back(builtin_code);
195194
registration = op_resolver_.FindOp(builtin_code);
196195
if (registration == nullptr) {
197196
error_reporter_->Report("Didn't find op for builtin opcode '%s'\n",
@@ -205,8 +204,6 @@ TfLiteStatus InterpreterBuilder::BuildLocalIndexToRegistrationMapping() {
205204
} else {
206205
const char* name = opcode->custom_code()->c_str();
207206
registration = op_resolver_.FindOp(name);
208-
flatbuffer_op_index_to_registration_types_.push_back(
209-
BuiltinOperator_CUSTOM);
210207
if (registration == nullptr) {
211208
error_reporter_->Report("Didn't find custom op for name '%s'\n", name);
212209
status = kTfLiteError;
@@ -685,8 +682,7 @@ TfLiteStatus InterpreterBuilder::ParseNodes(
685682
continue;
686683
}
687684

688-
auto op_type =
689-
flatbuffer_op_index_to_registration_types_[op->opcode_index()];
685+
BuiltinOperator op_type = static_cast<BuiltinOperator>(reg->builtin_code);
690686
if (op_type != BuiltinOperator_CUSTOM && op->custom_options()) {
691687
error_reporter_->Report(
692688
"Found builtin operator %s with custom options.\n",

tensorflow/contrib/lite/model.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ class InterpreterBuilder {
188188
ErrorReporter* error_reporter_;
189189

190190
std::vector<TfLiteRegistration*> flatbuffer_op_index_to_registration_;
191-
std::vector<BuiltinOperator> flatbuffer_op_index_to_registration_types_;
192191
const Allocation* allocation_ = nullptr;
193192
};
194193

0 commit comments

Comments
 (0)