ONE - On-device Neural Engine
Loading...
Searching...
No Matches
TestHelper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __TEST_HELPER_H__
18#define __TEST_HELPER_H__
19
20#include <loco.h>
21
22namespace moco
23{
24namespace test
25{
26
27template <typename T> T *find_first_node_bytype(loco::Graph *g)
28{
29 T *first_node = nullptr;
30 loco::Graph::NodeContext *nodes = g->nodes();
31 uint32_t count = nodes->size();
32
33 for (uint32_t i = 0; i < count; ++i)
34 {
35 first_node = dynamic_cast<T *>(nodes->at(i));
36 if (first_node != nullptr)
37 break;
38 }
39
40 return first_node;
41}
42
43template <typename T> std::vector<T *> find_nodes_bytype(loco::Graph *g)
44{
45 std::vector<T *> find_nodes;
46 loco::Graph::NodeContext *nodes = g->nodes();
47 uint32_t count = nodes->size();
48
49 for (uint32_t i = 0; i < count; ++i)
50 {
51 auto node = dynamic_cast<T *>(nodes->at(i));
52 if (node != nullptr)
53 find_nodes.push_back(node);
54 }
55
56 return find_nodes;
57}
58
64void setup_output_node(loco::Graph *graph, loco::Node *last_node);
65
66} // namespace test
67} // namespace moco
68
69#endif // __TEST_HELPER_H__
A neural network graph.
Definition Graph.h:161
Logical unit of computation.
Definition Node.h:54
T * at(uint32_t n) const
Access N-th object.
Definition ObjectPool.h:41
uint32_t size(void) const
Return the number of objects.
Definition ObjectPool.h:38
T * find_first_node_bytype(loco::Graph *g)
Definition TestHelper.h:35
void setup_output_node(loco::Graph *graph, loco::Node *last_node)
Append setup output of graph by adding loco::Push node.
std::vector< T * > find_nodes_bytype(loco::Graph *g)
Definition TestHelper.h:42
Definition Log.h:23