pub struct TileScorer {
pub tile: usize,
pub active: usize,
}Expand description
A reusable tiled scorer over a fixed decoder. Holds the tile width so the
router can score a whole minibatch with one object, never materialising an
N×K block.
Fields§
§tile: usize§active: usizeImplementations§
Source§impl TileScorer
impl TileScorer
pub fn new(active: usize, tile: usize) -> Self
Sourcepub fn route_row(
&self,
row: ArrayView1<'_, f32>,
decoder: ArrayView2<'_, f32>,
) -> Vec<(u32, f32)>
pub fn route_row( &self, row: ArrayView1<'_, f32>, decoder: ArrayView2<'_, f32>, ) -> Vec<(u32, f32)>
Top-active atoms for row against decoder.
Sourcepub fn route_minibatch(
&self,
rows: ArrayView2<'_, f32>,
decoder: ArrayView2<'_, f32>,
) -> Vec<Vec<(u32, f32)>>
pub fn route_minibatch( &self, rows: ArrayView2<'_, f32>, decoder: ArrayView2<'_, f32>, ) -> Vec<Vec<(u32, f32)>>
Top-active atoms for every row of a minibatch rows (B × P) against
decoder (K × P), scored a column tile at a time via a batched GEMM.
This is the implementation that delivers the module’s promise: the score
block formed at any instant is B × tile (peak rows × tile,
independent of K), and each tile is a single (B × P)·(P × tile)
matrix multiply rather than B × tile scalar dot loops. The online
top-s selector sees the atoms in the same global order as
Self::route_row (tile 0 first, ascending atom index). The GEMM
contracts the same P terms but matrixmultiply may accumulate them in
a blocked order, so the per-atom scores agree with the row-at-a-time path
only to f32 rounding; where two atoms tie within that rounding the two
paths may select different members of the tie (interchangeable for the
reconstruction, which is why the fit stays minibatch-invariant rather
than bit-identical). Returns one (atom, score) shortlist per row, in row
order.
Trait Implementations§
Source§impl Clone for TileScorer
impl Clone for TileScorer
Source§fn clone(&self) -> TileScorer
fn clone(&self) -> TileScorer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TileScorer
Auto Trait Implementations§
impl Freeze for TileScorer
impl RefUnwindSafe for TileScorer
impl Send for TileScorer
impl Sync for TileScorer
impl Unpin for TileScorer
impl UnsafeUnpin for TileScorer
impl UnwindSafe for TileScorer
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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,
impl<T, U> Imply<T> for U
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.