pub struct BlockSparseTensorDescriptor { /* private fields */ }Implementations§
Source§impl BlockSparseTensorDescriptor
impl BlockSparseTensorDescriptor
Sourcepub fn create(
ctx: &Context,
section_count_per_mode: &[u32],
section_extents: &[u64],
non_zero_block_count: u64,
non_zero_coordinates: &[i32],
block_strides: Option<&[u64]>,
data_type: DataType,
) -> Result<Self>
pub fn create( ctx: &Context, section_count_per_mode: &[u32], section_extents: &[u64], non_zero_block_count: u64, non_zero_coordinates: &[i32], block_strides: Option<&[u64]>, data_type: DataType, ) -> Result<Self>
Creates a block-sparse tensor descriptor.
A block-sparse tensor descriptor fully specifies the data layout of a block-sparse tensor (currently limited to up to 8 modes).
Consider an example for a block-sparse tensor of order 2, namely a block-sparse matrix A.
Its first mode (rows) is subdivided into 5 sections (with extents 4, 2, 3, 4, 5, respectively), and its second mode (columns) is subdivided into 3 sections (with extents 2, 3, 7).
The matrix has 8 non-zero blocks:
| 2 columns | 3 columns | 7 columns |
|---|---|---|
| 4 x 2 | 4 x 7 | |
| 2 x 3 | ||
| 3 x 3 | 3 x 7 | |
| 4 x 2 | ||
| 5 x 3 | 5 x 7 |
Each subsection has the same extent across its entire mode: every block within the same section of a mode has the same extent. For example, in the table above every block on the right has 7 columns, and all blocks on the bottom have 5 rows.
Only non-zero blocks are stored; zero blocks are left blank in the representation above.
For example:
- strides of block #0: 5, 1, 10, 20. Sorted strides would be: 1, 5, 10, 20. The permutation to sort the strides in this case is to swap the first two elements.
- strides of block #1: 10, 1, 30, 60. Applying the permutation would result in: 1, 10, 30, 60. The result is sorted in ascending order, which is allowed.
- strides of block #2: 1, 5, 50, 100. Applying permutation would result in: 5, 1, 50, 100. The result is not sorted in ascending order, this is not allowed.
This non-blocking call is thread-safe but not reentrant.
§Errors
Returns an error if the context cannot be bound, the section extent, coordinate, or stride slices do not match the descriptor dimensions, a value cannot be represented for cuTENSOR, cuTENSOR rejects the descriptor, or cuTENSOR returns a null descriptor handle.
pub fn mode_count(&self) -> u32
pub fn non_zero_block_count(&self) -> u64
pub fn data_type(&self) -> DataType
pub const fn as_raw(&self) -> cutensorBlockSparseTensorDescriptor_t
Sourcepub unsafe fn from_raw(
handle: cutensorBlockSparseTensorDescriptor_t,
ctx: &Context,
mode_count: u32,
non_zero_block_count: u64,
data_type: DataType,
) -> Self
pub unsafe fn from_raw( handle: cutensorBlockSparseTensorDescriptor_t, ctx: &Context, mode_count: u32, non_zero_block_count: u64, data_type: DataType, ) -> Self
Wraps an existing cuTENSOR block-sparse tensor descriptor and takes ownership of it.
§Safety
handle must be a valid cutensorBlockSparseTensorDescriptor_t whose
mode count, non-zero block count, and data type match the metadata
supplied to this function. Ownership of handle is transferred to the
returned descriptor, and the handle must not be destroyed elsewhere after
calling this function.
Sourcepub fn into_raw(self) -> cutensorBlockSparseTensorDescriptor_t
pub fn into_raw(self) -> cutensorBlockSparseTensorDescriptor_t
Consumes the descriptor and returns the raw cuTENSOR block-sparse tensor descriptor handle without destroying it.
The caller becomes responsible for eventually destroying the returned handle with cuTENSOR.