warp.sparse.bsr_zeros#

warp.sparse.bsr_zeros(
rows_of_blocks,
cols_of_blocks,
block_type,
device=None,
*,
topology=None,
row_capacity=None,
nnz_capacity=None,
)[source]#

Construct and return an empty BSR or CSR matrix with the given shape.

Parameters:
  • rows_of_blocks (int) – Number of rows of blocks.

  • cols_of_blocks (int) – Number of columns of blocks.

  • block_type (BlockType) – Type of individual blocks. For CSR matrices, this should be a scalar type. For BSR matrices, this should be a matrix type (e.g. from warp.types.matrix()).

  • device (wp.DeviceLike) – Device on which to allocate the matrix arrays.

  • topology (Literal['compact', 'padded'] | None) – Topology policy. Defaults to "compact" unless row_capacity is provided, in which case it defaults to "padded".

  • row_capacity (int | Array[int] | None) – Optional row capacity for padded matrices. May be a nonnegative integer for uniform capacity, or an integer Warp array of shape (rows_of_blocks,) for per-row capacity. Providing this implies padded topology when topology is omitted.

  • nnz_capacity (int | None) – Optional storage allocation upper bound for columns and values. This is mainly useful with per-row row_capacity arrays when an upper bound is already known. When row_capacity is an array, the caller is responsible for ensuring nnz_capacity is at least the total row capacity. During CUDA graph capture, per-row row_capacity arrays require an explicit nnz_capacity to avoid a host readback.

Return type:

BsrMatrix