diff options
Diffstat (limited to 'runtimes/neurun/src/dumper')
-rw-r--r-- | runtimes/neurun/src/dumper/dot/DotBuilder.cc | 85 | ||||
-rw-r--r-- | runtimes/neurun/src/dumper/dot/DotBuilder.h | 79 | ||||
-rw-r--r-- | runtimes/neurun/src/dumper/dot/DotDumper.cc | 115 | ||||
-rw-r--r-- | runtimes/neurun/src/dumper/dot/DotDumper.h | 63 | ||||
-rw-r--r-- | runtimes/neurun/src/dumper/dot/DotNodeInfo.cc | 108 | ||||
-rw-r--r-- | runtimes/neurun/src/dumper/dot/DotNodeInfo.h | 71 | ||||
-rw-r--r-- | runtimes/neurun/src/dumper/dot/DotOperandInfo.cc | 129 | ||||
-rw-r--r-- | runtimes/neurun/src/dumper/dot/DotOperandInfo.h | 77 | ||||
-rw-r--r-- | runtimes/neurun/src/dumper/dot/IDotInfo.h | 67 |
9 files changed, 794 insertions, 0 deletions
diff --git a/runtimes/neurun/src/dumper/dot/DotBuilder.cc b/runtimes/neurun/src/dumper/dot/DotBuilder.cc new file mode 100644 index 000000000..d694323b4 --- /dev/null +++ b/runtimes/neurun/src/dumper/dot/DotBuilder.cc @@ -0,0 +1,85 @@ +/* + * 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 neurun +{ +namespace dumper +{ +namespace dot +{ + +// NodeAttr +NodeAttr &NodeAttr::addAttr(const std::string &name, const std::string &attr) +{ + _attrs.emplace_back(name, attr); + + return *this; +} + +void NodeAttr::finish() +{ + _attr_stream << "["; + for (auto attr : _attrs) + { + _attr_stream << attr.first << "=" + << "\"" << attr.second << "\" "; + } + _attr_stream << "];\n"; +} + +// DotDumper +DotBuilder::DotBuilder() {} + +void DotBuilder::update(const IDotInfo &node_info) +{ + addNode(node_info); + for (auto child : node_info.children()) + { + addEdge(node_info, *child); + } +} + +void DotBuilder::writeDot(std::ostream &os) +{ + os << "digraph D {\n" + << _dot.str() << "\n" + << "}\n"; +} + +void DotBuilder::addNode(const IDotInfo &dotinfo) +{ + NodeAttr attr; + attr.addAttr("shape", dotinfo.dot_shape()) + .addAttr("label", dotinfo.label()) + .addAttr("style", "filled") + .addAttr("colorscheme", dotinfo.bg_color_scheme()) + .addAttr("fillcolor", dotinfo.bg_color()); + + attr.finish(); + + _dot << dotinfo.index_str() << attr.attr_stream(); +} + +void DotBuilder::addEdge(const IDotInfo &dotinfo1, const IDotInfo &dotinfo2) +{ + _dot << dotinfo1.index_str() << " -> " << dotinfo2.index_str() << ";\n"; +} + +} // namespace dot +} // namespace dumper +} // namespace neurun diff --git a/runtimes/neurun/src/dumper/dot/DotBuilder.h b/runtimes/neurun/src/dumper/dot/DotBuilder.h new file mode 100644 index 000000000..783e92b80 --- /dev/null +++ b/runtimes/neurun/src/dumper/dot/DotBuilder.h @@ -0,0 +1,79 @@ +/* + * 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 __NEURUN_DUMPER_DOT_DOT_BUILDER_H__ +#define __NEURUN_DUMPER_DOT_DOT_BUILDER_H__ + +#include <sstream> + +#include "model/operation/Index.h" +#include "model/operand/Index.h" + +#include "model/operation/Node.h" +#include "model/operand/Object.h" + +#include "DotNodeInfo.h" +#include "DotOperandInfo.h" + +using Node = neurun::model::operation::Node; +using Object = neurun::model::operand::Object; + +namespace neurun +{ +namespace dumper +{ +namespace dot +{ + +class NodeAttr +{ +public: + NodeAttr() = default; + +public: + void finish(); + NodeAttr &addAttr(const std::string &name, const std::string &attr); + +public: + std::stringbuf *attr_stream() { return _attr_stream.rdbuf(); } + +private: + std::vector<std::pair<std::string, std::string>> _attrs; + std::stringstream _attr_stream; +}; + +class DotBuilder +{ +public: + DotBuilder(); + +public: + void update(const IDotInfo &dotinfo); + + void writeDot(std::ostream &os); + +private: + void addNode(const IDotInfo &dotinfo); + void addEdge(const IDotInfo &dotinfo1, const IDotInfo &dotinfo2); + + std::stringstream _dot; +}; + +} // namespace dot +} // namespace dumper +} // namespace neurun + +#endif // __NEURUN_DUMPER_DOT_DOT_BUILDER_H__ diff --git a/runtimes/neurun/src/dumper/dot/DotDumper.cc b/runtimes/neurun/src/dumper/dot/DotDumper.cc new file mode 100644 index 000000000..1e53ece19 --- /dev/null +++ b/runtimes/neurun/src/dumper/dot/DotDumper.cc @@ -0,0 +1,115 @@ +/* + * 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 "DotDumper.h" +#include "DotBuilder.h" + +namespace neurun +{ +namespace dumper +{ +namespace dot +{ + +using namespace neurun::graph; + +void DotDumper::dumpIfNeeded(const std::string &tag) +{ + if (_option == OPTIONS::DUMP_OFF) + { + return; + } + neurun::dumper::dot::DotBuilder dot_builder; + + auto &operations = _graph.operations(); + auto &operands = _graph.operands(); + + operations.iterate([&](const model::operation::Index &index, const model::operation::Node &node) { + neurun::dumper::dot::DotNodeInfo node_info(_graph, index, node); + + for (auto output : node.getOutputs()) + { + using neurun::dumper::dot::DotOperandInfo; + auto child = std::make_shared<DotOperandInfo>(output, operands.at(output), + DotOperandInfo::Type::MODEL_OUTPUT); + node_info.appendChild(child); + } + + dot_builder.update(node_info); + }); + + operands.iterate([&](const model::operand::Index &index, const model::operand::Object &object) { + bool showing_cond = false; + auto usage = object.getUsage(); + if (_option == OPTIONS::SHOW_CONSTANTS) + { + showing_cond = object.usageIsDefined(); + } + else + { + showing_cond = (usage == model::operand::OperandUsage::MODEL_INPUT) || + (usage == model::operand::OperandUsage::OPERATION_OUTPUT); + } + if (usage != model::operand::OperandUsage::OPERATION_OUTPUT) + { + showing_cond = showing_cond && (object.getUses().size() > 0); + } + if (showing_cond) + { + auto type = [&]() { + using neurun::dumper::dot::DotOperandInfo; + if (_graph.getInputs().contains(index)) + return DotOperandInfo::Type::MODEL_INPUT; + if (_graph.getOutputs().contains(index)) + return DotOperandInfo::Type::MODEL_OUTPUT; + return DotOperandInfo::Type::INTERNAL; + }(); + + neurun::dumper::dot::DotOperandInfo operand_info(index, object, type); + + for (auto operation_index : object.getUses().list()) + { + auto &node = operations.at(operation_index); + auto child = + std::make_shared<neurun::dumper::dot::DotNodeInfo>(_graph, operation_index, node); + operand_info.appendChild(child); + } + + dot_builder.update(operand_info); + } + }); + + // 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 neurun diff --git a/runtimes/neurun/src/dumper/dot/DotDumper.h b/runtimes/neurun/src/dumper/dot/DotDumper.h new file mode 100644 index 000000000..0c0a9b8df --- /dev/null +++ b/runtimes/neurun/src/dumper/dot/DotDumper.h @@ -0,0 +1,63 @@ +/* + * 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 "graph/Graph.h" +#include "util/config/ConfigManager.h" + +#ifndef __NEURUN_DUMPER_DOT_DOT_DUMPER_H__ +#define __NEURUN_DUMPER_DOT_DOT_DUMPER_H__ + +namespace neurun +{ +namespace dumper +{ +namespace dot +{ + +enum OPTIONS +{ + DUMP_OFF = 0, // Don't dump + DEFAULT = 1, // Show default dot graph + SHOW_CONSTANTS // Show dot graph with input constants +}; + +class DotDumper +{ +public: + DotDumper(const neurun::graph::Graph &graph) : _graph(graph) + { + _option = config::ConfigManager::instance().get<int>("GRAPH_DOT_DUMP"); + } + +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 dumpIfNeeded(const std::string &tag); + +private: + const neurun::graph::Graph &_graph; + uint32_t _option; +}; + +} // namespace dot +} // namespace dumper +} // namespace neurun + +#endif // __NEURUN_DUMPER_DOT_DOT_DUMPER_H__ diff --git a/runtimes/neurun/src/dumper/dot/DotNodeInfo.cc b/runtimes/neurun/src/dumper/dot/DotNodeInfo.cc new file mode 100644 index 000000000..aefe12e2a --- /dev/null +++ b/runtimes/neurun/src/dumper/dot/DotNodeInfo.cc @@ -0,0 +1,108 @@ +/* + * 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 "DotNodeInfo.h" +#include "graph/Graph.h" +#include "graph/operation/LowerInfo.h" +#include "backend/interface/IConfig.h" + +namespace neurun +{ +namespace dumper +{ +namespace dot +{ + +const std::string DotNodeInfo::NODE_SHAPE = "rect"; +const std::string DotNodeInfo::BG_COLOR_SCHEME = "pastel18"; +// RED BLUE ORANGE YELLOW GREEN PUPLE CYAN PINK +const std::string DotNodeInfo::BG_COLORS[8] = {"1", "2", "5", "6", "3", "4", "7", "8"}; + +DotNodeInfo::DotNodeInfo(const neurun::graph::Graph &graph, + const neurun::model::operation::Index &index, + const neurun::model::operation::Node &node) + : _index(index), _node(node), _lower_info(graph.getLowerInfo(index)) +{ + addBackendLabel(); +} + +std::string DotNodeInfo::index_str() const +{ + std::stringstream ss; + ss << "node" << _index.value(); + + return ss.str(); +} + +std::string DotNodeInfo::label() const +{ + std::stringstream ss; + ss << _index.value() << " : " << _node.getName() << std::endl; + for (auto label : _labels) + { + ss << label << std::endl; + } + + return ss.str(); +} + +std::string DotNodeInfo::dot_shape() const { return NODE_SHAPE; } + +std::string DotNodeInfo::bg_color_scheme() const { return BG_COLOR_SCHEME; } + +std::string DotNodeInfo::bg_color() const +{ + if (!_lower_info) + return DEFAULT_BG_COLOR; + assert(_lower_info != nullptr); + const auto &backend = _lower_info->backend(); + assert(backend != nullptr); + + std::string backend_id = backend->config()->id(); + // TODO : This is just workaround it can be made more efficient. + if (backend_id == "acl_cl") + { + return BG_COLORS[RED]; + } + else if (backend_id == "cpu") + { + return BG_COLORS[BLUE]; + } + else + { + return DEFAULT_BG_COLOR; + } +} + +void DotNodeInfo::addBackendLabel() +{ + if (!_lower_info) + return; + + std::string label; + const auto &backend = _lower_info->backend(); + assert(backend != nullptr); + + label += "[Backend] : "; + label += backend->config()->id(); + _labels.emplace_back(label); +} + +} // namespace dot +} // namespace dumper +} // namespace neurun diff --git a/runtimes/neurun/src/dumper/dot/DotNodeInfo.h b/runtimes/neurun/src/dumper/dot/DotNodeInfo.h new file mode 100644 index 000000000..656a05af6 --- /dev/null +++ b/runtimes/neurun/src/dumper/dot/DotNodeInfo.h @@ -0,0 +1,71 @@ +/* + * 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 __NEURUN_DUMPER_DOT_DOT_NODE_INFO_H__ +#define __NEURUN_DUMPER_DOT_DOT_NODE_INFO_H__ + +#include "IDotInfo.h" +#include "model/operation/Node.h" +#include "model/operation/Index.h" + +namespace neurun +{ +namespace graph +{ +class Graph; +} // namespace graph +} // namespace neurun + +namespace neurun +{ +namespace dumper +{ +namespace dot +{ + +class DotNodeInfo : public IDotInfo +{ +public: + static const std::string NODE_SHAPE; + static const std::string BG_COLOR_SCHEME; + static const std::string BG_COLORS[8]; + +public: + DotNodeInfo(const neurun::graph::Graph &graph, const neurun::model::operation::Index &index, + const neurun::model::operation::Node &node); + +public: + virtual std::string index_str() const override; + virtual std::string label() const override; + virtual std::string dot_shape() const override; + virtual std::string bg_color_scheme() const override; + virtual std::string bg_color() const override; + +private: + void addBackendLabel(); + +private: + neurun::model::operation::Index _index; + const neurun::model::operation::Node &_node; + const neurun::graph::operation::LowerInfo *_lower_info; + std::vector<std::string> _labels; +}; + +} // namespace dot +} // namespace dumper +} // namespace neurun + +#endif // __NEURUN_DUMPER_DOT_DOT_NODE_INFO_H__ diff --git a/runtimes/neurun/src/dumper/dot/DotOperandInfo.cc b/runtimes/neurun/src/dumper/dot/DotOperandInfo.cc new file mode 100644 index 000000000..8f5905020 --- /dev/null +++ b/runtimes/neurun/src/dumper/dot/DotOperandInfo.cc @@ -0,0 +1,129 @@ +/* + * 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 "DotOperandInfo.h" +#include "graph/operand/LowerInfo.h" +#include "backend/interface/IConfig.h" +#include "backend/BackendManager.h" + +namespace neurun +{ +namespace dumper +{ +namespace dot +{ + +const std::string DotOperandInfo::INPUT_SHAPE = "doublecircle"; +const std::string DotOperandInfo::OUTPUT_SHAPE = "doublecircle"; +const std::string DotOperandInfo::OPERAND_SHAPE = "ellipse"; +const std::string DotOperandInfo::BG_COLOR_SCHEME = "set38"; +// RED BLUE ORANGE YELLOW GREEN PUPLE CYAN PINK +const std::string DotOperandInfo::BG_COLORS[8] = {"4", "5", "6", "2", "7", "3", "1", "8"}; + +DotOperandInfo::DotOperandInfo(const neurun::model::operand::Index &index, + const neurun::model::operand::Object &object, Type type) + : _index(index), _object(object), _type(type) +{ + const auto &lower_info = object.lower_info(); + if (lower_info) + { + addBackendLabel(); + } +} + +std::string DotOperandInfo::index_str() const +{ + std::stringstream ss; + ss << "obj" << _index.value(); + + return ss.str(); +} + +std::string DotOperandInfo::label() const +{ + std::stringstream ss; + ss << _index.value() << std::endl; + for (auto label : _labels) + { + ss << label << std::endl; + } + + return ss.str(); +} + +std::string DotOperandInfo::dot_shape() const +{ + 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; + } +} + +std::string DotOperandInfo::bg_color_scheme() const { return BG_COLOR_SCHEME; } + +std::string DotOperandInfo::bg_color() const +{ + const auto &lower_info = _object.lower_info(); + if (!lower_info) + return DEFAULT_BG_COLOR; + assert(lower_info != nullptr); + const auto &def_backends = lower_info->def_backends(); + assert(def_backends.size() == 1); + + std::string backend_id = def_backends.getOnlyElement()->config()->id(); + // TODO : This is just workaround it can be made more efficient. + if (backend_id == "acl_cl") + { + return BG_COLORS[RED]; + } + else if (backend_id == "cpu") + { + return BG_COLORS[BLUE]; + } + else + { + return DEFAULT_BG_COLOR; + } +} + +void DotOperandInfo::addBackendLabel() +{ + std::string label; + const auto &lower_info = _object.lower_info(); + assert(lower_info != nullptr); + const auto &def_backends = lower_info->def_backends(); + assert(def_backends.size() == 1); + + label += "["; + label += def_backends.getOnlyElement()->config()->id(); + label += "]"; + _labels.emplace_back(label); +} + +} // namespace dot +} // namespace dumper +} // namespace neurun diff --git a/runtimes/neurun/src/dumper/dot/DotOperandInfo.h b/runtimes/neurun/src/dumper/dot/DotOperandInfo.h new file mode 100644 index 000000000..c54da444d --- /dev/null +++ b/runtimes/neurun/src/dumper/dot/DotOperandInfo.h @@ -0,0 +1,77 @@ +/* + * 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 __NEURUN_DUMPER_DOT_DOT_OPERAND_INFO_H__ +#define __NEURUN_DUMPER_DOT_DOT_OPERAND_INFO_H__ + +#include <vector> + +#include "IDotInfo.h" +#include "model/operand/Object.h" +#include "model/operand/Index.h" + +namespace neurun +{ +namespace dumper +{ +namespace dot +{ + +class DotOperandInfo : public IDotInfo +{ +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; + static const std::string BG_COLORS[8]; + +public: + DotOperandInfo(const neurun::model::operand::Index &index, + const neurun::model::operand::Object &object, Type type); + +public: + virtual std::string index_str() const override; + virtual std::string label() const override; + virtual std::string dot_shape() const override; + virtual std::string bg_color_scheme() const override; + virtual std::string bg_color() const override; + +private: + void addBackendLabel(); + +private: + const neurun::model::operand::Index &_index; + const neurun::model::operand::Object &_object; + Type _type; + + std::vector<std::string> _labels; +}; + +} // namespace dot +} // namespace dumper +} // namespace neurun + +#endif // __NEURUN_DUMPER_DOT_DOT_OPERAND_INFO_H__ diff --git a/runtimes/neurun/src/dumper/dot/IDotInfo.h b/runtimes/neurun/src/dumper/dot/IDotInfo.h new file mode 100644 index 000000000..d507e724a --- /dev/null +++ b/runtimes/neurun/src/dumper/dot/IDotInfo.h @@ -0,0 +1,67 @@ +/* + * 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 __NEURUN_DUMPER_DOT_IDOTINFO_H__ +#define __NEURUN_DUMPER_DOT_IDOTINFO_H__ + +#include <string> +#include <memory> +#include <vector> + +namespace neurun +{ +namespace dumper +{ +namespace dot +{ + +#define DEFAULT_BG_COLOR_SCHEME "x11" +#define DEFAULT_BG_COLOR "white" + +enum BGCOLORS : int +{ + RED, + BLUE, + ORANGE, + YELLOW, + GREEN, + PUPLE, + CYAN, + PINK +}; + +struct IDotInfo +{ + virtual ~IDotInfo() = default; + + virtual std::string index_str() const = 0; + virtual std::string label() const = 0; + virtual std::string dot_shape() const = 0; + virtual std::string bg_color_scheme() const { return DEFAULT_BG_COLOR_SCHEME; } + virtual std::string bg_color() const { return DEFAULT_BG_COLOR; } + + void appendChild(std::shared_ptr<IDotInfo> dotinfo) { _children.emplace_back(dotinfo); } + const std::vector<std::shared_ptr<IDotInfo>> &children() const { return _children; } + +private: + std::vector<std::shared_ptr<IDotInfo>> _children; +}; + +} // namespace dot +} // namespace dumper +} // namespace neurun + +#endif // __NEURUN_DUMPER_DOT_IDOTINFO_H__ |