This is the first step towards supporting general sparse tensors as output
of operations. The init sparse tensor is used to materialize an empty sparse
tensor of given shape and sparsity into a subsequent computation (similar to
the dense tensor init operation counterpart).
Example:
%c = sparse_tensor.init %d1, %d2 : tensor<?x?xf32, #SparseMatrix> %0 = linalg.matmul ins(%a, %b: tensor<?x?xf32>, tensor<?x?xf32>) outs(%c: tensor<?x?xf32, #SparseMatrix>) -> tensor<?x?xf32, #SparseMatrix>
So we don't allow "dynamic value" in "sizes" if the corresponding dimension in the tensor type is static, something like this:
%0 = sparse_tensor.init [%d1, %d2] : tensor<?x10xf32, #SparseMatrix>. // not allow? %d1 %d2 aren't ConstantOp
%0 = sparse_tensor.init [%d1, %d2] : tensor<?x?xf32, #SparseMatrix>. // allow
Will we have runtime checking to verify the consistency of the dimensions? I think the needed runtime checking for both of the above cases are similar and we probably should support the first case as well.