diff --git a/mlir/integration_test/Sparse/CPU/frostt-example.mlir b/mlir/integration_test/Sparse/CPU/frostt-example.mlir --- a/mlir/integration_test/Sparse/CPU/frostt-example.mlir +++ b/mlir/integration_test/Sparse/CPU/frostt-example.mlir @@ -7,15 +7,21 @@ // RUN: -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext | \ // RUN: FileCheck %s +// +// Use descriptive names for opaque pointers. +// +!Filename = type !llvm.ptr +!Tensor = type !llvm.ptr + module { // // Example of using the sparse runtime support library to read a sparse tensor // in the FROSTT file format (http://frostt.io/tensors/file-formats.html). // - func private @openTensor(!llvm.ptr, memref) -> (!llvm.ptr) - func private @readTensorItem(!llvm.ptr, memref, memref) -> () - func private @closeTensor(!llvm.ptr) -> () - func private @getTensorFilename(index) -> (!llvm.ptr) + func private @getTensorFilename(index) -> (!Filename) + func private @openTensor(!Filename, memref) -> (!Tensor) + func private @readTensorItem(!Tensor, memref, memref) -> () + func private @closeTensor(!Tensor) -> () func @entry() { %d0 = constant 0.0 : f64 @@ -35,7 +41,7 @@ // // Obtain the sparse tensor filename through this test helper. // - %fileName = call @getTensorFilename(%c0) : (index) -> (!llvm.ptr) + %fileName = call @getTensorFilename(%c0) : (index) -> (!Filename) // // Read a sparse tensor. The call yields a pointer to an opaque @@ -44,8 +50,7 @@ // provides the rank and the number of nonzero elements (nnz) through // a memref array. // - %tensor = call @openTensor(%fileName, %idata) - : (!llvm.ptr, memref) -> (!llvm.ptr) + %tensor = call @openTensor(%fileName, %idata) : (!Filename, memref) -> (!Tensor) // // Print some meta data. @@ -65,8 +70,7 @@ // simply print the elements on the fly. // scf.for %k = %c0 to %nnz step %c1 { - call @readTensorItem(%tensor, %idata, %ddata) - : (!llvm.ptr, memref, memref) -> () + call @readTensorItem(%tensor, %idata, %ddata) : (!Tensor, memref, memref) -> () // // Build index vector and print element (here, using the // knowledge that the read sparse tensor has rank 8). @@ -88,7 +92,7 @@ // Since at this point we have processed the contents, make sure to // close the sparse tensor to release its memory resources. // - call @closeTensor(%tensor) : (!llvm.ptr) -> () + call @closeTensor(%tensor) : (!Tensor) -> () // // Verify that the results are as expected. diff --git a/mlir/integration_test/Sparse/CPU/matrix-market-example.mlir b/mlir/integration_test/Sparse/CPU/matrix-market-example.mlir --- a/mlir/integration_test/Sparse/CPU/matrix-market-example.mlir +++ b/mlir/integration_test/Sparse/CPU/matrix-market-example.mlir @@ -7,15 +7,21 @@ // RUN: -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext | \ // RUN: FileCheck %s +// +// Use descriptive names for opaque pointers. +// +!Filename = type !llvm.ptr +!Tensor = type !llvm.ptr + module { // // Example of using the sparse runtime support library to read a sparse matrix // in the Matrix Market Exchange Format (https://math.nist.gov/MatrixMarket). // - func private @openTensor(!llvm.ptr, memref) -> (!llvm.ptr) - func private @readTensorItem(!llvm.ptr, memref, memref) -> () - func private @closeTensor(!llvm.ptr) -> () - func private @getTensorFilename(index) -> (!llvm.ptr) + func private @getTensorFilename(index) -> (!Filename) + func private @openTensor(!Filename, memref) -> (!Tensor) + func private @readTensorItem(!Tensor, memref, memref) -> () + func private @closeTensor(!Tensor) -> () func @entry() { %d0 = constant 0.0 : f64 @@ -35,7 +41,7 @@ // // Obtain the sparse matrix filename through this test helper. // - %fileName = call @getTensorFilename(%c0) : (index) -> (!llvm.ptr) + %fileName = call @getTensorFilename(%c0) : (index) -> (!Filename) // // Read a sparse matrix. The call yields a pointer to an opaque @@ -44,8 +50,7 @@ // provides the rank (always 2 for the Matrix Market), number of // nonzero elements (nnz), and the size (m x n) through a memref array. // - %tensor = call @openTensor(%fileName, %idata) - : (!llvm.ptr, memref) -> (!llvm.ptr) + %tensor = call @openTensor(%fileName, %idata) : (!Filename, memref) -> (!Tensor) %rank = load %idata[%c0] : memref %nnz = load %idata[%c1] : memref %m = load %idata[%c2] : memref @@ -69,8 +74,7 @@ // simply insert them in the dense matrix. // scf.for %k = %c0 to %nnz step %c1 { - call @readTensorItem(%tensor, %idata, %ddata) - : (!llvm.ptr, memref, memref) -> () + call @readTensorItem(%tensor, %idata, %ddata) : (!Tensor, memref, memref) -> () %i = load %idata[%c0] : memref %j = load %idata[%c1] : memref %d = load %ddata[%c0] : memref @@ -82,7 +86,7 @@ // storage scheme, make sure to close the matrix to release its // memory resources. // - call @closeTensor(%tensor) : (!llvm.ptr) -> () + call @closeTensor(%tensor) : (!Tensor) -> () // // Verify that the results are as expected.