dimension (e.g. a full row for matrices). The added array and count are used
to store new indices when a false value is encountered in the filled array.
All arrays should be allocated before the loop (possibly even shared between
- loops in a future optimization) so that their *dense* intitialization can be
+ loops in a future optimization) so that their *dense* initialization can be
amortized over many iterations. Setting and resetting the dense arrays in
the loop nest itself is kept *sparse* by only iterating over set elements
through an indirection using the added array, so that the operations are
!Filename = type !llvm.ptr<i8>
-#SparseMatrix = #sparse_tensor.encoding<{
+#SparseTensor = #sparse_tensor.encoding<{
dimLevelType = [ "compressed", "compressed", "compressed" ]
}>
// Computes Matricized Tensor Times Khatri-Rao Product (MTTKRP) kernel. See
// http://tensor-compiler.org/docs/data_analytics/index.html.
//
- func @kernel_mttkrp(%argb: tensor<?x?x?xf64, #SparseMatrix>,
+ func @kernel_mttkrp(%argb: tensor<?x?x?xf64, #SparseTensor>,
%argc: tensor<?x?xf64>,
%argd: tensor<?x?xf64>,
%arga: tensor<?x?xf64> {linalg.inplaceable = true})
-> tensor<?x?xf64> {
%0 = linalg.generic #mttkrp
ins(%argb, %argc, %argd:
- tensor<?x?x?xf64, #SparseMatrix>, tensor<?x?xf64>, tensor<?x?xf64>)
+ tensor<?x?x?xf64, #SparseTensor>, tensor<?x?xf64>, tensor<?x?xf64>)
outs(%arga: tensor<?x?xf64>) {
^bb(%b: f64, %c: f64, %d: f64, %a: f64):
%0 = arith.mulf %b, %c : f64
// Read the sparse B input from a file.
%fileName = call @getTensorFilename(%c0) : (index) -> (!Filename)
%b = sparse_tensor.new %fileName
- : !Filename to tensor<?x?x?xf64, #SparseMatrix>
+ : !Filename to tensor<?x?x?xf64, #SparseTensor>
// Initialize dense C and D inputs and dense output A.
%cdata = memref.alloc(%c3, %c5) : memref<?x?xf64>
// Call kernel.
%0 = call @kernel_mttkrp(%b, %c, %d, %a)
- : (tensor<?x?x?xf64, #SparseMatrix>,
+ : (tensor<?x?x?xf64, #SparseTensor>,
tensor<?x?xf64>, tensor<?x?xf64>, tensor<?x?xf64>) -> tensor<?x?xf64>
// Print the result for verification.
memref.dealloc %adata : memref<?x?xf64>
memref.dealloc %cdata : memref<?x?xf64>
memref.dealloc %ddata : memref<?x?xf64>
- sparse_tensor.release %b : tensor<?x?x?xf64, #SparseMatrix>
+ sparse_tensor.release %b : tensor<?x?x?xf64, #SparseTensor>
return
}