Skip to main content

TensorReader

Struct TensorReader 

Source
pub struct TensorReader<R> { /* private fields */ }
Expand description

Specialized reader for tensor data with format-specific handling

Implementations§

Source§

impl<R: Read> TensorReader<R>

Source

pub fn new(reader: R) -> Self

Create a new tensor reader

Source

pub fn read_tensor_data( &mut self, tensor_info: &TensorInfo, ) -> Result<TensorReadResult>

Read tensor data with default options

Source

pub fn read_tensor_data_with_options( &mut self, tensor_info: &TensorInfo, options: &TensorReadOptions, ) -> Result<TensorReadResult>

Read tensor data with custom options

Source

pub fn read_multiple_tensors( &mut self, tensor_infos: &[&TensorInfo], options: &TensorReadOptions, ) -> Result<Vec<TensorReadResult>>

Read multiple tensors efficiently

Source

pub fn read_tensor_chunked( &mut self, tensor_info: &TensorInfo, chunk_size: usize, callback: impl FnMut(&[u8]) -> Result<()>, ) -> Result<()>

Read tensor data in chunks for large tensors

Source

pub fn position(&self) -> u64

Get current position

Source

pub fn reset_position(&mut self)

Reset position counter

Source

pub fn skip_bytes(&mut self, count: usize) -> Result<()>

Skip bytes in the stream

Source§

impl<R: Read + Seek> TensorReader<R>

Source

pub fn with_seek(reader: R) -> Self

Create a tensor reader with seeking support

Source

pub fn seek(&mut self, pos: SeekFrom) -> Result<u64>

Seek to a specific position

Source

pub fn read_tensor_at_offset( &mut self, tensor_info: &TensorInfo, offset: u64, options: &TensorReadOptions, ) -> Result<TensorReadResult>

Read tensor data at a specific offset

Source

pub fn read_tensors_by_offset( &mut self, tensors: &[(u64, &TensorInfo)], options: &TensorReadOptions, ) -> Result<Vec<TensorReadResult>>

Read multiple tensors by seeking to their offsets

Trait Implementations§

Source§

impl<R: Debug> Debug for TensorReader<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for TensorReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for TensorReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for TensorReader<R>
where R: Send,

§

impl<R> Sync for TensorReader<R>
where R: Sync,

§

impl<R> Unpin for TensorReader<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for TensorReader<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for TensorReader<R>
where R: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.