[Mlir-commits] [mlir] [mlir][sparse] fix uninitialized dense tensor out in conv2d test (PR #74884)
Aart Bik
llvmlistbot at llvm.org
Fri Dec 8 12:24:01 PST 2023
https://github.com/aartbik created https://github.com/llvm/llvm-project/pull/74884
Note, tensor.empty may feed into SPARSE output (meaning it truly has no values yet), but for a DENSE output, it should always have an initial value. We ran a verifier over all our tests and this is the only remaining omission.
>From c1d1110ba473132a505fa65935a05fab1347e6c2 Mon Sep 17 00:00:00 2001
From: Aart Bik <ajcbik at google.com>
Date: Fri, 8 Dec 2023 12:14:01 -0800
Subject: [PATCH] [mlir][sparse] fix uninitialized dense tensor out in conv2d
test
Note, tensor.empty may feed into SPARSE output (meaning it truly has
no values yet), but for a DENSE output, it should always have an
initial value. We ran a verifier over all our tests and this is the
only remaining omission.
---
.../Dialect/SparseTensor/CPU/sparse_conv_2d.mlir | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conv_2d.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conv_2d.mlir
index 4f5ceda261dac0..41071ea700fb60 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conv_2d.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conv_2d.mlir
@@ -55,15 +55,15 @@ module {
func.func @conv2d_CSR_dense_rotated(%arg0: tensor<8x8xi32, #CSR>,
%arg1: tensor<3x3xi32>) -> tensor<6x6xi32> {
- %s = tensor.empty() : tensor<6x6xi32>
+ %s = arith.constant dense<0> : tensor<6x6xi32>
%0 = linalg.generic {indexing_maps = [#map, #map1, #map2],
- iterator_types = ["parallel", "reduction", "reduction", "parallel"]}
- ins(%arg0, %arg1 : tensor<8x8xi32, #CSR>, tensor<3x3xi32>)
- outs(%s : tensor<6x6xi32>) attrs = {sorted = true} {
- ^bb0(%in: i32, %in_0: i32, %out: i32):
- %1 = arith.muli %in, %in_0 : i32
- %2 = arith.addi %out, %1 : i32
- linalg.yield %2 : i32
+ iterator_types = ["parallel", "reduction", "reduction", "parallel"]}
+ ins(%arg0, %arg1 : tensor<8x8xi32, #CSR>, tensor<3x3xi32>)
+ outs(%s : tensor<6x6xi32>) attrs = {sorted = true} {
+ ^bb0(%in: i32, %in_0: i32, %out: i32):
+ %1 = arith.muli %in, %in_0 : i32
+ %2 = arith.addi %out, %1 : i32
+ linalg.yield %2 : i32
} -> tensor<6x6xi32>
return %0 : tensor<6x6xi32>
}
More information about the Mlir-commits
mailing list