The test builds a model that produces the i-th number of triangular number sequence. TODO(ycling): Consider to improve this test case by adding a concat into the body subgraph.
| 37 | // TODO(ycling): Consider to improve this test case by adding a |
| 38 | // concat into the body subgraph. |
| 39 | TEST_F(WhileTest, TestTriangularNumberSequence) { |
| 40 | const std::vector<int> expected = {1, 3, 6, 10, 15, 21, 28}; |
| 41 | for (int i = 0; i < expected.size(); ++i) { |
| 42 | interpreter_.reset(new Interpreter); |
| 43 | interpreter_->AddSubgraphs(2); |
| 44 | builder_->BuildLessEqualCondSubgraph(interpreter_->subgraph(1), i); |
| 45 | builder_->BuildAccumulateLoopBodySubgraph(interpreter_->subgraph(2)); |
| 46 | builder_->BuildWhileSubgraph(&interpreter_->primary_subgraph()); |
| 47 | |
| 48 | interpreter_->ResizeInputTensor(interpreter_->inputs()[0], {1}); |
| 49 | interpreter_->ResizeInputTensor(interpreter_->inputs()[1], {1}); |
| 50 | ASSERT_EQ(interpreter_->AllocateTensors(), kTfLiteOk); |
| 51 | FillIntTensor(interpreter_->tensor(interpreter_->inputs()[0]), {1}); |
| 52 | FillIntTensor(interpreter_->tensor(interpreter_->inputs()[1]), {1}); |
| 53 | |
| 54 | ASSERT_EQ(interpreter_->Invoke(), kTfLiteOk); |
| 55 | TfLiteTensor* output1 = interpreter_->tensor(interpreter_->outputs()[0]); |
| 56 | CheckIntTensor(output1, {1}, {i + 1}); |
| 57 | TfLiteTensor* output2 = interpreter_->tensor(interpreter_->outputs()[1]); |
| 58 | CheckIntTensor(output2, {1}, {expected[i]}); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | TEST_F(WhileTest, TestPadLoop) { |
| 63 | interpreter_.reset(new Interpreter); |
nothing calls this directly
no test coverage detected