I have a situation where I need to calculate G^T * K * G, where both G and K are sparse and represented using CSR. G is unchanging, but I have a number of different K’s for which I need to calculate this value, and so would like to use batched multiplication. My issue is that although each K is the same size, they do not have the same number of non-zero elements, so the length of the column indices and value arrays are different for each K. As I understand, the parameter columnsValuesBatchStride
in cusparseCsrSetStridedBatch
is described as “Address offset between consecutive batches for the column and value arrays”, so it’s expected that each matrix has the same number of non-zero elements. I was wondering if I could determine the maximum number of non-zero elements of all the K’s, then pad all the other K’s with dummy values (e.g. entries with a value of 0), such that they all have the same number of non-zero elements. Would this be valid? Or would this invalidate the calculations? If so, what else could I do to enable batched multiplication?
Thanks, Ben.