Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/NeuraDialect/Transforms/CanonicalizeLiveInPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,28 @@ identifyDirectDominatingLiveIns(Region &region, DominanceInfo &dom_info,
continue;
}

// If the using block is a loop header (has a back-edge from itself or
// other blocks), we must NOT treat any live-in as a direct dominating
// live-in. In the dataflow model, loop headers operate at the inner
// loop rate, so live-in values from outer blocks must be promoted to
// block arguments to get proper rate-matched PHI_START operations
// during the ctrl-to-data-flow transformation.
// See: https://github.com/coredac/dataflow/issues/270
bool using_block_is_loop_header = false;
for (Block *pred : block.getPredecessors()) {
if (dom_info.dominates(&block, pred)) {
using_block_is_loop_header = true;
break;
}
}

if (using_block_is_loop_header) {
// Skips direct dominating live-in optimization for loop headers.
// The value must be promoted to a block argument so that the
// transform-ctrl-to-data-flow pass creates an inner-rate PHI_START.
continue;
}

// Pattern 1: Single-Source-Single-Sink with one conditional branch.
if (isSingleSourceSingleSinkPattern(defining_block, &block, dom_info,
post_dom_info)) {
Expand Down
253 changes: 138 additions & 115 deletions test/e2e/bicg/bicg_int_kernel.mlir

Large diffs are not rendered by default.

291 changes: 210 additions & 81 deletions test/e2e/bicg/bicg_kernel.mlir

Large diffs are not rendered by default.

627 changes: 354 additions & 273 deletions test/e2e/fft/fft_kernel.mlir

Large diffs are not rendered by default.

484 changes: 271 additions & 213 deletions test/e2e/gemm/gemm_kernel.mlir

Large diffs are not rendered by default.

345 changes: 194 additions & 151 deletions test/e2e/gemv/gemv_kernel.mlir

Large diffs are not rendered by default.

408 changes: 325 additions & 83 deletions test/e2e/spmv/spmv_kernel.mlir

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/neura/fusion/test.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

// CHECK-FUSED: func.func @_Z6kernelPA1024_iPiS1_S1_S1_
// CHECK-FUSED: accelerator = "neura"
// CHECK-FUSED-DAG: %91 = neura.load_indexed %89[%90 : !neura.data<i64, i1>] !neura.data<!llvm.ptr, i1> : !neura.data<i32, i1>
// CHECK-FUSED-DAG: %82 = "neura.mul_add"(%79, %80, %81) : (!neura.data<i32, i1>, !neura.data<i32, i1>, !neura.data<i32, i1>) -> !neura.data<i32, i1>
// CHECK-FUSED-DAG: %95 = "neura.mul_add"(%92, %93, %94) : (!neura.data<i32, i1>, !neura.data<i32, i1>, !neura.data<i32, i1>) -> !neura.data<i32, i1>
// CHECK-FUSED-DAG: %102 = neura.load_indexed %100[%101 : !neura.data<i64, i1>] !neura.data<!llvm.ptr, i1> : !neura.data<i32, i1>
// CHECK-FUSED-DAG: %93 = "neura.mul_add"(%90, %91, %92) : (!neura.data<i32, i1>, !neura.data<i32, i1>, !neura.data<i32, i1>) -> !neura.data<i32, i1>
// CHECK-FUSED-DAG: %106 = "neura.mul_add"(%103, %104, %105) : (!neura.data<i32, i1>, !neura.data<i32, i1>, !neura.data<i32, i1>) -> !neura.data<i32, i1>

// CHECK-MAPPING: mapping_info = {compiled_ii = 12 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 9 : i32, res_mii = 5 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}

Expand Down
Loading