Skip to main content

QConcat

Struct QConcat 

Source
pub struct QConcat {
    pub input_a_zero_point: i8,
    pub input_b_zero_point: i8,
    pub requantizer_a: Requantizer,
    pub requantizer_b: Requantizer,
}
Expand description

Concatenation of two NHWC tensors along the channel axis (C++ QConcat2_2D, TFLite CONCATENATION on the last axis): the output’s channels are the first input’s, then the second’s, each rescaled onto the output grid by its own requantizer (calibration::build_rescaler). The output’s channel count must be CA + CB, or the call does not compile.

use tinymind::int8::{QConcat, Requantizer};

// Both inputs already on the output grid: ratio 1 (multiplier 2^30, shift -1).
let same = Requantizer { multiplier: 1 << 30, shift: -1, zero_point: 0, qmin: -128, qmax: 127 };
let concat = QConcat { input_a_zero_point: 0, input_b_zero_point: 0, requantizer_a: same, requantizer_b: same };
let a = [[[1i8]; 2]; 1];
let b = [[[2i8, 3]; 2]; 1];
let mut y = [[[0i8; 3]; 2]; 1];
concat.forward(&a, &b, &mut y);
assert_eq!(y, [[[1, 2, 3]; 2]]);

An output whose channels are not the two inputs’ together does not compile:

ⓘ
let a = [[[1i8]; 2]; 1];
let b = [[[2i8, 3]; 2]; 1];
let mut y = [[[0i8; 4]; 2]; 1]; // 4 channels: 1 + 2 is 3
concat.forward(&a, &b, &mut y);

Fields§

§input_a_zero_point: i8

Zero point of the first input.

§input_b_zero_point: i8

Zero point of the second input.

§requantizer_a: Requantizer

Rescales the first input to the output: scale_a / scale_out.

§requantizer_b: Requantizer

Rescales the second input to the output: scale_b / scale_out.

Implementations§

Source§

impl QConcat

Source

pub fn forward<const H: usize, const W: usize, const CA: usize, const CB: usize, const C: usize>( &self, a: &[[[i8; CA]; W]; H], b: &[[[i8; CB]; W]; H], out: &mut [[[i8; C]; W]; H], )

Concatenate a (CA channels) and b (CB channels) into out (C = CA + CB channels), pixel by pixel.

Trait Implementations§

Source§

impl Clone for QConcat

Source§

fn clone(&self) -> Self

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 Copy for QConcat

Source§

impl Debug for QConcat

Source§

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

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

impl Eq for QConcat

Source§

impl PartialEq for QConcat

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for QConcat

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

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.