MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST_F

Function TEST_F

tensorflow/lite/kernels/while_test.cc:39–60  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

37// TODO(ycling): Consider to improve this test case by adding a
38// concat into the body subgraph.
39TEST_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
62TEST_F(WhileTest, TestPadLoop) {
63 interpreter_.reset(new Interpreter);

Callers

nothing calls this directly

Calls 15

FillIntTensorFunction · 0.85
CheckIntTensorFunction · 0.85
AddSubgraphsMethod · 0.80
subgraphMethod · 0.80
BuildWhileSubgraphMethod · 0.80
sizeMethod · 0.45
resetMethod · 0.45
ResizeInputTensorMethod · 0.45
inputsMethod · 0.45

Tested by

no test coverage detected