pub struct Population<B: Backend, K> { /* private fields */ }Expand description
Population stored on a Burn backend device.
The concrete tensor type depends on the genome kind K. Most
consumers interact with Population<B, Real> via tensor,
but strategies parameterized on the kind can keep the K generic and
reach for the right tensor flavor through the inherent impls below.
Invariant: for every Population<B, K> produced by the public
constructors, exactly one of tensor_real / tensor_int is Some,
determined by K. Real populates tensor_real; Binary,
Integer, and Permutation populate tensor_int. The inherent
tensor(&self) accessors .expect() on the matching field because
the constructor contract pins the invariant — a mismatch would be a
bug in this module.
Implementations§
Source§impl<B: Backend, K> Population<B, K>
impl<B: Backend, K> Population<B, K>
Source§impl<B: Backend> Population<B, Real>
impl<B: Backend> Population<B, Real>
Sourcepub fn new_real(tensor: Tensor<B, 2>) -> Self
pub fn new_real(tensor: Tensor<B, 2>) -> Self
Constructs a real-valued population from a Tensor<B, 2>.
§Panics
Panics if the tensor is not rank 2.
Sourcepub fn tensor(&self) -> &Tensor<B, 2>
pub fn tensor(&self) -> &Tensor<B, 2>
Borrows the backing real-valued tensor.
§Panics
Never panics for a correctly constructed Population<B, Real>.
Sourcepub fn into_tensor(self) -> Tensor<B, 2>
pub fn into_tensor(self) -> Tensor<B, 2>
Consumes the wrapper and returns the owned tensor.
§Panics
Never panics for a correctly constructed Population<B, Real>.
Source§impl<B: Backend> Population<B, Binary>
impl<B: Backend> Population<B, Binary>
Sourcepub fn new_binary(tensor: Tensor<B, 2, Int>) -> Self
pub fn new_binary(tensor: Tensor<B, 2, Int>) -> Self
Constructs a binary population from a Tensor<B, 2, Int>.
§Panics
Panics if the tensor is not rank 2.
Source§impl<B: Backend> Population<B, Integer>
impl<B: Backend> Population<B, Integer>
Sourcepub fn new_integer(tensor: Tensor<B, 2, Int>) -> Self
pub fn new_integer(tensor: Tensor<B, 2, Int>) -> Self
Constructs an integer population from a Tensor<B, 2, Int>.
§Panics
Panics if the tensor is not rank 2.
Trait Implementations§
Auto Trait Implementations§
impl<B, K> Freeze for Population<B, K>where
<B as Backend>::IntTensorPrimitive: Freeze,
<B as Backend>::FloatTensorPrimitive: Freeze,
<B as Backend>::QuantizedTensorPrimitive: Freeze,
impl<B, K> RefUnwindSafe for Population<B, K>where
K: RefUnwindSafe,
<B as Backend>::IntTensorPrimitive: RefUnwindSafe,
<B as Backend>::FloatTensorPrimitive: RefUnwindSafe,
<B as Backend>::QuantizedTensorPrimitive: RefUnwindSafe,
impl<B, K> Send for Population<B, K>where
K: Send,
impl<B, K> Sync for Population<B, K>where
K: Sync,
impl<B, K> Unpin for Population<B, K>where
K: Unpin,
<B as Backend>::IntTensorPrimitive: Unpin,
<B as Backend>::FloatTensorPrimitive: Unpin,
<B as Backend>::QuantizedTensorPrimitive: Unpin,
impl<B, K> UnsafeUnpin for Population<B, K>where
<B as Backend>::IntTensorPrimitive: UnsafeUnpin,
<B as Backend>::FloatTensorPrimitive: UnsafeUnpin,
<B as Backend>::QuantizedTensorPrimitive: UnsafeUnpin,
impl<B, K> UnwindSafe for Population<B, K>where
K: UnwindSafe,
<B as Backend>::IntTensorPrimitive: UnwindSafe,
<B as Backend>::FloatTensorPrimitive: UnwindSafe,
<B as Backend>::QuantizedTensorPrimitive: UnwindSafe,
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> 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 more