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
22#include <moco/Support/NodeAs.h>
23
24namespace moco
25{
26namespace test
27{
28
29template <typename T> T *find_first_node_bytype(loco::Graph *g)
30{
31 for (auto node : loco::active_nodes(loco::output_nodes(g)))
32 {
33 if (auto T_node = as<T>(node))
34 {
35 return T_node;
36 }
37 }
38
39 return nullptr;
40}
41
42template <typename T> std::vector<T *> find_nodes_bytype(loco::Graph *g)
43{
44 std::vector<T *> find_nodes;
45
46 for (auto node : loco::active_nodes(loco::output_nodes(g)))
47 {
48 if (auto T_node = as<T>(node))
49 {
50 find_nodes.push_back(T_node);
51 }
52 }
53
54 return find_nodes;
55}
56
62void setup_output_node(loco::Graph *graph, loco::Node *last_node);
63
64} // namespace test
65} // namespace moco
66
67#endif // __TEST_HELPER_H__
A neural network graph.
Definition Graph.h:161
Logical unit of computation.
Definition Node.h:54
std::set< loco::Node * > active_nodes(const std::vector< loco::Node * > &roots)
Enumerate all the nodes required to compute "roots".
std::vector< Node * > output_nodes(Graph *)
Definition Graph.cpp:101
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