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: i8Zero point of the first input.
input_b_zero_point: i8Zero point of the second input.
requantizer_a: RequantizerRescales the first input to the output: scale_a / scale_out.
requantizer_b: RequantizerRescales the second input to the output: scale_b / scale_out.
Implementations§
Trait Implementations§
impl Copy for QConcat
impl Eq for QConcat
impl StructuralPartialEq for QConcat
Auto Trait Implementations§
impl Freeze for QConcat
impl RefUnwindSafe for QConcat
impl Send for QConcat
impl Sync for QConcat
impl Unpin for QConcat
impl UnsafeUnpin for QConcat
impl UnwindSafe for QConcat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more