warp.sparse.bsr_compress#
- warp.sparse.bsr_compress(
- src,
- prune_numerical_zeros=True,
- inplace=False,
- topology=None,
Compress the active blocks of
srcand returnsrc.Slack entries outside
offsets[row]:offsets[row] + row_counts[row]are ignored. Wheninplace=False, the topology is rebuilt natively from active row and column data, and values are accumulated with differentiable Warp kernels. Wheninplace=True, entries are sorted and coalesced independently within each active row using native in-place compression withoutO(nnz)temporary allocation, but this path is not differentiable. In-place compression requires native support and currently supports matrices whose scalar type isfloat32orfloat64;topology="padded"preserves the existing row capacity instead of packing active blocks into compact row storage. Compact compression setssrc.row_countstoNoneand does not update any previously attached row-count array. Callers should not rely on buffer identity being preserved for anyinplacevalue.- Parameters:
src (BsrMatrix[_MatrixBlockType[Rows, Cols, Scalar] | _ScalarBlockType[Scalar]]) – Matrix to compress.
prune_numerical_zeros (bool) – If
True, zero-valued input blocks are ignored before coalescing.inplace (bool) – If
True, sort and coalesce each active row range directly insrcusing native in-place compression withoutO(nnz)temporary allocation. This path is not differentiable. Withtopology="compact", active blocks are also packed into compact row storage. IfFalse, use differentiable value accumulation.topology (Literal['compact', 'padded'] | None) – Topology policy for the compressed arrays. Defaults to
"compact"."padded"preserves existing row capacity; it cannot report row-capacity overflow because compression never increases the active block count.
- Return type:
BsrMatrix[_MatrixBlockType[Rows, Cols, Scalar] | _ScalarBlockType[Scalar]]