pub struct HoloTensorEncoder { /* private fields */ }Expand description
Holographic tensor encoder.
Encodes tensors into holographic fragments using the selected encoding scheme.
Implementations§
Source§impl HoloTensorEncoder
impl HoloTensorEncoder
Sourcepub fn new(encoding: HolographicEncoding) -> Self
pub fn new(encoding: HolographicEncoding) -> Self
Create encoder with specified encoding scheme.
Sourcepub fn with_fragments(self, n: u16) -> Self
pub fn with_fragments(self, n: u16) -> Self
Set number of fragments.
Sourcepub fn with_compression(self, algo: CompressionAlgorithm) -> Self
pub fn with_compression(self, algo: CompressionAlgorithm) -> Self
Set compression algorithm for fragments.
Sourcepub fn with_essential_ratio(self, ratio: f32) -> Self
pub fn with_essential_ratio(self, ratio: f32) -> Self
Set essential ratio for spectral encoding.
Sourcepub fn with_max_rank(self, rank: usize) -> Self
pub fn with_max_rank(self, rank: usize) -> Self
Set max rank for LRDF encoding.
Sourcepub fn encode_nd(
&self,
data: &[f32],
shape: &[usize],
) -> Result<(HoloTensorHeader, Vec<HoloFragment>)>
pub fn encode_nd( &self, data: &[f32], shape: &[usize], ) -> Result<(HoloTensorHeader, Vec<HoloFragment>)>
Encode n-dimensional tensor with arbitrary shape.
Preserves the original shape in the header while internally flattening to 2D for encoding.
§Arguments
data- Flattened tensor datashape- Original tensor shape (e.g.,[256]for 1D,[8, 8]for 2D)
§Example
ⓘ
// Encode 1D layernorm weights with shape preservation
let weights = vec![0.1f32; 576];
let (header, fragments) = encoder.encode_nd(&weights, &[576])?;
assert_eq!(header.shape, vec![576]); // Shape preserved!Sourcepub fn encode_2d(
&self,
data: &[f32],
rows: usize,
cols: usize,
) -> Result<(HoloTensorHeader, Vec<HoloFragment>)>
pub fn encode_2d( &self, data: &[f32], rows: usize, cols: usize, ) -> Result<(HoloTensorHeader, Vec<HoloFragment>)>
Encode 2D tensor (matrix).
Sourcepub fn encode_1d(
&self,
data: &[f32],
) -> Result<(HoloTensorHeader, Vec<HoloFragment>)>
pub fn encode_1d( &self, data: &[f32], ) -> Result<(HoloTensorHeader, Vec<HoloFragment>)>
Encode 1D tensor (vector).
Preserves the original 1D shape in the header (e.g., [576] instead of [1, 576]).
Auto Trait Implementations§
impl Freeze for HoloTensorEncoder
impl RefUnwindSafe for HoloTensorEncoder
impl Send for HoloTensorEncoder
impl Sync for HoloTensorEncoder
impl Unpin for HoloTensorEncoder
impl UnwindSafe for HoloTensorEncoder
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