π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix(losses): make mask_ignore_pixels torch.compile fullgraph-safe (#3792)
Edgar Ribabba1a09dc9b3
diff --git a/kornia/losses/_utils.py b/kornia/losses/_utils.pyindex c26a8bbbc..c0bef8af4 100644--- a/kornia/losses/_utils.py+++ b/kornia/losses/_utils.py@@ -48,7 +48,10 @@ def mask_ignore_pixels(target_mask = target != ignore_index- if target_mask.all():+ # Data-dependent early-out (skip masking when nothing is ignored). Guard it under+ # torch.compile: returning the all-True mask instead of None just makes callers apply+ # a no-op mask, which keeps the result identical while staying fullgraph-safe.+ if not torch.compiler.is_compiling() and target_mask.all():return target, None# map invalid pixels to a valid class (0)