pub struct EmbeddingCache<B: Backend> {
pub dft_cos: Tensor<B, 2>,
pub dft_sin: Tensor<B, 2>,
pub channel_one_hot: Tensor<B, 2>,
pub spectral_bins: usize,
pub patch_size: usize,
}Expand description
Cached on-device tensors for the patch embedding.
Created once via EmbeddingCache::new and reused across forward calls,
avoiding repeated CPU→device transfers of constant data.
Fields§
§dft_cos: Tensor<B, 2>DFT cosine basis [K, N] where K = spectral_bins, N = patch_size.
dft_sin: Tensor<B, 2>DFT sine basis [K, N].
channel_one_hot: Tensor<B, 2>Channel one-hot matrix [C, C].
spectral_bins: usize§patch_size: usizeImplementations§
Source§impl<B: Backend> EmbeddingCache<B>
impl<B: Backend> EmbeddingCache<B>
Sourcepub fn new(cfg: &ModelConfig, device: &B::Device) -> Self
pub fn new(cfg: &ModelConfig, device: &B::Device) -> Self
Build cached device tensors for a given config.
Auto Trait Implementations§
impl<B> Freeze for EmbeddingCache<B>where
<B as Backend>::FloatTensorPrimitive: Freeze,
<B as Backend>::QuantizedTensorPrimitive: Freeze,
impl<B> RefUnwindSafe for EmbeddingCache<B>where
<B as Backend>::FloatTensorPrimitive: RefUnwindSafe,
<B as Backend>::QuantizedTensorPrimitive: RefUnwindSafe,
impl<B> Send for EmbeddingCache<B>
impl<B> Sync for EmbeddingCache<B>
impl<B> Unpin for EmbeddingCache<B>
impl<B> UnsafeUnpin for EmbeddingCache<B>where
<B as Backend>::FloatTensorPrimitive: UnsafeUnpin,
<B as Backend>::QuantizedTensorPrimitive: UnsafeUnpin,
impl<B> UnwindSafe for EmbeddingCache<B>where
<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
Mutably borrows from an owned value. Read more
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