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

Method TestGraph

tensorflow/lite/arena_planner_test.cc:50–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48class TestGraph {
49 public:
50 TestGraph(std::initializer_list<int> inputs,
51 std::initializer_list<TestOp> nodes,
52 std::initializer_list<int> outputs)
53 : inputs_(inputs), outputs_(outputs) {
54 int max_tensor_index = 0;
55
56 for (int t : inputs) {
57 max_tensor_index = std::max(max_tensor_index, t);
58 }
59 for (int t : outputs) {
60 max_tensor_index = std::max(max_tensor_index, t);
61 }
62 for (const auto& node : nodes) {
63 auto int_array = [](const std::vector<int>& x) {
64 TfLiteIntArray* lite = TfLiteIntArrayCreate(x.size());
65 for (size_t i = 0; i < x.size(); i++) lite->data[i] = x[i];
66 return lite;
67 };
68
69 nodes_.push_back(TfLiteNode());
70 nodes_.back().inputs = int_array(node.inputs());
71 for (int t : node.inputs()) {
72 max_tensor_index = std::max(max_tensor_index, t);
73 }
74 nodes_.back().outputs = int_array(node.outputs());
75 for (int t : node.outputs()) {
76 max_tensor_index = std::max(max_tensor_index, t);
77 }
78 nodes_.back().temporaries = int_array(node.temporaries());
79 for (int t : node.temporaries()) {
80 max_tensor_index = std::max(max_tensor_index, t);
81 }
82 }
83
84 for (int i = 0; i <= max_tensor_index; ++i) {
85 tensors_.push_back(TfLiteTensor());
86 // Set some default values for allocation_type and bytes, which are the
87 // only fields used by the arena planner.
88 tensors_.back().allocation_type = kTfLiteArenaRw;
89 tensors_.back().bytes = (i + 1) * 3;
90 }
91 }
92
93 ~TestGraph() {
94 for (auto node : nodes_) {

Callers

nothing calls this directly

Calls 7

TfLiteIntArrayCreateFunction · 0.85
maxFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
backMethod · 0.45
inputsMethod · 0.45
outputsMethod · 0.45

Tested by

no test coverage detected