#[non_exhaustive]pub struct CooLayout {
pub nnz: u64,
pub is_sorted: bool,
}Expand description
Descriptor for the COO (Coordinate list) sparse layout.
A COO tensor stores non-zero elements as (index_tuple, value) pairs.
It requires two buffers:
| Buffer | Contents |
|---|---|
0 — values | Non-zero element values; nnz elements of the tensor element type. |
1 — indices | Index tuples as uint64; nnz × rank elements, stored row-major: indices[i * rank + d] is coordinate d of non-zero i. |
The byte_offset field in the common descriptor header MUST be 0 for
COO tensors (no meaningful “first element at a fixed offset”).
§Examples
use hurray_core::layout::{CooLayout, LayoutDescriptor};
let layout = LayoutDescriptor::Coo(CooLayout::new(3, true));
assert_eq!(layout.tag(), 0x06);
assert_eq!(layout.buffer_count().map(|n| n.get()), Some(2));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 tensor.
is_sorted: booltrue if non-zeros are stored in lexicographic index order
(dimension 0 major); false if no ordering guarantee is made.
Implementations§
Trait Implementations§
impl Eq for CooLayout
impl StructuralPartialEq for CooLayout
Auto Trait Implementations§
impl Freeze for CooLayout
impl RefUnwindSafe for CooLayout
impl Send for CooLayout
impl Sync for CooLayout
impl Unpin for CooLayout
impl UnsafeUnpin for CooLayout
impl UnwindSafe for CooLayout
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