Skip to main content

Module ciou

Module ciou 

Source
Expand description

Fused CIoU loss Triton kernels for YOLO detection training.

Computes Complete-IoU (CIoU) loss between predicted and target boxes, both in XYWH world-coordinate format, in a single fused kernel pass.

CIoU = 1 − IoU + d²/c² + α·v

where:

  • IoU = intersection / union
  • d² = squared Euclidean distance between box centers
  • c² = squared diagonal of the smallest enclosing box
  • v = (4/π²) · (atan(tw/th) − atan(pw/ph))² (aspect-ratio consistency)
  • α = v / (1 − IoU + v + ε)

Layout:

  • pred: [4, N] — predicted (cx, cy, w, h) per anchor
  • target: [4, N] — target (cx, cy, w, h) per anchor
  • loss: [N] — per-anchor CIoU loss
  • iou: [N] — saved IoU (forward → backward)
  • v: [N] — saved aspect-ratio term (forward → backward)
  • alpha: [N] — saved α coefficient (forward → backward)

Parallelism: one CTA per BLOCK_N-wide anchor tile. Grid: cdiv(N, BLOCK_N) flat CTAs.

Structs§

YoloCiouLossBackward
Fused CIoU loss backward: computes ∂L/∂pred given the upstream gradient and the saved activations from the forward pass.
YoloCiouLossForward
Fused CIoU loss forward: predicted and target XYWH boxes → per-anchor loss plus saved activations (iou, v, alpha) needed by the backward pass.

Functions§

yolo_ciou_loss_backward
Fused CIoU loss backward: computes ∂L/∂pred given the upstream gradient and the saved activations from the forward pass.
yolo_ciou_loss_forward
Fused CIoU loss forward: predicted and target XYWH boxes → per-anchor loss plus saved activations (iou, v, alpha) needed by the backward pass.