Skip to content

Commit 995d053

Browse files
committed
add option view-op-graph in mlir-neura-opt
1 parent c187a11 commit 995d053

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

test/visualize/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ First, run `apt install graphviz` to install Graphviz. For an MLIR file, use the
99
Example:
1010

1111
```bash
12-
mlir-neura-opt --assign-accelerator --lower-arith-to-neura --fuse-patterns test.mlir > test_fused.mlir
13-
mlir-opt --allow-unregistered-dialect --view-op-graph test_fused.mlir 2> test.dot
12+
mlir-neura-opt --assign-accelerator --lower-arith-to-neura --fuse-pattern --view-op-graph test.mlir 2> test.dot
1413
dot -Tpng test.dot -o test.png
1514
```
1615

test/visualize/test.mlir

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// Test cases for FusePatternsPass
2-
31
// Test 1: Verify dot generation for fused operations
4-
// RUN: mlir-neura-opt --assign-accelerator --lower-arith-to-neura --fuse-patterns --generate-dot %s | FileCheck %s --check-prefix=CHECK-DOT-GENERATION
2+
// RUN: mlir-neura-opt --assign-accelerator --lower-arith-to-neura --fuse-pattern --view-op-graph %s 2>&1 | FileCheck %s --check-prefix=CHECK-DOT-GENERATION
53

64
func.func @test_dot_generation(%a: f32, %b: f32, %c: f32) -> f32 {
75
%temp = arith.addf %a, %b : f32
86
%res = arith.addf %temp, %c : f32
9-
// CHECK-DOT-GENERATION: // DOT: digraph
10-
// CHECK-DOT-GENERATION: // DOT: "fadd_fadd"
7+
// CHECK-DOT-GENERATION: digraph G
8+
// CHECK-DOT-GENERATION: label = "func.func : ()\n\naccelerator: \"neura\"\nfunction_type: (f32, f32, f32) -> f...\nsym_name: \"test_dot_generation...";
9+
// CHECK-DOT-GENERATION: label = "neura.fadd_fadd : (f32)\n"
1110
return %res : f32
1211
}
1312

tools/mlir-neura-opt/mlir-neura-opt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ int main(int argc, char **argv) {
2424

2525
mlir::neura::registerPasses();
2626
mlir::registerPasses();
27+
mlir::registerViewOpGraphPass();
2728

2829
// Runs the MLIR optimizer.
2930
return mlir::asMainReturnCode(

0 commit comments

Comments
 (0)