Skip to main content

HoloTensorEncoder

Struct HoloTensorEncoder 

Source
pub struct HoloTensorEncoder { /* private fields */ }
Expand description

Holographic tensor encoder.

Encodes tensors into holographic fragments using the selected encoding scheme.

Implementations§

Source§

impl HoloTensorEncoder

Source

pub fn new(encoding: HolographicEncoding) -> Self

Create encoder with specified encoding scheme.

Source

pub fn with_fragments(self, n: u16) -> Self

Set number of fragments.

Source

pub fn with_seed(self, seed: u64) -> Self

Set seed for deterministic encoding.

Source

pub fn with_compression(self, algo: CompressionAlgorithm) -> Self

Set compression algorithm for fragments.

Source

pub fn with_essential_ratio(self, ratio: f32) -> Self

Set essential ratio for spectral encoding.

Source

pub fn with_max_rank(self, rank: usize) -> Self

Set max rank for LRDF encoding.

Source

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 data
  • shape - 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!
Source

pub fn encode_2d( &self, data: &[f32], rows: usize, cols: usize, ) -> Result<(HoloTensorHeader, Vec<HoloFragment>)>

Encode 2D tensor (matrix).

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.