Automated g4 rollback of changelist 194306629
authorYu-Cheng Ling <ycling@google.com>
Fri, 27 Apr 2018 07:07:07 +0000 (00:07 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Fri, 27 Apr 2018 07:09:12 +0000 (00:09 -0700)
PiperOrigin-RevId: 194507274

tensorflow/contrib/lite/kernels/test_util.h
tensorflow/contrib/lite/model.cc
tensorflow/contrib/lite/model.h

index a5f345e..a9064d5 100644 (file)
@@ -88,9 +88,7 @@ struct TensorData {
 class SingleOpResolver : public OpResolver {
  public:
   SingleOpResolver(const BuiltinOperator op, TfLiteRegistration* registration)
-      : op_(op), registration_(registration) {
-    registration_->builtin_code = op;
-  }
+      : op_(op), registration_(registration) {}
   TfLiteRegistration* FindOp(BuiltinOperator op) const override {
     if (op == op_) {
       return registration_;
index 6fd3d9f..e15f1be 100644 (file)
@@ -194,6 +194,7 @@ 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",
@@ -207,6 +208,8 @@ 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;
@@ -700,7 +703,8 @@ TfLiteStatus InterpreterBuilder::ParseNodes(
       continue;
     }
 
-    BuiltinOperator op_type = static_cast<BuiltinOperator>(reg->builtin_code);
+    auto op_type =
+        flatbuffer_op_index_to_registration_types_[op->opcode_index()];
     if (op_type != BuiltinOperator_CUSTOM && op->custom_options()) {
       error_reporter_->Report(
           "Found builtin operator %s with custom options.\n",
index a7d7f3e..5a55b03 100644 (file)
@@ -188,6 +188,7 @@ 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;
 };