pub fn yolo_ciou_loss_backward<T: Triton, D: Float, const BLOCK_N: i32>(
dy_ptr: T::Pointer<D>,
pred_ptr: T::Pointer<D>,
target_ptr: T::Pointer<D>,
iou_ptr: T::Pointer<D>,
v_ptr: T::Pointer<D>,
alpha_ptr: T::Pointer<D>,
d_pred_ptr: T::Pointer<D>,
N: i32,
)Expand description
Fused CIoU loss backward: computes ∂L/∂pred given the upstream gradient and the saved activations from the forward pass.
Only produces gradients w.r.t. pred; target boxes are treated as constants.
Gradient decomposes into three independent parts:
(a) IoU term: ∂(−IoU)/∂pred (b) Center-distance term: ∂(d²/(c²+ε))/∂pred (c) α·v term: ∂(α·v)/∂(pw,ph) — zero for (px,py)
The min/max branching for intersection and enclosing-box corners is re-derived from (pred, target) rather than saved, since pred+target fully determine which branch was active.
Grid: cdiv(N, BLOCK_N) — one CTA per anchor tile.