Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

perf(augmentation): skip the per-forward param deepcopy when there are no kwargs (#3819)

Edgar Ribae9511401b431
diff --git a/kornia/augmentation/utils/helpers.py b/kornia/augmentation/utils/helpers.py
index 017326570..d08afe22c 100644
--- a/kornia/augmentation/utils/helpers.py
+++ b/kornia/augmentation/utils/helpers.py
@@ -408,7 +408,11 @@ def override_parameters(
in_place: if to override in-place or not.
"""
- if params_override is None:
+ # Nothing to override (None or an empty kwargs dict β€” the common forward path): return the
+ # params untouched. This skips a per-call `deepcopy_dict` (a full tensor clone of every
+ # param) that only existed to decouple the copy from the override β€” with no override there
+ # is nothing to decouple. Matches the pre-existing `None` fast path.
+ if not params_override:
return params
out = params if in_place else deepcopy_dict(params)
for k, v in params_override.items():