ONE - On-device Neural Engine
Loading...
Searching...
No Matches
FormattedGraph.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 __LOCOP_FORMATTED_GRAPH_H__
18#define __LOCOP_FORMATTED_GRAPH_H__
19
20#include "locop/SymbolTable.h"
21#include "locop/NodeSummary.h"
23// TODO Remove this redundant include
25
26#include <loco.h>
27
28#include <memory>
29#include <ostream>
30#include <string>
31#include <vector>
32
33namespace locop
34{
35
37{
38 virtual ~FormattedGraph() = default;
39
40 virtual void dump(std::ostream &os) const = 0;
41};
42
43std::ostream &operator<<(std::ostream &, const FormattedGraph &);
44
46{
48 // TO BE ADDED
49};
50
51template <Formatter F> class FormattedGraphImpl;
52
53template <> class FormattedGraphImpl<Formatter::LinearV1> final : public FormattedGraph
54{
55public:
56 FormattedGraphImpl(loco::Graph *graph) : _graph{graph} {}
57
58public:
59 void dump(std::ostream &os) const final;
60
61public:
62 FormattedGraphImpl<Formatter::LinearV1> &with(std::unique_ptr<NodeSummaryBuilderFactory> &&f)
63 {
64 _factory = std::move(f);
65 return (*this);
66 }
67
68private:
69 loco::Graph *_graph;
70
74 std::unique_ptr<NodeSummaryBuilderFactory> _factory = nullptr;
75};
76
77template <Formatter F> FormattedGraphImpl<F> fmt(loco::Graph *g)
78{
79 return FormattedGraphImpl<F>{g};
80}
81
82template <Formatter F> FormattedGraphImpl<F> fmt(const std::unique_ptr<loco::Graph> &g)
83{
84 return fmt<F>(g.get());
85}
86
87} // namespace locop
88
89#endif // __LOCOP_FORMATTED_GRAPH_H__
A neural network graph.
Definition Graph.h:161
FormattedGraphImpl< Formatter::LinearV1 > & with(std::unique_ptr< NodeSummaryBuilderFactory > &&f)
void dump(const coco::Op *op, int indent)
Definition Dump.cpp:177
FormattedGraphImpl< F > fmt(loco::Graph *g)
std::ostream & operator<<(std::ostream &, const FormattedGraph &)
virtual void dump(std::ostream &os) const =0
virtual ~FormattedGraph()=default