diff --git a/docs/content/en/docs/getting_started.md b/docs/content/en/docs/getting_started.md index f0eb622f8..1fdd6784e 100644 --- a/docs/content/en/docs/getting_started.md +++ b/docs/content/en/docs/getting_started.md @@ -432,3 +432,22 @@ bazel run --noallow_analysis_cache_discard //tools:heir-opt -- \ --insert-rotate --cse --canonicalize --collapse-insertion-chains \ --canonicalize --cse /path/to/heir/tests/simd/box_blur_64x64.mlir ``` + +### Optional: Graphviz visualization of the IR + +Getting a visualization of the IR during optimization/transformation might help +you understand what is going on more easily. + +Still taking the `dot_product_8.mlir` as an example: + +```bash +bazel run --ui_event_filters=-info,-debug,-warning,-stderr,-stdout --noshow_progress --logging=0 //tools:heir-opt -- --wrap-generic --heir-simd-vectorizer $PWD/tests/Examples/openfhe/dot_product_8.mlir --view-op-graph 2> dot_product_8.dot +dot -Tpdf dot_product_8.dot > dot_product_8.pdf +# open pdf in your favorite pdf viewer +``` + +The diagram is also shown below. It demonstrates that the HEIR SIMD vectorizer +would vectorize the dot-product program (`tensor<8xi16>`) then use +rotate-and-reduce technique to compute the sum. + +{{% figure src="/images/dot_product_8.svg" link="/images/dot_product_8.svg" %}} diff --git a/docs/static/images/dot_product_8.svg b/docs/static/images/dot_product_8.svg new file mode 100644 index 000000000..122089d21 --- /dev/null +++ b/docs/static/images/dot_product_8.svg @@ -0,0 +1,324 @@ + + + + + + +G + + +cluster_1 + +builtin.module : () + + +cluster_3 + + + +cluster_5 + +func.func : () +function_type: (!secret.secret<tens... +sym_name: "dot_product" + + +cluster_7 + + + +cluster_15 + +secret.generic : (!secret.secret<i16>) + + +cluster_17 + + + + +v2 + + + + +v4 + + + + +v6 + + + + +v8 + + + + +v9 + +arg0 + + + +v16 + + + + +v9->v16 + + + + + +v10 + +arg1 + + + +v10->v16 + + + + + +v11 + +arith.constant : (index) +value: 1 : index + + + +v26 + +tensor_ext.rotate : (tensor<8xi16>) + + + +v11->v26 + + +1 + + + +v12 + +arith.constant : (index) +value: 2 : index + + + +v24 + +tensor_ext.rotate : (tensor<8xi16>) + + + +v12->v24 + + +1 + + + +v13 + +arith.constant : (index) +value: 4 : index + + + +v22 + +tensor_ext.rotate : (tensor<8xi16>) + + + +v13->v22 + + +1 + + + +v14 + +arith.constant : (index) +value: 7 : index + + + +v28 + +tensor.extract : (i16) + + + +v14->v28 + + +1 + + + +v30 + +func.return : () + + + +v16->v30 + + + + + +v18 + + + + +v19 + +arg0 + + + +v21 + +arith.muli : (tensor<8xi16>) +overflowFlags: #arith.overflow<none... + + + +v19->v21 + + +0 + + + +v20 + +arg1 + + + +v20->v21 + + +1 + + + +v21->v22 + + +0 + + + +v23 + +arith.addi : (tensor<8xi16>) +overflowFlags: #arith.overflow<none... + + + +v21->v23 + + +0 + + + +v22->v23 + + +1 + + + +v23->v24 + + +0 + + + +v25 + +arith.addi : (tensor<8xi16>) +overflowFlags: #arith.overflow<none... + + + +v23->v25 + + +0 + + + +v24->v25 + + +1 + + + +v25->v26 + + +0 + + + +v27 + +arith.addi : (tensor<8xi16>) +overflowFlags: #arith.overflow<none... + + + +v25->v27 + + +0 + + + +v26->v27 + + +1 + + + +v27->v28 + + +0 + + + +v29 + +secret.yield : () + + + +v28->v29 + + + + +