Skip to content

Commit

Permalink
add copy_tile_init() needed before eltwise max operand copies (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
vroubtsovTT authored Dec 4, 2024
1 parent 7f6046e commit d837ac7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Conversion/TTIRToTTMetal/TTIRToTTMetal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,12 @@ class TTIRToTTMetalDispatchRewriter : public OpRewritePattern<ttir::GenericOp> {
builder.create<ttkernel::TileRegsAcquireOp>(location);
{
// copy inCB0[inCB0TileIndex] and inCB1[inCB1TileIndex] to DST:
builder.create<ttkernel::CopyTileInitOp>(location);
builder.create<ttkernel::CopyTileOp>(location, inCB0, inCB0TileIndex,
dstLhsTileIndex);
builder.create<ttkernel::CopyTileOp>(location, inCB1, inCB1TileIndex,
dstRhsTileIndex);
// SFPU ooperates on DST tiles:
// SFPU operates on DST tiles:
builder.create<TTKernelTilesOp>(location, dstLhsTileIndex,
dstRhsTileIndex);
}
Expand Down
13 changes: 13 additions & 0 deletions test/ttmlir/Silicon/TTMetal/simple_max.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: ttmlir-opt --ttir-to-ttmetal-backend-pipeline="system-desc-path=%system_desc_path%" %s > %t.mlir
// RUN: FileCheck %s --input-file=%t.mlir
// RUN: ttmlir-translate --ttmetal-to-flatbuffer %t.mlir > %t.ttm

#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile>

func.func @maximum(%arg0: tensor<64x128xf32>, %arg1: tensor<64x128xf32>) -> tensor<64x128xf32> {
// CHECK: %[[C:.*]] = "ttmetal.alloc"[[C:.*]]
%0 = tensor.empty() : tensor<64x128xf32>
// CHECK: %[[C:.*]] = "ttmetal.dispatch"[[C:.*]]
%1 = "ttir.maximum"(%arg0, %arg1, %0) <{operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32>
return %1 : tensor<64x128xf32>
}

0 comments on commit d837ac7

Please sign in to comment.