(title, path, graph_module: torch.fx.GraphModule, format=DrawFormat.SVG)
| 959 | |
| 960 | |
| 961 | def draw_graph(title, path, graph_module: torch.fx.GraphModule, format=DrawFormat.SVG): |
| 962 | graph = passes.graph_drawer.FxGraphDrawer(graph_module, title) |
| 963 | warnings.warn( |
| 964 | "For large models such as LLM, it is strongly recommended to use PYDOT format.", |
| 965 | stacklevel=1, |
| 966 | ) |
| 967 | if format == DrawFormat.SVG: |
| 968 | with open(f"{path}/{title}.svg", "wb") as f: |
| 969 | f.write(graph.get_dot_graph().create_svg()) |
| 970 | elif format == DrawFormat.PYDOT: |
| 971 | graph.get_dot_graph().write_raw(f"{path}/{title}.dot") |
| 972 | else: |
| 973 | raise RuntimeError(f"Unknown format {format}.") |
| 974 | |
| 975 | |
| 976 | def generate_gpu_compiler_spec( |
no test coverage detected