CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
94 lines
3.6 KiB
MLIR
94 lines
3.6 KiB
MLIR
// RUN: mlir-opt %s --stage-sparse-ops --lower-sparse-ops-to-foreach --canonicalize --cse | FileCheck %s
|
|
|
|
#SparseVector = #sparse_tensor.encoding<{
|
|
map = (d0) -> (d0 : compressed)
|
|
}>
|
|
|
|
#CSR = #sparse_tensor.encoding<{
|
|
map = (d0, d1) -> (d0 : dense, d1 : compressed)
|
|
}>
|
|
|
|
#CSC = #sparse_tensor.encoding<{
|
|
map = (d0, d1) -> (d1 : dense, d0 : compressed)
|
|
}>
|
|
|
|
#SparseTensor = #sparse_tensor.encoding<{
|
|
map = (d0, d1, d2) -> (d2 : dense, d0 : compressed, d1 : compressed)
|
|
}>
|
|
|
|
// CHECK-LABEL: func.func @sparse_convert_1d
|
|
// CHECK: sparse_tensor.foreach
|
|
// CHECK: scf.if
|
|
// CHECK: tensor.insert
|
|
// CHECK-NOT: sparse_tensor.reorder_coo
|
|
// CHECK: sparse_tensor.load
|
|
func.func @sparse_convert_1d(%arg0: tensor<?xi32>) -> tensor<?xi32, #SparseVector> {
|
|
%0 = sparse_tensor.convert %arg0 : tensor<?xi32> to tensor<?xi32, #SparseVector>
|
|
return %0 : tensor<?xi32, #SparseVector>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @sparse_convert_complex
|
|
// CHECK: sparse_tensor.foreach
|
|
// CHECK: scf.if
|
|
// CHECK: tensor.insert
|
|
// CHECK-NOT: sparse_tensor.reorder_coo
|
|
// CHECK: sparse_tensor.load
|
|
func.func @sparse_convert_complex(%arg0: tensor<100xcomplex<f64>>) -> tensor<100xcomplex<f64>, #SparseVector> {
|
|
%0 = sparse_tensor.convert %arg0 : tensor<100xcomplex<f64>> to tensor<100xcomplex<f64>, #SparseVector>
|
|
return %0 : tensor<100xcomplex<f64>, #SparseVector>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @sparse_convert_2d
|
|
// CHECK: sparse_tensor.foreach
|
|
// CHECK: scf.if
|
|
// CHECK: tensor.insert
|
|
// CHECK-NOT: sparse_tensor.reorder_coo
|
|
// CHECK: sparse_tensor.load
|
|
func.func @sparse_convert_2d(%arg0: tensor<2x4xf64>) -> tensor<2x4xf64, #CSR> {
|
|
%0 = sparse_tensor.convert %arg0 : tensor<2x4xf64> to tensor<2x4xf64, #CSR>
|
|
return %0 : tensor<2x4xf64, #CSR>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @sparse_constant
|
|
// CHECK: sparse_tensor.foreach
|
|
// CHECK-NOT: scf.if
|
|
// CHECK: tensor.insert
|
|
// CHECK-NOT: sparse_tensor.reorder_coo
|
|
// CHECK: sparse_tensor.load
|
|
func.func @sparse_constant() -> tensor<8x7xf32, #CSR>{
|
|
// Initialize a tensor.
|
|
%0 = arith.constant sparse<[[0, 0], [1, 6]], [1.0, 5.0]> : tensor<8x7xf32>
|
|
// Convert the tensor to a sparse tensor.
|
|
%1 = sparse_tensor.convert %0 : tensor<8x7xf32> to tensor<8x7xf32, #CSR>
|
|
return %1 : tensor<8x7xf32, #CSR>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @sparse_constant_csc
|
|
// CHECK: sparse_tensor.foreach
|
|
// CHECK-NOT: scf.if
|
|
// CHECK: tensor.insert
|
|
// CHECK-NOT: sparse_tensor.reorder_coo
|
|
// CHECK: sparse_tensor.load
|
|
func.func @sparse_constant_csc() -> tensor<8x7xf32, #CSC>{
|
|
// Initialize a tensor.
|
|
%0 = arith.constant sparse<[[0, 0], [1, 6]], [1.0, 5.0]> : tensor<8x7xf32>
|
|
// Convert the tensor to a sparse tensor.
|
|
%1 = sparse_tensor.convert %0 : tensor<8x7xf32> to tensor<8x7xf32, #CSC>
|
|
return %1 : tensor<8x7xf32, #CSC>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @sparse_convert_3d
|
|
// CHECK: sparse_tensor.foreach
|
|
// CHECK: scf.if
|
|
// CHECK: tensor.insert
|
|
// CHECK: sparse_tensor.load
|
|
// CHECK: %[[TMP:.*]] = sparse_tensor.reorder_coo
|
|
// CHECK: sparse_tensor.foreach
|
|
// CHECK: tensor.insert
|
|
// CHECK: sparse_tensor.load
|
|
// CHECK: bufferization.dealloc_tensor %[[TMP]]
|
|
func.func @sparse_convert_3d(%arg0: tensor<?x?x?xf64>) -> tensor<?x?x?xf64, #SparseTensor> {
|
|
%0 = sparse_tensor.convert %arg0 : tensor<?x?x?xf64> to tensor<?x?x?xf64, #SparseTensor>
|
|
return %0 : tensor<?x?x?xf64, #SparseTensor>
|
|
}
|