diff options
author | Chunseok Lee <chunseok.lee@samsung.com> | 2020-10-29 13:12:50 +0900 |
---|---|---|
committer | Chunseok Lee <chunseok.lee@samsung.com> | 2020-10-29 13:12:50 +0900 |
commit | d6b371e095d737922187a518b8faba1ef6f3a2b1 (patch) | |
tree | 9d90c09c887b5111389dbedf924f59206411cd5a /runtime/onert/core/src/dumper | |
parent | c55f8a6db48cda9d3a78048338b7f18c4cca62b8 (diff) | |
download | nnfw-d6b371e095d737922187a518b8faba1ef6f3a2b1.tar.gz nnfw-d6b371e095d737922187a518b8faba1ef6f3a2b1.tar.bz2 nnfw-d6b371e095d737922187a518b8faba1ef6f3a2b1.zip |
Imported Upstream version 0.4upstream/0.4
Diffstat (limited to 'runtime/onert/core/src/dumper')
-rw-r--r-- | runtime/onert/core/src/dumper/dot/DotBuilder.cc | 83 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/DotBuilder.h | 62 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/DotDumper.cc | 201 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/DotDumper.h | 69 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/DotSubgraphInfo.cc | 58 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/DotSubgraphInfo.h | 61 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/Node.cc | 56 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/Node.h | 127 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/OperandNode.cc | 60 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/OperandNode.h | 79 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/OperationNode.cc | 46 | ||||
-rw-r--r-- | runtime/onert/core/src/dumper/dot/OperationNode.h | 62 |
12 files changed, 0 insertions, 964 deletions
diff --git a/runtime/onert/core/src/dumper/dot/DotBuilder.cc b/runtime/onert/core/src/dumper/dot/DotBuilder.cc deleted file mode 100644 index 38a69696e..000000000 --- a/runtime/onert/core/src/dumper/dot/DotBuilder.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "DotBuilder.h" - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -// DotDumper -DotBuilder::DotBuilder() {} - -void DotBuilder::update(const Node &node_info) -{ - add(node_info); - for (auto edge : node_info.out_edges()) - { - addEdge(node_info, *edge); - } -} - -void DotBuilder::addOpSequence(const DotSubgraphInfo &subgraph_info) -{ - _dot << "subgraph cluster_" << subgraph_info.index().value() << " {\n"; - _dot << " label=\"" << subgraph_info.label() << "\";\n"; - _dot << " style=filled;\n"; - _dot << " color=lightgrey;\n"; - _dot << " "; - for (auto op : subgraph_info.operations()) - { - _dot << "operation" << op.value() << "; "; - } - for (auto op : subgraph_info.operands()) - { - _dot << "operand" << op.value() << "; "; - } - _dot << "\n"; - _dot << "}\n"; -} - -void DotBuilder::writeDot(std::ostream &os) -{ - os << "digraph D {\n" - << _dot.str() << "\n" - << "}\n"; -} - -void DotBuilder::add(const Node &node) -{ - _dot << node.id(); - std::stringstream ss; - _dot << "["; - for (auto attr : node.attributes()) - { - _dot << attr.first << "=\"" << attr.second << "\" "; - } - _dot << "];\n"; -} - -void DotBuilder::addEdge(const Node &node1, const Node &node2) -{ - _dot << node1.id() << " -> " << node2.id() << ";\n"; -} - -} // namespace dot -} // namespace dumper -} // namespace onert diff --git a/runtime/onert/core/src/dumper/dot/DotBuilder.h b/runtime/onert/core/src/dumper/dot/DotBuilder.h deleted file mode 100644 index 681cbbf5d..000000000 --- a/runtime/onert/core/src/dumper/dot/DotBuilder.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __ONERT_DUMPER_DOT_DOT_BUILDER_H__ -#define __ONERT_DUMPER_DOT_DOT_BUILDER_H__ - -#include <sstream> - -#include "ir/Index.h" -#include "ir/Operation.h" -#include "ir/Operand.h" - -#include "OperationNode.h" -#include "OperandNode.h" -#include "DotSubgraphInfo.h" - -using Operation = onert::ir::Operation; -using Object = onert::ir::Operand; - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -class DotBuilder -{ -public: - DotBuilder(); - -public: - void update(const Node &dotinfo); - void addOpSequence(const DotSubgraphInfo &subgraph_info); - - void writeDot(std::ostream &os); - -private: - void add(const Node &dotinfo); - void addEdge(const Node &dotinfo1, const Node &dotinfo2); - - std::stringstream _dot; -}; - -} // namespace dot -} // namespace dumper -} // namespace onert - -#endif // __ONERT_DUMPER_DOT_DOT_BUILDER_H__ diff --git a/runtime/onert/core/src/dumper/dot/DotDumper.cc b/runtime/onert/core/src/dumper/dot/DotDumper.cc deleted file mode 100644 index 8f3cf328c..000000000 --- a/runtime/onert/core/src/dumper/dot/DotDumper.cc +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <fstream> -#include <unordered_map> - -#include "DotDumper.h" -#include "DotBuilder.h" -#include "DotSubgraphInfo.h" -#include "ir/OpSequence.h" -#include "ir/OperationIndexMap.h" -#include "backend/Backend.h" -#include "backend/IConfig.h" -#include "compiler/BackendManager.h" - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -void DotDumper::dump(const std::string &tag) -{ - if (_level == Level::OFF) - { - return; - } - - onert::dumper::dot::DotBuilder dot_builder; - - auto &operations = _graph.operations(); - auto &operands = _graph.operands(); - - ir::OperationIndexMap<std::unique_ptr<Operation>> operation_nodes; - std::unordered_map<ir::OperandIndex, std::unique_ptr<Operand>> operand_nodes; - - auto backend_to_fillcolor = [](const backend::Backend *backend) { - static const auto map = []() { - std::unordered_map<const backend::Backend *, std::string> ret; - uint32_t index = 1; // Start from 1 to avoid 0(red) which is too dark :( - for (const auto backend : compiler::BackendManager::get().getAll()) - { - ret.emplace(backend, Node::BG_COLORS[index]); - index = (index + 1) % (sizeof(Node::BG_COLORS) / sizeof(Node::BG_COLORS[0])); - } - return ret; - }(); - - auto itr = map.find(backend); - if (itr == map.end()) - { - return Node::DEFAULT_FILLCOLOR; - } - else - { - return itr->second; - } - }; - - util::Set<ir::OperandIndex> shown_operand_set; - - operands.iterate([&](const ir::OperandIndex &index, const ir::Operand &object) { - bool showing_cond = false; - if (_level == Level::ALL) - { - showing_cond = true; - } - else - { - showing_cond = - !object.isConstant() || (_graph.getInputs() + _graph.getOutputs()).contains(index); - } - if (showing_cond) - { - shown_operand_set.add(index); - - auto type = [&]() { - using onert::dumper::dot::Operand; - if (_graph.getInputs().contains(index)) - return Operand::Type::MODEL_INPUT; - if (_graph.getOutputs().contains(index)) - return Operand::Type::MODEL_OUTPUT; - return Operand::Type::INTERNAL; - }(); - - auto node = std::make_unique<Operand>(index, type); - - { - // Display LowerInfo attributes - std::string label = std::to_string(index.value()); - std::string fillcolor = ""; - if (_lowered_graph) - { - auto lower_info = _lowered_graph->getLowerInfo(index); - const auto &def_factors = lower_info->def_factors(); - if (def_factors.size() > 0) - { - label += "\\n["; - label += def_factors.getOnlyElement().backend()->config()->id(); - label += "]"; - - fillcolor = backend_to_fillcolor(lower_info->def_factors().getOnlyElement().backend()); - } - } - node->setAttribute("label", label); - node->setAttribute("fillcolor", fillcolor); - } - - operand_nodes.emplace(index, std::move(node)); - } - }); - - operations.iterate([&](const ir::OperationIndex &index, const ir::Operation &op) { - auto node = std::make_unique<Operation>(index, op); - - for (auto input : op.getInputs()) - { - using onert::dumper::dot::Operand; - - // Constant input and dump level is ALL_BUT_CONSTANTS - if (operand_nodes.find(input) == operand_nodes.end()) - continue; - - auto &input_node = operand_nodes.at(input); - input_node->addOutEdge(node.get()); - } - - for (auto output : op.getOutputs()) - { - using onert::dumper::dot::Operand; - auto &output_node = operand_nodes.at(output); - node->addOutEdge(output_node.get()); - } - - operation_nodes.emplace(index, std::move(node)); - }); - - if (_lowered_graph) - { - const auto &op_seqs = _lowered_graph->op_seqs(); - op_seqs.iterate([&](const ir::OpSequenceIndex &index, const ir::OpSequence &op_seq) { - const auto lower_info = _lowered_graph->getLowerInfo(index); - auto fillcolor = backend_to_fillcolor(lower_info->backend()); - std::string label = - std::to_string(index.value()) + " [" + lower_info->backend()->config()->id() + "]"; - DotSubgraphInfo subgraph_info{index, op_seq, shown_operand_set, _graph.operations()}; - subgraph_info.label(label); - subgraph_info.fillcolor(fillcolor); - dot_builder.addOpSequence(subgraph_info); - - // Set fillcolor of all operations in the op_seq - for (const auto &op_idx : op_seq.operations()) - { - auto found = operation_nodes.find(op_idx); - if (found != operation_nodes.end()) - { - auto &&op = found->second; - op->setAttribute("fillcolor", fillcolor); - } - } - }); - } - - for (const auto &e : operation_nodes) - dot_builder.update(*e.second); - for (const auto &e : operand_nodes) - dot_builder.update(*e.second); - - // Dump to file - { - std::string file_name; - file_name += tag; - file_name += ".dot"; - std::filebuf fb; - - fb.open(file_name, std::ios::out); - std::ostream os(&fb); - - dot_builder.writeDot(os); - - fb.close(); - } -} - -} // namespace dot -} // namespace dumper -} // namespace onert diff --git a/runtime/onert/core/src/dumper/dot/DotDumper.h b/runtime/onert/core/src/dumper/dot/DotDumper.h deleted file mode 100644 index fdbca1642..000000000 --- a/runtime/onert/core/src/dumper/dot/DotDumper.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ir/Graph.h" -#include "compiler/LoweredGraph.h" - -#ifndef __ONERT_DUMPER_DOT_DOT_DUMPER_H__ -#define __ONERT_DUMPER_DOT_DOT_DUMPER_H__ - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -class DotDumper -{ -public: - enum Level - { - OFF = 0, //< Do not dump - ALL_BUT_CONSTANTS = 1, //< Emit all operations and operands but constants - ALL = 2 //< Emit all operations and operands - }; - -public: - DotDumper(const ir::Graph &graph, Level level) - : _lowered_graph{nullptr}, _graph(graph), _level{level} - { - } - DotDumper(const compiler::LoweredGraph *lowered_graph, Level level) - : _lowered_graph{lowered_graph}, _graph(_lowered_graph->graph()), _level{level} - { - } - -public: - /** - * @brief Dump to dot file as tag name if "GRAPH_DOT_DUMP" is set - * - * @param[in] tag The name of dot file that would be created - * @return N/A - */ - void dump(const std::string &tag); - -private: - const compiler::LoweredGraph *_lowered_graph; - const ir::Graph &_graph; - Level _level; -}; - -} // namespace dot -} // namespace dumper -} // namespace onert - -#endif // __ONERT_DUMPER_DOT_DOT_DUMPER_H__ diff --git a/runtime/onert/core/src/dumper/dot/DotSubgraphInfo.cc b/runtime/onert/core/src/dumper/dot/DotSubgraphInfo.cc deleted file mode 100644 index 52e9c758d..000000000 --- a/runtime/onert/core/src/dumper/dot/DotSubgraphInfo.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "DotSubgraphInfo.h" - -#include <sstream> - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -DotSubgraphInfo::DotSubgraphInfo(const ir::OpSequenceIndex &index, const ir::OpSequence &op_seq, - const util::Set<ir::OperandIndex> &shown_operands, - const ir::Operations &operations_ctx) - : _index{index} -{ - for (const auto &op_idx : op_seq.operations()) - { - _operations.insert(op_idx); - const auto &node = operations_ctx.at(op_idx); - for (auto o : node.getInputs()) - { - // Must be a shown operand, not op_seq's inputs - if (shown_operands.contains(o) && !op_seq.getInputs().contains(o)) - { - _operands.insert(o); - } - } - for (auto o : node.getOutputs()) - { - // Must be a shown operand, not op_seq's inputs - if (shown_operands.contains(o) && !op_seq.getOutputs().contains(o)) - { - _operands.insert(o); - } - } - } -} - -} // namespace dot -} // namespace dumper -} // namespace onert diff --git a/runtime/onert/core/src/dumper/dot/DotSubgraphInfo.h b/runtime/onert/core/src/dumper/dot/DotSubgraphInfo.h deleted file mode 100644 index 95ba8953e..000000000 --- a/runtime/onert/core/src/dumper/dot/DotSubgraphInfo.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __ONERT_CORE_DUMPER_DOT_DOT_SUBGRAPH_INFO_H__ -#define __ONERT_CORE_DUMPER_DOT_DOT_SUBGRAPH_INFO_H__ - -#include <unordered_set> - -#include "ir/Index.h" -#include <ir/Operations.h> -#include "ir/OpSequence.h" -#include "util/Set.h" - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -class DotSubgraphInfo -{ -public: - DotSubgraphInfo(const ir::OpSequenceIndex &index, const ir::OpSequence &op_seq, - const util::Set<ir::OperandIndex> &shown_operands, - const ir::Operations &operations_ctx); - - ir::OpSequenceIndex index() const { return _index; } - std::string label() const { return _label; } - void label(const std::string &val) { _label = val; } - std::string fillcolor() const { return _fillcolor; } - void fillcolor(const std::string &val) { _fillcolor = val; } - const std::unordered_set<ir::OperationIndex> &operations() const { return _operations; } - const std::unordered_set<ir::OperandIndex> &operands() const { return _operands; } - -private: - ir::OpSequenceIndex _index; - std::string _label; - std::string _fillcolor; - std::unordered_set<ir::OperationIndex> _operations; - std::unordered_set<ir::OperandIndex> _operands; -}; - -} // namespace dot -} // namespace dumper -} // namespace onert - -#endif // __ONERT_CORE_DUMPER_DOT_DOT_SUBGRAPH_INFO_H__ diff --git a/runtime/onert/core/src/dumper/dot/Node.cc b/runtime/onert/core/src/dumper/dot/Node.cc deleted file mode 100644 index 85d6e67a4..000000000 --- a/runtime/onert/core/src/dumper/dot/Node.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Node.h" - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -const std::string Node::DEFAULT_COLORSCHEME = "x11"; -const std::string Node::DEFAULT_FILLCOLOR = "white"; -// RED, BLUE, GREEN, PURPLE, ORANGE, YELLOW, BROWN, PINK -const std::string Node::BG_COLORS[8] = {"1", "2", "3", "4", "5", "6", "7", "8"}; - -Node::Node(const std::string &id) : _id{id} -{ - // Set default values - _attributes["style"] = "filled"; - _attributes["colorscheme"] = DEFAULT_COLORSCHEME; - _attributes["fillcolor"] = DEFAULT_FILLCOLOR; -} - -void Node::setAttribute(const std::string &key, const std::string &val) { _attributes[key] = val; } - -std::string Node::getAttribute(const std::string &key) -{ - auto itr = _attributes.find(key); - if (itr == _attributes.end()) - { - return ""; - } - else - { - return itr->second; - } -} - -} // namespace dot -} // namespace dumper -} // namespace onert diff --git a/runtime/onert/core/src/dumper/dot/Node.h b/runtime/onert/core/src/dumper/dot/Node.h deleted file mode 100644 index 9b09b92e7..000000000 --- a/runtime/onert/core/src/dumper/dot/Node.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file Node.h - * @brief This file contains Node class - * @ingroup COM_AI_RUNTIME - * - */ - -#ifndef __ONERT_DUMPER_DOT_NODE_H__ -#define __ONERT_DUMPER_DOT_NODE_H__ - -#include <string> -#include <memory> -#include <vector> -#include <unordered_map> - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -enum BGCOLORS : int -{ - RED, - BLUE, - GREEN, - PUPLE, - ORANGE, - YELLOW, - BROWN, - PINK -}; - -/** - * @brief Class that represents a Node in "dot" format - * - */ -class Node -{ -public: - const static std::string DEFAULT_FILLCOLOR; - const static std::string DEFAULT_COLORSCHEME; - const static std::string BG_COLORS[8]; - -public: - /** - * @brief Destroy the Node object - * - */ - virtual ~Node() = default; - - /** - * @brief Construct a new Node object - * - * @param id - */ - Node(const std::string &id); - - /** - * @brief return id - * - * @return id - */ - std::string id() const { return _id; } - - /** - * @brief return attributes - * - * @return const reference of attributes object - */ - const std::unordered_map<std::string, std::string> &attributes() const { return _attributes; } - /** - * @brief Store an attribute with key-value pair - * - * @param[in] key attribute's key - * @param[in] val attribute's value that is associated with the key - */ - void setAttribute(const std::string &key, const std::string &val); - /** - * @brief Get the attributte value that is associated with key - * - * @param[in] key key of the attribute - * @return value that is associated with the key - */ - std::string getAttribute(const std::string &key); - - /** - * @brief Add an edge in the graph, which is an outgoing edge - * - * @param[in] dotinfo A node that the new edge will be connected to - */ - void addOutEdge(Node *dotinfo) { _out_edges.emplace_back(dotinfo); } - /** - * @brief Return list of out edges - * - * @return Edges - */ - const std::vector<Node *> &out_edges() const { return _out_edges; } - -private: - std::string _id; - std::unordered_map<std::string, std::string> _attributes; - std::vector<Node *> _out_edges; -}; - -} // namespace dot -} // namespace dumper -} // namespace onert - -#endif // __ONERT_DUMPER_DOT_NODE_H__ diff --git a/runtime/onert/core/src/dumper/dot/OperandNode.cc b/runtime/onert/core/src/dumper/dot/OperandNode.cc deleted file mode 100644 index 5a6015ca9..000000000 --- a/runtime/onert/core/src/dumper/dot/OperandNode.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <sstream> - -#include "OperandNode.h" -#include "ir/Graph.h" -#include "ir/operand/LowerInfo.h" - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -const std::string Operand::INPUT_SHAPE = "doublecircle"; -const std::string Operand::OUTPUT_SHAPE = "doublecircle"; -const std::string Operand::OPERAND_SHAPE = "ellipse"; -const std::string Operand::BG_COLOR_SCHEME = "set18"; - -Operand::Operand(const ir::OperandIndex &index, Type type) - : Node{"operand" + std::to_string(index.value())} -{ - { - auto type_to_shape = [](Type type) { - switch (type) - { - case Type::MODEL_INPUT: - return INPUT_SHAPE; - case Type::MODEL_OUTPUT: - return OUTPUT_SHAPE; - case Type::UNDEFINED: - case Type::INTERNAL: - default: - return OPERAND_SHAPE; - } - }; - setAttribute("shape", type_to_shape(type)); - } - - setAttribute("colorscheme", BG_COLOR_SCHEME); -} - -} // namespace dot -} // namespace dumper -} // namespace onert diff --git a/runtime/onert/core/src/dumper/dot/OperandNode.h b/runtime/onert/core/src/dumper/dot/OperandNode.h deleted file mode 100644 index 2e7cc5861..000000000 --- a/runtime/onert/core/src/dumper/dot/OperandNode.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file Operand.h - * @brief This file contains Operand - * @ingroup COM_AI_RUNTIME - * - */ - -#ifndef __ONERT_DUMPER_DOT_DOT_OPERAND_INFO_H__ -#define __ONERT_DUMPER_DOT_DOT_OPERAND_INFO_H__ - -#include <vector> - -#include "Node.h" -#include "ir/Operand.h" -#include "ir/Index.h" - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -/** - * @brief Class that represents an Operand - * - */ -class Operand : public Node -{ -public: - enum class Type - { - UNDEFINED, - MODEL_INPUT, - MODEL_OUTPUT, - INTERNAL - }; - -public: - static const std::string INPUT_SHAPE; - static const std::string OUTPUT_SHAPE; - static const std::string OPERAND_SHAPE; - static const std::string BG_COLOR_SCHEME; - -public: - /** - * @brief Construct a new Operand Node object - * - * @param[in] index Operand index - * @param[in] type Operand type - * @param[in] lower_info Operand LowerInfo - */ - Operand(const ir::OperandIndex &index, Type type); - -private: - void addBackendLabel(); -}; - -} // namespace dot -} // namespace dumper -} // namespace onert - -#endif // __ONERT_DUMPER_DOT_DOT_OPERAND_INFO_H__ diff --git a/runtime/onert/core/src/dumper/dot/OperationNode.cc b/runtime/onert/core/src/dumper/dot/OperationNode.cc deleted file mode 100644 index bee137e7c..000000000 --- a/runtime/onert/core/src/dumper/dot/OperationNode.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <sstream> - -#include "OperationNode.h" -#include "ir/Graph.h" -#include "ir/operation/LowerInfo.h" -#include "backend/IConfig.h" -#include "backend/Backend.h" - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -const std::string Operation::OPERATION_SHAPE = "rect"; -const std::string Operation::BG_COLOR_SCHEME = "pastel18"; - -Operation::Operation(const ir::OperationIndex &index, const ir::Operation &node) - : Node{"operation" + std::to_string(index.value())} -{ - setAttribute("label", std::to_string(index.value()) + " : " + node.name()); - setAttribute("shape", OPERATION_SHAPE); - setAttribute("colorscheme", BG_COLOR_SCHEME); - setAttribute("fillcolor", DEFAULT_FILLCOLOR); -} - -} // namespace dot -} // namespace dumper -} // namespace onert diff --git a/runtime/onert/core/src/dumper/dot/OperationNode.h b/runtime/onert/core/src/dumper/dot/OperationNode.h deleted file mode 100644 index 74a37d3fb..000000000 --- a/runtime/onert/core/src/dumper/dot/OperationNode.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file Operation.h - * @brief This file contains Operation - * @ingroup COM_AI_RUNTIME - * - */ - -#ifndef __ONERT_DUMPER_DOT_DOT_NODE_INFO_H__ -#define __ONERT_DUMPER_DOT_DOT_NODE_INFO_H__ - -#include "Node.h" -#include "ir/Operation.h" -#include "ir/Index.h" - -namespace onert -{ -namespace dumper -{ -namespace dot -{ - -/** - * @brief Class that represents an Operation - * - */ -class Operation : public Node -{ -public: - static const std::string OPERATION_SHAPE; - static const std::string BG_COLOR_SCHEME; - -public: - /** - * @brief Construct a new Operation Node object - * - * @param[in] index operation index - * @param[in] node operation object - */ - Operation(const ir::OperationIndex &index, const ir::Operation &node); -}; - -} // namespace dot -} // namespace dumper -} // namespace onert - -#endif // __ONERT_DUMPER_DOT_DOT_NODE_INFO_H__ |