Skip to main content

fake_quant_backward

Function fake_quant_backward 

Source
pub fn fake_quant_backward(
    grad: &Array1<f64>,
    x: &Array1<f64>,
    qmin_real: f64,
    qmax_real: f64,
) -> Result<Array1<f64>, GpuOptimError>
Expand description

Straight-through estimator backward for a fake-quant op.

The gradient passes through unchanged where the (pre-quant) value x lies in the representable interval [qmin_real, qmax_real] and is zeroed where the clamp saturates (no gradient flows through a saturated value). The bounds may be supplied in either order.

ยงErrors

Returns GpuOptimError::DimensionMismatch if grad and x differ in length.