ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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::ir
27{
28
29struct OperationIndexTag;
31
32struct OperandIndexTag;
34
35struct IOIndexTag;
37
38struct SubgraphIndexTag;
40
41struct ModelIndexTag;
43
44struct OriginIndexTag;
46
47template <typename IndexType>
48std::ostream &_index_print_impl(std::ostream &o, const std::string &prefix, IndexType index)
49{
50 std::ostringstream oss;
51 if (index.undefined())
52 oss << prefix << std::string("?");
53 else
54 oss << prefix << index.value();
55 return o << std::right << std::setw(4) << oss.str();
56}
57
58inline std::ostream &operator<<(std::ostream &o, const OperationIndex &i)
59{
60 return _index_print_impl(o, "@", i);
61}
62
63inline std::ostream &operator<<(std::ostream &o, const OperandIndex &i)
64{
65 return _index_print_impl(o, "%", i);
66}
67
68inline std::ostream &operator<<(std::ostream &o, const IOIndex &i)
69{
70 return _index_print_impl(o, "IO", i);
71}
72
73inline std::ostream &operator<<(std::ostream &o, const SubgraphIndex &i)
74{
75 return _index_print_impl(o, "SUBGRAPH", i);
76}
77
78inline std::ostream &operator<<(std::ostream &o, const ModelIndex &i)
79{
80 return _index_print_impl(o, "MODEL", i);
81}
82
83inline std::ostream &operator<<(std::ostream &o, const OriginIndex &i)
84{
85 return _index_print_impl(o, "", i);
86}
87} // namespace onert::ir
88
89#endif // __ONERT_IR_INDEX_H__
std::ostream & operator<<(std::ostream &o, const OperationIndex &i)
Definition Index.h:58
std::ostream & _index_print_impl(std::ostream &o, const std::string &prefix, IndexType index)
Definition Index.h:48