pub struct HostData {
pub data: HostDataVec,
pub shape: Shape,
pub strides: Strides,
}Fields§
§data: HostDataVec§shape: Shape§strides: StridesImplementations§
Source§impl HostData
impl HostData
pub fn from_tensor_handle( client: &ComputeClient<TestRuntime>, tensor_handle: TensorHandle<TestRuntime>, host_data_type: HostDataType, ) -> Self
pub fn get_f32(&self, index: &[usize]) -> f32
pub fn get_bool(&self, index: &[usize]) -> bool
pub fn get_i32(&self, index: &[usize]) -> i32
Sourcepub fn try_get_f32(&self, index: &[usize]) -> Option<f32>
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.
pub fn try_get_i32(&self, index: &[usize]) -> Option<i32>
pub fn try_get_bool(&self, index: &[usize]) -> Option<bool>
Sourcepub fn iter_indices(&self) -> impl Iterator<Item = Vec<usize>> + '_
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.
Sourcepub fn iter_indexed_f32(&self) -> impl Iterator<Item = (Vec<usize>, f32)> + '_
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.
Sourcepub fn iter_indexed_i32(&self) -> impl Iterator<Item = (Vec<usize>, i32)> + '_
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.
Sourcepub fn iter_indexed_bool(&self) -> impl Iterator<Item = (Vec<usize>, bool)> + '_
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.
Sourcepub fn pretty_print(&self) -> String
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).
Sourcepub fn pretty_print_slice<I>(&self, filter: I) -> String
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).