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
21
22#include <moco/IR/TFNode.h>
23#include <loco.h>
24#include <plier/tf/TestHelper.h>
25
26#include <tensorflow/core/framework/graph.pb.h>
27
28#define STRING_CONTENT(content) #content
29
30namespace moco
31{
32namespace test
33{
34
35template <typename T> T *find_first_node_bytype(loco::Graph *g)
36{
37 T *first_node = nullptr;
38 loco::Graph::NodeContext *nodes = g->nodes();
39 uint32_t count = nodes->size();
40
41 for (uint32_t i = 0; i < count; ++i)
42 {
43 first_node = dynamic_cast<T *>(nodes->at(i));
44 if (first_node != nullptr)
45 break;
46 }
47
48 return first_node;
49}
50
51} // namespace test
52} // namespace moco
53
54namespace moco
55{
56namespace test
57{
58
60{
61public:
63
64public:
65 void inputs(const std::vector<std::string> &names);
66 void inputs(const std::vector<std::string> &names, const loco::DataType dtype);
67 void output(const char *name);
69
70 void run(tensorflow::NodeDef &node_def, moco::GraphBuilder &graph_builder);
71
72private:
73 std::unique_ptr<moco::SymbolTable> _tensor_names;
74 std::unique_ptr<loco::Graph> _graph;
75
76 std::vector<moco::TFNode *> _inputs;
77 const char *_output{nullptr};
78};
79
80} // namespace test
81} // namespace moco
82
83#endif // __TEST_HELPER_H__
A neural network graph.
Definition Graph.h:161
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
Interface of convert TF NodeDef to loco::Node (e.g., Conv2DGraphBuilder)
void inputs(const std::vector< std::string > &names)
void inputs(const std::vector< std::string > &names, const loco::DataType dtype)
void run(tensorflow::NodeDef &node_def, moco::GraphBuilder &graph_builder)
void output(const char *name)
moco::TFNode * output(void)
DataType
"scalar" value type
Definition DataType.h:27
T * find_first_node_bytype(loco::Graph *g)
Definition TestHelper.h:35
Definition Log.h:23