ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Index.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 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 __ONERT_IR_INDEX_H__
18#define __ONERT_IR_INDEX_H__
19
20#include "util/Index.h"
21
22#include <iomanip>
23#include <ostream>
24#include <sstream>
25
26namespace onert
27{
28namespace ir
29{
30
31struct OperationIndexTag;
33
34struct OperandIndexTag;
36
37struct IOIndexTag;
39
40struct SubgraphIndexTag;
42
43struct ModelIndexTag;
45
46struct OriginIndexTag;
48
49template <typename IndexType>
50std::ostream &_index_print_impl(std::ostream &o, const std::string &prefix, IndexType index)
51{
52 std::ostringstream oss;
53 if (index.undefined())
54 oss << prefix << std::string("?");
55 else
56 oss << prefix << index.value();
57 return o << std::right << std::setw(4) << oss.str();
58}
59
60inline std::ostream &operator<<(std::ostream &o, const OperationIndex &i)
61{
62 return _index_print_impl(o, "@", i);
63}
64
65inline std::ostream &operator<<(std::ostream &o, const OperandIndex &i)
66{
67 return _index_print_impl(o, "%", i);
68}
69
70inline std::ostream &operator<<(std::ostream &o, const IOIndex &i)
71{
72 return _index_print_impl(o, "IO", i);
73}
74
75inline std::ostream &operator<<(std::ostream &o, const SubgraphIndex &i)
76{
77 return _index_print_impl(o, "SUBGRAPH", i);
78}
79
80inline std::ostream &operator<<(std::ostream &o, const ModelIndex &i)
81{
82 return _index_print_impl(o, "MODEL", i);
83}
84
85inline std::ostream &operator<<(std::ostream &o, const OriginIndex &i)
86{
87 return _index_print_impl(o, "", i);
88}
89} // namespace ir
90} // namespace onert
91
92#endif // __ONERT_IR_INDEX_H__
std::ostream & operator<<(std::ostream &o, const OperationIndex &i)
Definition Index.h:60
std::ostream & _index_print_impl(std::ostream &o, const std::string &prefix, IndexType index)
Definition Index.h:50