pub struct QPad2D<const PT: usize, const PB: usize, const PL: usize, const PR: usize> {
pub pad_value: i8,
}Expand description
Explicit spatial padding of an NHWC tensor with a constant (C++ QPad2D,
TFLite PAD): PT rows above, PB below, PL columns on the left and
PR on the right, each holding pad_value in every channel. The
convolution layers pad by themselves; this is for models with a separate
PAD operator. The output must be H + PT + PB by W + PL + PR, or the call
does not compile.
use tinymind::int8::QPad2D;
let input = [[[1i8, 2]; 2]; 1];
let mut padded = [[[0i8; 2]; 3]; 2]; // one row below, one column on the left
QPad2D::<0, 1, 1, 0> { pad_value: -7 }.forward(&input, &mut padded);
assert_eq!(padded, [[[-7, -7], [1, 2], [1, 2]], [[-7, -7]; 3]]);A padded size that does not add up does not compile:
ⓘ
let input = [[[1i8, 2]; 2]; 1];
let mut padded = [[[0i8; 2]; 4]; 2]; // 4 columns: 2 + 1 + 0 is 3
QPad2D::<0, 1, 1, 0> { pad_value: -7 }.forward(&input, &mut padded);Fields§
§pad_value: i8The value every padded element holds: the tensor’s zero point for a real 0.0, as TFLite pads.
Implementations§
Trait Implementations§
Source§impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Clone for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Clone for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Copy for QPad2D<PT, PB, PL, PR>
Source§impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Debug for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Debug for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Eq for QPad2D<PT, PB, PL, PR>
Source§impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> PartialEq for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> PartialEq for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> StructuralPartialEq for QPad2D<PT, PB, PL, PR>
Auto Trait Implementations§
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Freeze for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> RefUnwindSafe for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Send for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Sync for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> Unpin for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> UnsafeUnpin for QPad2D<PT, PB, PL, PR>
impl<const PT: usize, const PB: usize, const PL: usize, const PR: usize> UnwindSafe for QPad2D<PT, PB, PL, PR>
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