Fix bug in populating the execution plan sent to the delegate.
authorAndrew Selle <aselle@google.com>
Tue, 13 Feb 2018 20:24:02 +0000 (12:24 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Tue, 13 Feb 2018 20:27:40 +0000 (12:27 -0800)
- memcpy was missing the array size.
- modified the unit test to verify that the execution plan is
trivial on first delegate invocation.

PiperOrigin-RevId: 185569606

tensorflow/contrib/lite/interpreter.cc
tensorflow/contrib/lite/interpreter_test.cc

index 6dea4e5..0284492 100644 (file)
@@ -166,7 +166,7 @@ TfLiteStatus Interpreter::GetExecutionPlan(TfLiteIntArray** execution_plan) {
   static_assert(sizeof(plan_cache_->data[0]) == sizeof(execution_plan_[0]),
                 "TfLiteIntArray and execution_plan do not contain same type.");
   memcpy(plan_cache_->data, execution_plan_.data(),
-         sizeof(plan_cache_->data[0]));
+         sizeof(plan_cache_->data[0]) * execution_plan_.size());
   return kTfLiteOk;
 }
 
index 4b30974..28c96e5 100644 (file)
@@ -773,6 +773,8 @@ class TestDelegate : public ::testing::Test {
         for (int exec_index = 0; exec_index < execution_plan->size;
              exec_index++) {
           int node_index = execution_plan->data[exec_index];
+          // Check that we are an identity map to start.
+          TFLITE_CHECK_EQ(exec_index, node_index);
           TfLiteNode* node;
           TfLiteRegistration* reg;
           context->GetNodeAndRegistration(context, node_index, &node, &reg);