warp.sparse.BsrTripletMap#
- class warp.sparse.BsrTripletMap(capacity=0, device=None)[source]#
Reusable mapping from COO triplets to an existing BSR topology.
Build this mapping with
bsr_set_from_triplets()through itsbuild_mappingargument, then update the matrix values withbsr_set_from_mapped_values(). Every map caches a triplet-to-block lookup for atomic accumulation and block-grouped triplet indices for atomic-free gather reduction.Constructing a map preallocates its storage. Passing it as
build_mappingthen rebuilds it in place, without allocating as long as its capacity covers the triplet count. This allows, for instance, allocating the storage outside of a CUDA graph capture and building the map within it, so that the map does not depend on the graph’s lifetime.The map is built without host synchronization, so its arrays are sized by the triplet count, which is an upper bound on the destination block count. The actual block count is read on the device from the destination offsets.
The destination matrix topology must remain unchanged while the map is in use. Its numerical values may be replaced freely.
- Parameters:
capacity (int) – Number of triplets to preallocate storage for. The storage grows as needed when the map is built for more triplets.
device (warp.DeviceLike) – Device on which to allocate the storage.
Methods
validate(dest)Raise if
destdimensions or topology storage differ from those recorded by this map.Attributes
Number of triplets the map can be built for without reallocating its storage.
Device on which the map storage is allocated.
Number of input triplets the map was last built for.
- triplet_count#
Number of input triplets the map was last built for.