pub struct FakeQuantizePlan<TIn: Element> { /* private fields */ }Expand description
fake_quantize forward plan.
y = scale * (clamp(round(x / scale) + zp, q_min, q_max) - zp).
The FP-only roundtrip of quantize-then-dequantize, no integer
storage (PyTorch torch.fake_quantize_per_tensor_affine).
When to use: QAT (quantization-aware training) — produces a
lossy FP output of the same dtype as the input. Pair with
FakeQuantizeBackwardPlan for
STE autograd.
Dtypes: {f32, f64, f16, bf16} in and out (same dtype).
Shape limits: flat [numel].
Workspace: none.
Precision guarantee: deterministic, bit-stable. Round-ties- even matches FW quantize.
Implementations§
Source§impl<TIn: Element> FakeQuantizePlan<TIn>
impl<TIn: Element> FakeQuantizePlan<TIn>
Sourcepub fn select(
_stream: &Stream,
desc: &FakeQuantizeDescriptor,
_pref: PlanPreference,
) -> Result<Self>
pub fn select( _stream: &Stream, desc: &FakeQuantizeDescriptor, _pref: PlanPreference, ) -> Result<Self>
Pick a kernel.
Sourcepub fn can_implement(&self, args: &FakeQuantizeArgs<'_, TIn>) -> Result<()>
pub fn can_implement(&self, args: &FakeQuantizeArgs<'_, TIn>) -> Result<()>
Validate args.
Sourcepub fn workspace_size(&self) -> usize
pub fn workspace_size(&self) -> usize
Workspace bytes.
Sourcepub fn precision_guarantee(&self) -> PrecisionGuarantee
pub fn precision_guarantee(&self) -> PrecisionGuarantee
Numerical guarantees.
Auto Trait Implementations§
impl<TIn> Freeze for FakeQuantizePlan<TIn>
impl<TIn> RefUnwindSafe for FakeQuantizePlan<TIn>where
TIn: RefUnwindSafe,
impl<TIn> Send for FakeQuantizePlan<TIn>where
TIn: Send,
impl<TIn> Sync for FakeQuantizePlan<TIn>where
TIn: Sync,
impl<TIn> Unpin for FakeQuantizePlan<TIn>where
TIn: Unpin,
impl<TIn> UnsafeUnpin for FakeQuantizePlan<TIn>
impl<TIn> UnwindSafe for FakeQuantizePlan<TIn>where
TIn: UnwindSafe,
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