Skip to main content

HostData

Struct HostData 

Source
pub struct HostData {
    pub data: HostDataVec,
    pub shape: Shape,
    pub strides: Strides,
}

Fields§

§data: HostDataVec§shape: Shape§strides: Strides

Implementations§

Source§

impl HostData

Source

pub fn from_tensor_handle( client: &ComputeClient<TestRuntime>, tensor_handle: TensorHandle<TestRuntime>, host_data_type: HostDataType, ) -> Self

Source

pub fn get_f32(&self, index: &[usize]) -> f32

Source

pub fn get_bool(&self, index: &[usize]) -> bool

Source

pub fn get_i32(&self, index: &[usize]) -> i32

Source

pub fn try_get_f32(&self, index: &[usize]) -> Option<f32>

Like [get_f32], but returns None if the underlying data isn’t F32 (or the index is out of bounds), instead of panicking.

Source

pub fn try_get_i32(&self, index: &[usize]) -> Option<i32>

Source

pub fn try_get_bool(&self, index: &[usize]) -> Option<bool>

Source

pub fn iter_indices(&self) -> impl Iterator<Item = Vec<usize>> + '_

Iterate every logical index in row-major order, yielding the index vector.

Useful when callers want to walk a non-contiguous tensor without re-implementing the rank recursion themselves.

Source

pub fn iter_indexed_f32(&self) -> impl Iterator<Item = (Vec<usize>, f32)> + '_

Iterate (index, f32 value) pairs in row-major order. Panics if the underlying data isn’t F32.

Source

pub fn iter_indexed_i32(&self) -> impl Iterator<Item = (Vec<usize>, i32)> + '_

Iterate (index, i32 value) pairs in row-major order. Panics if the underlying data isn’t I32.

Source

pub fn iter_indexed_bool(&self) -> impl Iterator<Item = (Vec<usize>, bool)> + '_

Iterate (index, bool value) pairs in row-major order. Panics if the underlying data isn’t Bool.

Source

pub fn pretty_print(&self) -> String

Render the tensor as one or more 2-D tables.

  • rank 1: a single row.
  • rank 2: a table.
  • rank ≥ 3: one labeled table per combination of leading-dim indices (the last two dims are always the row/col axes).
Source

pub fn pretty_print_slice<I>(&self, filter: I) -> String

Like [pretty_print], but only prints slices whose leading-dim indices match the filter. Wildcards (DimFilter::Any) iterate every value.

filter accepts both Vec<std::ops::Range<usize>> and the canonical TensorFilter (the CUBE_TEST_MODE M-K syntax).

Trait Implementations§

Source§

impl Clone for HostData

Source§

fn clone(&self) -> HostData

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HostData

Source§

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

Formats the value using the given formatter. Read more

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<C> CloneExpand for C
where C: Clone,

Source§

fn __expand_clone_method(&self, _scope: &mut Scope) -> C

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoComptime for T

Source§

fn comptime(self) -> Self

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> TuneInputs for T
where T: Clone + Send + Sync + 'static,

Source§

type At<'a> = T

The concrete input type at lifetime 'a.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,