pub struct VariantEvaluator<B: Backend> { /* private fields */ }Expand description
A type-erased per-variant evaluator.
Built from a concrete Module variant M and a scorer Fn(&M) -> f32, it
captures a ModuleReshaper<B, M>
in a boxed closure and exposes only B-generic operations. The concrete
M is invisible to callers.
Implementations§
Source§impl<B: Backend> VariantEvaluator<B>
impl<B: Backend> VariantEvaluator<B>
Sourcepub fn new<M, F>(template: M, scorer: F) -> Self
pub fn new<M, F>(template: M, scorer: F) -> Self
Build an evaluator for one architecture variant.
template is an instance of the concrete Module variant (its weights
are irrelevant — only its shape is used, to build the reshaper).
scorer maps an unflattened module to a fitness value in the canonical
maximise convention (higher is better).
Sourcepub fn num_params(&self) -> usize
pub fn num_params(&self) -> usize
Number of flat float parameters this variant occupies (the active prefix width of a padded weight row).
Sourcepub fn score(&self, padded_row: Tensor<B, 1>) -> f32
pub fn score(&self, padded_row: Tensor<B, 1>) -> f32
Score a single (padded) weight row.
The leading num_params columns are sliced off, unflattened into the
concrete module, and scored; trailing padding is ignored. Returns a
fitness value in the canonical maximise convention.
§Panics
Panics if padded_row has fewer than num_params elements.
Trait Implementations§
Auto Trait Implementations§
impl<B> !RefUnwindSafe for VariantEvaluator<B>
impl<B> !UnwindSafe for VariantEvaluator<B>
impl<B> Freeze for VariantEvaluator<B>
impl<B> Send for VariantEvaluator<B>
impl<B> Sync for VariantEvaluator<B>
impl<B> Unpin for VariantEvaluator<B>
impl<B> UnsafeUnpin for VariantEvaluator<B>
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> 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