aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/interpreter_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/contrib/lite/interpreter_test.cc')
-rw-r--r--tensorflow/contrib/lite/interpreter_test.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/tensorflow/contrib/lite/interpreter_test.cc b/tensorflow/contrib/lite/interpreter_test.cc
index 453c1ada1c..4c78466480 100644
--- a/tensorflow/contrib/lite/interpreter_test.cc
+++ b/tensorflow/contrib/lite/interpreter_test.cc
@@ -211,7 +211,7 @@ TEST(BasicInterpreter, CheckArenaAllocation) {
TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr};
std::vector<int> sizes{2048, 4096, 1023, 2047, 1021,
- 2047, 1023, 2046, 1021, 2048};
+ 2047, 1023, 2046, 0, 2048};
for (int i = 0; i < sizes.size(); ++i) {
interpreter.SetTensorParametersReadWrite(i, kTfLiteUInt8, "", {sizes[i]},
quant);
@@ -228,6 +228,7 @@ TEST(BasicInterpreter, CheckArenaAllocation) {
ASSERT_EQ(interpreter.tensor(0)->data.raw, interpreter.tensor(4)->data.raw);
ASSERT_EQ(interpreter.tensor(1)->data.raw, interpreter.tensor(7)->data.raw);
+ ASSERT_EQ(interpreter.tensor(8)->data.raw, nullptr);
ASSERT_LT(interpreter.tensor(4)->data.raw, interpreter.tensor(1)->data.raw);
ASSERT_LT(interpreter.tensor(6)->data.raw, interpreter.tensor(1)->data.raw);
@@ -314,6 +315,18 @@ TEST(BasicInterpreter, ResizingTensors) {
EXPECT_EQ(tensor->bytes, 8 * sizeof(float));
ASSERT_EQ(interpreter.AllocateTensors(), kTfLiteOk);
+ ASSERT_EQ(interpreter.ResizeInputTensor(t, {}), kTfLiteOk);
+ EXPECT_EQ(tensor->bytes, 1 * sizeof(float));
+ ASSERT_EQ(interpreter.AllocateTensors(), kTfLiteOk);
+
+ ASSERT_EQ(interpreter.ResizeInputTensor(t, {0}), kTfLiteOk);
+ EXPECT_EQ(tensor->bytes, 0);
+ ASSERT_EQ(interpreter.AllocateTensors(), kTfLiteOk);
+
+ ASSERT_EQ(interpreter.ResizeInputTensor(t, {1, 2, 0}), kTfLiteOk);
+ EXPECT_EQ(tensor->bytes, 0);
+ ASSERT_EQ(interpreter.AllocateTensors(), kTfLiteOk);
+
// TODO(ahentz): We shouldn't have to force reallocation, but
// ResizeInputTensor doesn't realloc dynamic tensors. Also note that
// TfLiteTensorRealloc(tensor->bytes, tensor) is a no-op.