#[repr(transparent)]pub struct Bool(pub u8);Expand description
Boolean element marker. #[repr(transparent)] wrapper around u8
(1-byte storage).
Truthiness convention follows PyTorch / NumPy: 0 is false; any
non-zero byte is true. Kernels that consume Bool operands normalize
the input to 0 or 1 before applying the logical op so the result
is always strictly 0 or 1. The wrapper is #[repr(transparent)]
over u8, so a DeviceBuffer<u8> (byte substrate) can be
reinterpreted as a DeviceBuffer<Bool> via view_as without
copying.
Used as the element type of comparison-op output tensors (eq, gt,
…) and as the input element type for the logical-op family
(logical_and, logical_or, logical_xor). Implements Element
so the same BinaryPlan<T, N> / UnaryPlan<T, N> shapes extend to
boolean tensors.
Tuple Fields§
§0: u8Implementations§
Trait Implementations§
impl Copy for Bool
impl DeviceRepr for Bool
Source§impl Element for Bool
Boolean as an elementwise kernel input element. Used by the logical
op family (logical_and / logical_or / logical_xor) and as the
output type of comparison ops. Storage is 1 byte per element via the
Bool wrapper.
impl Element for Bool
Boolean as an elementwise kernel input element. Used by the logical
op family (logical_and / logical_or / logical_xor) and as the
output type of comparison ops. Storage is 1 byte per element via the
Bool wrapper.
The Scalar projection is f32 (nominal).
Source§type Scalar = f32
type Scalar = f32
f32 for f16/bf16/f32/F32Strict
— the epilogue runs at f32 to match the F32 accumulator. f64
for f64 — the DGEMM path uses an F64 accumulator and
f64 alpha/beta. For integer / Bool elements the projection
is nominally f32 (no α/β-scaled epilogue applies).impl Eq for Bool
Source§impl KernelDtype for Bool
impl KernelDtype for Bool
Source§const KIND: ElementKind = ElementKind::Bool
const KIND: ElementKind = ElementKind::Bool
crate::KernelSku::element.