diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td --- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td +++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td @@ -1393,7 +1393,41 @@ let summary = "Pads a tensor with value specified."; let description = [{ - Pads a tensor along borders of each dimension with pad_value. + The `tosa.pad` operation pads a tensor along borders of each dimension with + `pad_const` (defaults to zero), given a padding configuration `padding` + specifying low and high values along the dimensions. + + Example: + + ```mlir + %0 = arith.constant dense<[[1, 2], [3, 4]]> : tensor<2x2xi32> + "tosa.pad"(%arg0, %0) : (tensor<1x2xf32>, tensor<2x2xi32>) -> (tensor<4x9xf32>) + ``` + + This may lower to IR resembling: + + ```mlir + tensor.pad %arg0 low[1, 3] high[2, 4] { + ^bb0(%arg1: index, %arg2: index): + tensor.yield %cst_0 : f32 + } : tensor<1x2xf32> to tensor<4x9xf32> + ``` + + Example 2: + + ```mlir + %0 = arith.constant dense<[[-1, 2], [3, 4]]> : tensor<2x2xi32> + "tosa.pad"(%arg0, %0) : (tensor<1x2xf32>, tensor<2x2xi32>) -> (tensor) + ``` + + This may lower to IR resembling: + + ```mlir + %padded = tensor.pad %arg0 low[-1, 3] high[2, 4] { + ^bb0(%arg1: index, %arg2: index): + tensor.yield %cst_0 : f32 + } : tensor<1x2xf32> to tensor + ``` }]; let arguments = (ins