Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update sparsity printer test to use aliases, from latest LLVM bump
  • Loading branch information
GleasonK authored Nov 20, 2023
1 parent 47d62a3 commit 202cb2b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ http_archive(
],
)

LLVM_COMMIT = "c5dd1bbcc37e8811e7c6050159014d084eac6438"
LLVM_COMMIT = "506c47df00bbd9e527ecc5ac6e192b5fe5daa2c5"

LLVM_SHA256 = "f374bf677707588fc07235215e2bf03e27dfb299c4b478306dc918099c60b583"
LLVM_SHA256 = "5db67a5293810e6aebd2f757d660dbe2271fc86016c56cfcc56a89705dc22d80"

http_archive(
name = "llvm-raw",
Expand Down
2 changes: 1 addition & 1 deletion build_tools/llvm_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c5dd1bbcc37e8811e7c6050159014d084eac6438
506c47df00bbd9e527ecc5ac6e192b5fe5daa2c5
55 changes: 29 additions & 26 deletions stablehlo/tests/print_stablehlo.mlir
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
// RUN: stablehlo-opt %s | FileCheck %s
// RUN: stablehlo-opt %s | stablehlo-opt | FileCheck %s

// Test encodings first since aliases are printed at top of file.
#CSR = #sparse_tensor.encoding<{
map = (d0, d1) -> (d0 : dense, d1 : compressed)
}>

#DCSR = #sparse_tensor.encoding<{
map = (d0, d1) -> (d0 : compressed, d1 : compressed)
}>

// CHECK: #[[$CSR:.*]] = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }>
// CHECK: #[[$DCSR:.*]] = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : compressed, d1 : compressed) }>
// CHECK-LABEL: func @encodings
func.func @encodings(%arg0: tensor<10x20xf32, #CSR>,
%arg1: tensor<10x20xf32, #DCSR>) -> tensor<10x20xf32> {
// CHECK: %0 = stablehlo.add %arg0, %arg1 : (tensor<10x20xf32, #[[$CSR]]>, tensor<10x20xf32, #[[$DCSR]]>) -> tensor<10x20xf32>
// CHECK-NEXT: %1 = stablehlo.add %arg1, %arg1 : tensor<10x20xf32, #[[$DCSR]]>
// CHECK-NEXT: %2 = stablehlo.abs %arg0 : (tensor<10x20xf32, #[[$CSR]]>) -> tensor<10x20xf32>
// CHECK-NEXT: %3 = stablehlo.abs %arg0 : tensor<10x20xf32, #[[$CSR]]>
// CHECK-NEXT: %4 = stablehlo.complex %arg0, %arg0 : (tensor<10x20xf32, #[[$CSR]]>, tensor<10x20xf32, #[[$CSR]]>) -> tensor<10x20xcomplex<f32>>
%0 = "stablehlo.add"(%arg0, %arg1) : (tensor<10x20xf32, #CSR>,
tensor<10x20xf32, #DCSR>) -> tensor<10x20xf32>
%1 = "stablehlo.add"(%arg1, %arg1) : (tensor<10x20xf32, #DCSR>,
tensor<10x20xf32, #DCSR>) -> tensor<10x20xf32, #DCSR>
%2 = "stablehlo.abs"(%arg0) : (tensor<10x20xf32, #CSR>) -> tensor<10x20xf32>
%3 = "stablehlo.abs"(%arg0) : (tensor<10x20xf32, #CSR>) -> tensor<10x20xf32, #CSR>
%4 = "stablehlo.complex"(%arg0, %arg0) : (tensor<10x20xf32, #CSR>, tensor<10x20xf32, #CSR>) -> tensor<10x20xcomplex<f32>>
func.return %0 : tensor<10x20xf32>
}

// CHECK-LABEL: func @zero_input
func.func @zero_input() -> !stablehlo.token {
// CHECK: %0 = stablehlo.replica_id : tensor<ui32>
Expand Down Expand Up @@ -291,32 +320,6 @@ func.func @extensions(%arg0 : tensor<?x?xf32, #stablehlo.bounds<3, ?>>,
"stablehlo.return"() : () -> ()
}

#CSR = #sparse_tensor.encoding<{
map = (d0, d1) -> (d0 : dense, d1 : compressed)
}>

#DCSR = #sparse_tensor.encoding<{
map = (d0, d1) -> (d0 : compressed, d1 : compressed)
}>

// CHECK-LABEL: func @encodings
func.func @encodings(%arg0: tensor<10x20xf32, #CSR>,
%arg1: tensor<10x20xf32, #DCSR>) -> tensor<10x20xf32> {
// CHECK: %0 = stablehlo.add %arg0, %arg1 : (tensor<10x20xf32, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }>>, tensor<10x20xf32, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : compressed, d1 : compressed) }>>) -> tensor<10x20xf32>
// CHECK-NEXT: %1 = stablehlo.add %arg1, %arg1 : tensor<10x20xf32, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : compressed, d1 : compressed) }>>
// CHECK-NEXT: %2 = stablehlo.abs %arg0 : (tensor<10x20xf32, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }>>) -> tensor<10x20xf32>
// CHECK-NEXT: %3 = stablehlo.abs %arg0 : tensor<10x20xf32, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }>>
// CHECK-NEXT: %4 = stablehlo.complex %arg0, %arg0 : (tensor<10x20xf32, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }>>, tensor<10x20xf32, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }>>) -> tensor<10x20xcomplex<f32>>
%0 = "stablehlo.add"(%arg0, %arg1) : (tensor<10x20xf32, #CSR>,
tensor<10x20xf32, #DCSR>) -> tensor<10x20xf32>
%1 = "stablehlo.add"(%arg1, %arg1) : (tensor<10x20xf32, #DCSR>,
tensor<10x20xf32, #DCSR>) -> tensor<10x20xf32, #DCSR>
%2 = "stablehlo.abs"(%arg0) : (tensor<10x20xf32, #CSR>) -> tensor<10x20xf32>
%3 = "stablehlo.abs"(%arg0) : (tensor<10x20xf32, #CSR>) -> tensor<10x20xf32, #CSR>
%4 = "stablehlo.complex"(%arg0, %arg0) : (tensor<10x20xf32, #CSR>, tensor<10x20xf32, #CSR>) -> tensor<10x20xcomplex<f32>>
func.return %0 : tensor<10x20xf32>
}

func.func @dot_general(%arg0: tensor<2x2x2xi8>, %arg1: tensor<2x2x3xi8>, %arg2: tensor<2x2xi8>, %arg3: tensor<2x3xi8>) -> tensor<2x2x3xi32> {
// CHECK: {{%.*}} = stablehlo.dot_general %arg0, %arg1, batching_dims = [0] x [0], contracting_dims = [2] x [1] : (tensor<2x2x2xi8>, tensor<2x2x3xi8>) -> tensor<2x2x3xi32>
// CHECK-NEXT: {{%.*}} = stablehlo.dot_general %arg0, %arg1, batching_dims = [0] x [0], contracting_dims = [2] x [1], precision = [DEFAULT, DEFAULT] : (tensor<2x2x2xi8>, tensor<2x2x3xi8>) -> tensor<2x2x3xi32>
Expand Down

0 comments on commit 202cb2b

Please sign in to comment.