| 1276 | } |
| 1277 | |
| 1278 | void module::print_graph(std::ostream& os, bool brief) const |
| 1279 | { |
| 1280 | os << "digraph {" << std::endl; |
| 1281 | os << "\trankdir=LR;" << std::endl; |
| 1282 | |
| 1283 | this->print([&](auto ins, auto ins_names) { |
| 1284 | std::string label; |
| 1285 | if(brief) |
| 1286 | label = ins->name(); |
| 1287 | else |
| 1288 | label = to_string(ins->get_operator()); |
| 1289 | os << "\t" << enclose_name(ins_names.at(ins)) << "[label=" << enclose_name(label) << "]"; |
| 1290 | os << ";" << std::endl; |
| 1291 | if(not ins->inputs().empty()) |
| 1292 | { |
| 1293 | for(auto&& arg : ins->inputs()) |
| 1294 | { |
| 1295 | os << "\t" << enclose_name(ins_names.at(arg)) << " -> " |
| 1296 | << enclose_name(ins_names.at(ins)); |
| 1297 | if(not brief) |
| 1298 | os << "[label=" << enclose_name(to_string(ins->get_shape())) << "]"; |
| 1299 | os << ";" << std::endl; |
| 1300 | } |
| 1301 | } |
| 1302 | }); |
| 1303 | os << "}" << std::endl; |
| 1304 | } |
| 1305 | |
| 1306 | static std::string cpp_var_name(const std::string& name) |
| 1307 | { |