[Mlir-commits] [mlir] [mlir][tensor] Fix PadOp::getConstantPaddingValue (PR #121205)

Andrzej WarzyƄski llvmlistbot at llvm.org
Mon Dec 30 13:25:59 PST 2024


================
@@ -44,3 +46,26 @@ func.func @generalize_pad_tensor_dynamic_shape(%arg0: tensor<4x?x2x?xf32>, %arg1
   } : tensor<4x?x2x?xf32> to tensor<4x?x?x?xf32>
   return %out : tensor<4x?x?x?xf32>
 }
+
+// -----
+
+// Ensure that the constant value inside the PadOp block does not cause a crash.
+
+// CHECK-LABEL:   func.func @generalize_pad_tensor_constant_inside(
+// CHECK-SAME:                                                     %[[VAL_0:.*]]: tensor<1x28x28x1xf32>) -> tensor<1x32x32x1xf32> {
+// CHECK:           %[[VAL_1:.*]] = tensor.generate  {
+// CHECK:           ^bb0(%[[VAL_2:.*]]: index, %[[VAL_3:.*]]: index, %[[VAL_4:.*]]: index, %[[VAL_5:.*]]: index):
+// CHECK:             %[[VAL_6:.*]] = arith.constant 0.000000e+00 : f32
+// CHECK:             tensor.yield %[[VAL_6]] : f32
+// CHECK:           } : tensor<1x32x32x1xf32>
+// CHECK:           %[[VAL_7:.*]] = tensor.insert_slice %[[VAL_0]] into %[[VAL_8:.*]][0, 2, 2, 0] [1, 28, 28, 1] [1, 1, 1, 1] : tensor<1x28x28x1xf32> into tensor<1x32x32x1xf32>
+// CHECK:           return %[[VAL_7]] : tensor<1x32x32x1xf32>
+// CHECK:         }
----------------
banach-space wrote:

Please follow the existing convention in this file and use meaningful LIT variables (e.g. `PADDED`) instead of the auto-generated ones (e.g. `VAL_7`).

https://github.com/llvm/llvm-project/pull/121205


More information about the Mlir-commits mailing list