Struct ANeuralNetworksOperandType

Source
#[repr(C)]
pub struct ANeuralNetworksOperandType { pub type_: i32, pub dimensionCount: u32, pub dimensions: *const u32, pub scale: f32, pub zeroPoint: i32, }
Expand description

ANeuralNetworksOperandType describes the type of an operand.

This structure is used to describe both scalars and tensors.

A tensor operand type with all dimensions specified is “fully specified”. Whenever possible (i.e., whenever the dimensions are known at model construction time), a tensor operand type should be (but is not required to be) fully specified, in order to enable the best possible performance.

If a tensor operand’s type is not fully specified, the dimensions of the operand are deduced from the operand types and values of the operation for which that operand is an output or from the corresponding {@link ANEURALNETWORKS_IF} or {@link ANEURALNETWORKS_WHILE} operation input operand type in the case of referenced model input operands.

In the following situations, a tensor operand type must be fully specified:

  • The operand has a constant value, set by {@link ANeuralNetworksModel_setOperandValue} (with a non-nullptr buffer) or {@link ANeuralNetworksModel_setOperandValueFromMemory}.
  • The operand is a model input (see {@link ANeuralNetworksModel_identifyInputsAndOutputs}) of the main model within a compilation. A fully specified tensor operand type must either be provided to {@link ANeuralNetworksModel_addOperand}; or it must be provided to the corresponding {@link ANeuralNetworksExecution_setInput}, or {@link ANeuralNetworksExecution_setInputFromMemory}. EXCEPTION: If the input is optional and omitted (by passing nullptr for buffer to {@link ANeuralNetworksExecution_setInput}) then it need not have a fully specified tensor operand type.
  • The operand is a model output (see {@link ANeuralNetworksModel_identifyInputsAndOutputs}) of the main model within a compilation and is to be used with {@link ANeuralNetworksExecution_startComputeWithDependencies}. A fully specified tensor operand type must either be provided to {@link ANeuralNetworksModel_addOperand}; or it must be provided to the corresponding {@link ANeuralNetworksExecution_setOutput}, or {@link ANeuralNetworksExecution_setOutputFromMemory}.

A tensor operand type of specified rank but some number of unspecified dimensions is represented by setting dimensionCount to the rank and each unspecified dimension to 0.

Available since API level 27.

Starting at API level 29, a tensor operand type of unspecified rank is represented by setting dimensionCount to 0 and dimensions to NULL (just as if it were a scalar operand type).

Fields§

§type_: i32

The data type, e.g ANEURALNETWORKS_FLOAT32.

§dimensionCount: u32

The number of dimensions (rank).

Must be 0 for scalars.

§dimensions: *const u32

The dimensions of the tensor.

Must be nullptr for scalars.

§scale: f32

The quantization scale.

Must be 0 when not applicable to an operand type.

See {@link OperandCode}.

§zeroPoint: i32

The quantization zero point.

Must be 0 when not applicable to an operand type.

See {@link OperandCode}.

Trait Implementations§

Source§

impl Clone for ANeuralNetworksOperandType

Source§

fn clone(&self) -> ANeuralNetworksOperandType

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 ANeuralNetworksOperandType

Source§

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

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

impl Copy for ANeuralNetworksOperandType

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.