*************************************************************/
// dump graph to .dot
- neurun::dumper::dot::DotDumper dot_dumper(*_graph);
- dot_dumper.dumpIfNeeded("before_lower");
+ auto dump_level =
+ static_cast<dumper::dot::DotDumper::Level>(util::getConfigInt(util::config::GRAPH_DOT_DUMP));
+ neurun::dumper::dot::DotDumper dot_dumper(*_graph, dump_level);
+ dot_dumper.dump("before_lower");
// Lower: decide backend
_graph->lower();
_state = State::LOWERED;
- dot_dumper.dumpIfNeeded("after_lower");
+ dot_dumper.dump("after_lower");
const std::string executor_str = util::getConfigString(util::config::EXECUTOR);
using namespace neurun::graph;
-void DotDumper::dumpIfNeeded(const std::string &tag)
+void DotDumper::dump(const std::string &tag)
{
- if (_option == OPTIONS::DUMP_OFF)
+ if (_level == Level::OFF)
{
return;
}
+
neurun::dumper::dot::DotBuilder dot_builder;
auto &operations = _graph.operations();
operands.iterate([&](const model::OperandIndex &index, const model::Operand &object) {
bool showing_cond = false;
- if (_option == OPTIONS::SHOW_CONSTANTS)
+ if (_level == Level::ALL)
{
showing_cond = true;
}
*/
#include "graph/Graph.h"
-#include "util/ConfigSource.h"
#ifndef __NEURUN_DUMPER_DOT_DOT_DUMPER_H__
#define __NEURUN_DUMPER_DOT_DOT_DUMPER_H__
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)
+ enum Level
{
- _option = util::getConfigInt(util::config::GRAPH_DOT_DUMP);
- }
+ 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 neurun::graph::Graph &graph, Level level) : _graph(graph), _level{level} {}
public:
/**
* @param[in] tag The name of dot file that would be created
* @return N/A
*/
- void dumpIfNeeded(const std::string &tag);
+ void dump(const std::string &tag);
private:
const neurun::graph::Graph &_graph;
- uint32_t _option;
+ Level _level;
};
} // namespace dot