#[non_exhaustive]pub struct CsrLayout {
pub nnz: u64,
}Expand description
Descriptor for the CSR (Compressed Sparse Row) sparse layout.
CSR is defined only for rank-2 tensors. A conforming implementation MUST
reject a CSR descriptor whose tensor rank is not 2 (checked by
[LayoutDescriptor::validate_against_shape]).
Three buffers are required:
| Buffer | Contents |
|---|---|
0 — values | Non-zero values in row-major order; nnz elements. |
1 — col_indices | Column index of each non-zero; nnz uint64 elements. |
2 — row_ptr | Row pointer array; nrows + 1 uint64 elements where nrows = shape[0]. |
The byte_offset field MUST be 0 for CSR tensors.
§Examples
use hurray_core::layout::{CsrLayout, LayoutDescriptor};
let layout = LayoutDescriptor::Csr(CsrLayout::new(5));
assert_eq!(layout.tag(), 0x07);
assert_eq!(layout.buffer_count().map(|n| n.get()), Some(3));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.nnz: u64Number of stored (non-zero) elements. MAY be 0 for an empty sparse matrix.
Implementations§
Trait Implementations§
impl Eq for CsrLayout
impl StructuralPartialEq for CsrLayout
Auto Trait Implementations§
impl Freeze for CsrLayout
impl RefUnwindSafe for CsrLayout
impl Send for CsrLayout
impl Sync for CsrLayout
impl Unpin for CsrLayout
impl UnsafeUnpin for CsrLayout
impl UnwindSafe for CsrLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more