Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConvTranspose2dOp verification missmatch #2389

Closed
mstojkovicTT opened this issue Mar 6, 2025 · 0 comments · Fixed by #2390
Closed

ConvTranspose2dOp verification missmatch #2389

mstojkovicTT opened this issue Mar 6, 2025 · 0 comments · Fixed by #2390
Assignees
Labels
bug Something isn't working

Comments

@mstojkovicTT
Copy link
Contributor

Incorrect Padding Dimension Check in MLIR Validation

Description:
Forge-FE provides padding values in the order [pT, pL, pB, pR]. However, the MLIR implementation currently checks the dimensions incorrectly. Instead of validating that the top and bottom paddings are equal (p[0] == p[2]) and the left and right paddings are equal (p[1] == p[3]), the code mistakenly compares p[0] == p[1] and p[2] == p[3]. This results in false validation errors when the frontend sends correctly structured padding.

TTIR:

module @ConvTranspose2d attributes {tt.system_desc = #tt.system_desc<[{role = host, target_triple = "x86_64-pc-linux-gnu"}], [{arch = <wormhole_b0>, grid = 8x8, l1_size = 1499136, num_dram_channels = 12, dram_channel_size = 1073741824, noc_l1_address_align_bytes = 16, pcie_address_align_bytes = 32, noc_dram_address_align_bytes = 32, l1_unreserved_base = 1024, erisc_l1_unreserved_base = 1024, dram_unreserved_base = 1024, dram_unreserved_end = 1073741824, physical_cores = {worker = [ 0x0,  0x1,  0x2,  0x3,  0x4,  0x5,  0x6,  0x7,  1x0,  1x1,  1x2,  1x3,  1x4,  1x5,  1x6,  1x7,  2x0,  2x1,  2x2,  2x3,  2x4,  2x5,  2x6,  2x7,  3x0,  3x1,  3x2,  3x3,  3x4,  3x5,  3x6,  3x7,  4x0,  4x1,  4x2,  4x3,  4x4,  4x5,  4x6,  4x7,  5x0,  5x1,  5x2,  5x3,  5x4,  5x5,  5x6,  5x7,  6x0,  6x1,  6x2,  6x3,  6x4,  6x5,  6x6,  6x7,  7x0,  7x1,  7x2,  7x3,  7x4,  7x5,  7x6,  7x7] dram = [ 8x0,  9x0,  10x0,  8x1,  9x1,  10x1,  8x2,  9x2,  10x2,  8x3,  9x3,  10x3]}, supported_data_types = [<f32>, <f16>, <bf16>, <bfp_f8>, <bfp_bf8>, <bfp_f4>, <bfp_bf4>, <bfp_f2>, <bfp_bf2>, <u32>, <u16>, <u8>, <si32>], supported_tile_sizes = [ 4x16,  16x16,  32x16,  4x32,  16x32,  32x32], num_cbs = 32}], [0], [3 : i32], [ 0x0x0x0]>} {
  func.func @forward(%arg0: tensor<20x16x50x100xf32> {ttir.name = "input"}, %arg1: tensor<16x32x3x3xf32> {ttir.name = "weight"}) -> (tensor<20x32x197x395xf32> {ttir.name = "ConvTranspose2d.output_conv2d_transpose_0"}) {
    %0 = tensor.empty() : tensor<20x50x16x100xf32>
    %1 = "ttir.transpose"(%arg0, %0) <{dim0 = -3 : si32, dim1 = -2 : si32}> : (tensor<20x16x50x100xf32>, tensor<20x50x16x100xf32>) -> tensor<20x50x16x100xf32>
    %2 = tensor.empty() : tensor<20x50x100x16xf32>
    %3 = "ttir.transpose"(%1, %2) <{dim0 = -2 : si32, dim1 = -1 : si32}> : (tensor<20x50x16x100xf32>, tensor<20x50x100x16xf32>) -> tensor<20x50x100x16xf32>
    %4 = tensor.empty() : tensor<20x197x395x32xf32>
    %5 = "ttir.conv_transpose2d"(%3, %arg1, %4) <{dilation = array<i32: 1, 1>, groups = 1 : i32, output_padding = array<i32: 0, 0>, padding = array<i32: 1, 2, 1, 2>, stride = array<i32: 4, 4>}> {channel_last = 1 : si32} : (tensor<20x50x100x16xf32>, tensor<16x32x3x3xf32>, tensor<20x197x395x32xf32>) -> tensor<20x197x395x32xf32>
    %6 = tensor.empty() : tensor<20x197x32x395xf32>
    %7 = "ttir.transpose"(%5, %6) <{dim0 = -2 : si32, dim1 = -1 : si32}> : (tensor<20x197x395x32xf32>, tensor<20x197x32x395xf32>) -> tensor<20x197x32x395xf32>
    %8 = tensor.empty() : tensor<20x32x197x395xf32>
    %9 = "ttir.transpose"(%7, %8) <{dim0 = -3 : si32, dim1 = -2 : si32}> : (tensor<20x197x32x395xf32>, tensor<20x32x197x395xf32>) -> tensor<20x32x197x395xf32>
    return %9 : tensor<20x32x197x395xf32>
  }
}
loc("conv2d_transpose_0.dc.conv2d_transpose.2"("forward":4294967295:14)): error: failed to legalize operation 'ttir.conv_transpose2d' 

Expected Behavior:

  • The top and bottom paddings should be equal: p[0] == p[2]
  • The left and right paddings should be equal: p[1] == p[3]

Actual Behavior:
The current logic compares:

  • p[0] == p[1]
  • p[2] == p[3]

which does not correctly represent the intended padding semantics.

Suggested Fix:
Modify the validation logic in the MLIR component to check:

  • p[0] == p[2] (Top equals Bottom)
  • p[1] == p[3] (Left equals Right)

Additional Context:
This issue affects the integration between the frontend and MLIR, causing unexpected errors even when the padding is correctly provided.

@mstojkovicTT mstojkovicTT added the bug Something isn't working label Mar 6, 2025
@azecevicTT azecevicTT linked a pull request Mar 6, 2025 that will close this issue
1 task
azecevicTT added a commit that referenced this issue Mar 9, 2025
### Ticket
#2389

### Problem description
Forge-FE provides padding values in the order [pT, pL, pB, pR]. However, the MLIR implementation currently checks the dimensions incorrectly. Instead of validating that the top and bottom paddings are equal (p[0] == p[2]) and the left and right paddings are equal (p[1] == p[3]), the code mistakenly compares p[0] == p[1] and p[2] == p[3]. This results in false validation errors when the frontend sends correctly structured padding.

### What's changed
Fixed an error in comparison. Added both positive and negative test (for padding) for TTIR->TTNN conversion of `conv_transpose2d` op.

### Checklist
- [x] New/Existing tests provide coverage for changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants