pub struct BoolTensor { /* private fields */ }Expand description
CPU-resident tensor of booleans. Shape is metadata; storage is a flat
Arc<Vec<bool>> for cheap clones.
Implementations§
Source§impl BoolTensor
impl BoolTensor
Sourcepub fn from_vec(
data: Vec<bool>,
shape: Vec<usize>,
) -> Result<BoolTensor, FerrotorchError>
pub fn from_vec( data: Vec<bool>, shape: Vec<usize>, ) -> Result<BoolTensor, FerrotorchError>
Build from a Vec + shape. Errors on numel mismatch.
Sourcepub fn from_slice(
data: &[bool],
shape: &[usize],
) -> Result<BoolTensor, FerrotorchError>
pub fn from_slice( data: &[bool], shape: &[usize], ) -> Result<BoolTensor, FerrotorchError>
Build from a slice + shape (clones into a fresh Vec).
Sourcepub fn zeros(shape: &[usize]) -> BoolTensor
pub fn zeros(shape: &[usize]) -> BoolTensor
All-false tensor of the given shape.
Sourcepub fn ones(shape: &[usize]) -> BoolTensor
pub fn ones(shape: &[usize]) -> BoolTensor
All-true tensor of the given shape.
Sourcepub fn from_predicate<T>(
t: &Tensor<T>,
pred: impl Fn(T) -> bool,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
pub fn from_predicate<T>(
t: &Tensor<T>,
pred: impl Fn(T) -> bool,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
Build a mask by applying pred to every element of t.
Useful for Tensor < 0, Tensor.is_finite(), etc.
Sourcepub fn not(&self) -> BoolTensor
pub fn not(&self) -> BoolTensor
Pointwise NOT.
Sourcepub fn and(&self, other: &BoolTensor) -> Result<BoolTensor, FerrotorchError>
pub fn and(&self, other: &BoolTensor) -> Result<BoolTensor, FerrotorchError>
Pointwise AND. Errors on shape mismatch.
Sourcepub fn or(&self, other: &BoolTensor) -> Result<BoolTensor, FerrotorchError>
pub fn or(&self, other: &BoolTensor) -> Result<BoolTensor, FerrotorchError>
Pointwise OR.
Sourcepub fn xor(&self, other: &BoolTensor) -> Result<BoolTensor, FerrotorchError>
pub fn xor(&self, other: &BoolTensor) -> Result<BoolTensor, FerrotorchError>
Pointwise XOR.
Sourcepub fn reshape(&self, shape: &[usize]) -> Result<BoolTensor, FerrotorchError>
pub fn reshape(&self, shape: &[usize]) -> Result<BoolTensor, FerrotorchError>
Reshape (must preserve numel; no data copy).
Sourcepub fn count_true(&self) -> usize
pub fn count_true(&self) -> usize
Number of true elements.
Sourcepub fn gt<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
pub fn gt<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
Pointwise > comparing two float tensors of the same shape;
produces a BoolTensor of matching shape. Mirrors
torch.gt(a, b) returning a bool tensor. (#615)
Sourcepub fn lt<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
pub fn lt<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
Pointwise <. (#615)
Sourcepub fn ge<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
pub fn ge<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
Pointwise >=. (#615)
Sourcepub fn le<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
pub fn le<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
Pointwise <=. (#615)
Sourcepub fn eq_t<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
pub fn eq_t<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
Pointwise ==. (#615)
Sourcepub fn ne<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
pub fn ne<T>(
a: &Tensor<T>,
b: &Tensor<T>,
) -> Result<BoolTensor, FerrotorchError>where
T: Float,
Pointwise !=. (#615)
Trait Implementations§
Source§impl Clone for BoolTensor
impl Clone for BoolTensor
Source§fn clone(&self) -> BoolTensor
fn clone(&self) -> BoolTensor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoolTensor
impl Debug for BoolTensor
Auto Trait Implementations§
impl Freeze for BoolTensor
impl RefUnwindSafe for BoolTensor
impl Send for BoolTensor
impl Sync for BoolTensor
impl Unpin for BoolTensor
impl UnsafeUnpin for BoolTensor
impl UnwindSafe for BoolTensor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more