pub struct QuantizedResidualAdd { /* private fields */ }Expand description
Quantized Residual Addition
Adds two quantized tensors with potentially different scales: output = input1 + input2
Handles scale alignment and requantization.
Implementations§
Source§impl QuantizedResidualAdd
impl QuantizedResidualAdd
Sourcepub fn new(scale1: f32, scale2: f32) -> Self
pub fn new(scale1: f32, scale2: f32) -> Self
Create a new quantized residual add layer
§Arguments
scale1- Scale of first inputscale2- Scale of second input
Sourcepub fn forward_int8(
&self,
input1: &[u8],
scale1: f32,
zero_point1: u8,
input2: &[u8],
scale2: f32,
zero_point2: u8,
shape: &[usize],
) -> CnnResult<(Vec<u8>, f32, u8)>
pub fn forward_int8( &self, input1: &[u8], scale1: f32, zero_point1: u8, input2: &[u8], scale2: f32, zero_point2: u8, shape: &[usize], ) -> CnnResult<(Vec<u8>, f32, u8)>
Forward pass with INT8 inputs
§Arguments
input1- First quantized u8 inputscale1- Scale of first inputzero_point1- Zero point of first inputinput2- Second quantized u8 inputscale2- Scale of second inputzero_point2- Zero point of second inputshape- Tensor shape (must be identical for both inputs)
§Returns
(output, output_scale, output_zero_point)
Sourcepub fn forward_int8_i16(
&self,
input1: &[u8],
scale1: f32,
zero_point1: u8,
input2: &[u8],
scale2: f32,
zero_point2: u8,
shape: &[usize],
) -> CnnResult<(Vec<u8>, f32, u8)>
pub fn forward_int8_i16( &self, input1: &[u8], scale1: f32, zero_point1: u8, input2: &[u8], scale2: f32, zero_point2: u8, shape: &[usize], ) -> CnnResult<(Vec<u8>, f32, u8)>
Forward pass with scale alignment (i16 intermediate precision)
More accurate version using i16 intermediate precision.
Sourcepub fn output_scale(&self) -> f32
pub fn output_scale(&self) -> f32
Get output scale
Sourcepub fn output_zero_point(&self) -> u8
pub fn output_zero_point(&self) -> u8
Get output zero point
Trait Implementations§
Source§impl Clone for QuantizedResidualAdd
impl Clone for QuantizedResidualAdd
Source§fn clone(&self) -> QuantizedResidualAdd
fn clone(&self) -> QuantizedResidualAdd
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for QuantizedResidualAdd
impl RefUnwindSafe for QuantizedResidualAdd
impl Send for QuantizedResidualAdd
impl Sync for QuantizedResidualAdd
impl Unpin for QuantizedResidualAdd
impl UnsafeUnpin for QuantizedResidualAdd
impl UnwindSafe for QuantizedResidualAdd
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