pub struct BitTensor { /* private fields */ }Expand description
A boolean tensor stored as bit-packed u64 words.
Each element occupies a single bit, so an n-element tensor is held in
ceil(n / 64) words. The logical shape and element count
drive layout; bitwise operations work directly on the packed words.
Implementations§
Source§impl BitTensor
impl BitTensor
Sourcepub fn from_bools(shape: Vec<usize>, bits: &[bool]) -> Option<Self>
pub fn from_bools(shape: Vec<usize>, bits: &[bool]) -> Option<Self>
Packs a slice of booleans into a bit tensor of the given shape.
Returns None when bits.len() does not match the element count
implied by shape.
Sourcepub fn to_bools(&self) -> Vec<bool>
pub fn to_bools(&self) -> Vec<bool>
Unpacks the tensor back into one boolean per element, in flat order.
Sourcepub fn bit_or(&self, other: &Self) -> Option<Self>
pub fn bit_or(&self, other: &Self) -> Option<Self>
Element-wise bitwise OR with another bit tensor of the same shape.
Returns None when the shapes differ.
Trait Implementations§
impl Eq for BitTensor
Source§impl SpecTensor for BitTensor
impl SpecTensor for BitTensor
Source§fn shape(&self) -> &[usize]
fn shape(&self) -> &[usize]
The length of each axis of the specialized tensor, outermost first.
Source§fn dtype(&self) -> Symbol
fn dtype(&self) -> Symbol
The element number domain (dtype) of the specialized tensor’s cells.
Source§fn to_uniform(&self) -> Tensor
fn to_uniform(&self) -> Tensor
Converts this specialized tensor into the uniform
Tensor storage.Source§fn from_uniform(tensor: &Tensor) -> Option<Self>
fn from_uniform(tensor: &Tensor) -> Option<Self>
Rebuilds a specialized tensor from uniform storage, or
None if the
uniform tensor’s dtype or shape does not fit this backend.impl StructuralPartialEq for BitTensor
Auto Trait Implementations§
impl Freeze for BitTensor
impl RefUnwindSafe for BitTensor
impl Send for BitTensor
impl Sync for BitTensor
impl Unpin for BitTensor
impl UnsafeUnpin for BitTensor
impl UnwindSafe for BitTensor
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