Skip to main content

TensorAttr

Struct TensorAttr 

Source
pub struct TensorAttr {
    pub index: u32,
    pub shape: Vec<u32>,
    pub n_elems: u32,
    pub size: u32,
    pub size_with_stride: u32,
    pub format: TensorFormat,
    pub data_type: TensorType,
    pub qnt_type: QuantType,
    pub zp: i32,
    pub scale: f32,
    pub name: String,
}
Expand description

Metadata for a single tensor (input or output).

Contains everything you need to interpret the tensor data: shape, memory layout, data type, and quantization parameters.

§Quantization fields

  • zp (zero-point) and scale are used for INT8 affine dequantization: f32_value = (raw_i8 - zp) * scale
  • These are set during model conversion and are different for each tensor.

§Shape

For NC1HWC2 outputs (common on RV1106), the shape is [1, c1, H, W, c2]. For NHWC inputs, the shape is [1, H, W, C].

Fields§

§index: u32

Tensor index (0 for first input/output, 1 for second, etc.).

§shape: Vec<u32>

Tensor dimensions. See TensorFormat for how to interpret them.

§n_elems: u32

Total number of elements in the tensor.

§size: u32

Size in bytes.

§size_with_stride: u32

Size in bytes including stride padding (used for memory allocation).

§format: TensorFormat

Memory layout of the tensor data.

§data_type: TensorType

Element data type.

§qnt_type: QuantType

Quantization method.

§zp: i32

Quantization zero-point (for affine dequantization).

§scale: f32

Quantization scale (for affine dequantization).

§name: String

Human-readable tensor name from the model.

Trait Implementations§

Source§

impl Clone for TensorAttr

Source§

fn clone(&self) -> TensorAttr

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TensorAttr

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<&RknnTensorAttr> for TensorAttr

Implements From for TensorAttr

Source§

fn from(raw: &RknnTensorAttr) -> Self

Converts to this type from the input type.

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> 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> 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> 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.