taco
taco copied to clipboard
How to convert tensor formats
I‘m new to taco, any existing methods to convert tensor formats ?
Suppose that I have a tensor W with the shape (256, 512) and 60% sparsity. To define a dense-dense martix in taco, I think the code should be something like :
Format denseFormat({Dense, Dense});
Tensor<double> W("W", {256, 512}, denseFormat);
Then use utils to fill the matrix with 60% sparsity, There's going to be 60% zeros in this matrix, and I look forward to use some other specified formats, like BCSR to store this martix, any methods can do that? for example, is there something like :
Format bcsr({Dense,Sparse,Dense,Dense});
W_bcsr = W.convertFormat(bcsr)
Because to manually create a bcsr format tensor which represents the 60% sparsity tensor W is Incomprehensible, I need to create a tensor with code like (with bcsr block size (16,1)):
Format bcsr({Dense,Sparse,Dense, Dense});
Tensor<double> W("W", {1,4916,16,1}, denseFormat);
or maybe I have some improper understanding about taco?
Conversions between formats are expressed in TACO by assignments between tensors of the desired source and destination formats. Unfortunately, there aren't utilities right now in TACO to directly express the tiling that you want when converting a dense -> BCSR, so you would have to explicitly iterate over the values in WDense
and insert each value into WBCSR
and then call pack
.