Skip to main content

ste_forward

Function ste_forward 

Source
pub fn ste_forward(
    input: &Tensor,
    scale: f32,
    min_val: f32,
    max_val: f32,
) -> Result<Tensor>
Expand description

Apply STE forward pass (quantize then dequantize).

This creates a “fake quantized” tensor that:

  • Has values as if they were quantized and dequantized
  • Can receive gradients normally during backprop

§Arguments

  • input - Input tensor to quantize
  • scale - Scale factor for quantization
  • min_val - Minimum quantized value (e.g., -1 for ternary)
  • max_val - Maximum quantized value (e.g., +1 for ternary)

§Errors

Returns error if tensor operations fail.