pub struct MatrixWrapper {
pub inner: UnsafeCell<Matrix>,
}Expand description
Thread-safe wrapper around Matrix for concurrent training
Uses UnsafeCell to allow interior mutability across threads.
Safety is ensured by the training algorithm’s access patterns where
each thread writes to distinct rows.
§Fields
inner- The inner matrix data (unsafe cell)
Fields§
§inner: UnsafeCell<Matrix>Trait Implementations§
Source§impl Debug for MatrixWrapper
impl Debug for MatrixWrapper
impl Sync for MatrixWrapper
SAFETY: This is intentionally unsound. Multiple threads will concurrently read and write overlapping rows (e.g. a target in one thread may be a negative sample in another). This mirrors the deliberate data race in Mikolov’s original word2vec C implementation and the word2vec-rs crate it was ported from. SGD tolerates stale/torn reads and the resulting embeddings converge in practice. Do not use MatrixWrapper as a general- purpose concurrent container.
Auto Trait Implementations§
impl !Freeze for MatrixWrapper
impl !RefUnwindSafe for MatrixWrapper
impl Send for MatrixWrapper
impl Unpin for MatrixWrapper
impl UnsafeUnpin for MatrixWrapper
impl UnwindSafe for MatrixWrapper
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
Mutably borrows from an owned value. Read more
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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>
Converts
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>
Converts
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