Handle Keyword dict keys in fused-pipeline primitive
Some checks are pending
GPU Worker CI/CD / test (push) Waiting to run
GPU Worker CI/CD / deploy (push) Blocked by required conditions

This commit is contained in:
giles
2026-02-04 09:53:28 +00:00
parent b773689814
commit 1442216a15
2 changed files with 22 additions and 5 deletions

View File

@@ -858,6 +858,19 @@ except ImportError as e:
_FUSED_PIPELINE_CACHE = {} _FUSED_PIPELINE_CACHE = {}
def _normalize_effect_dict(effect):
"""Convert effect dict with Keyword keys to string keys."""
result = {}
for k, v in effect.items():
# Handle Keyword objects from sexp parser
if hasattr(k, 'name'): # Keyword object
key = k.name
else:
key = str(k)
result[key] = v
return result
def prim_fused_pipeline(img, effects_list, **dynamic_params): def prim_fused_pipeline(img, effects_list, **dynamic_params):
""" """
Apply a fused CUDA kernel pipeline to an image. Apply a fused CUDA kernel pipeline to an image.
@@ -879,6 +892,9 @@ def prim_fused_pipeline(img, effects_list, **dynamic_params):
Supported ops: rotate, zoom, ripple, invert, hue_shift, brightness Supported ops: rotate, zoom, ripple, invert, hue_shift, brightness
""" """
# Normalize effects list - convert Keyword keys to strings
effects_list = [_normalize_effect_dict(e) for e in effects_list]
if not _FUSED_KERNELS_AVAILABLE: if not _FUSED_KERNELS_AVAILABLE:
# Fallback: apply effects one by one # Fallback: apply effects one by one
result = img result = img

View File

@@ -15,12 +15,13 @@
(require-primitives "math") (require-primitives "math")
;; Define the effects pipeline (compiled to single CUDA kernel) ;; Define the effects pipeline (compiled to single CUDA kernel)
;; Each effect is a map with :op and effect-specific parameters
(def effects-pipeline (def effects-pipeline
[{"op" "rotate" "angle" 0} [{:op "rotate" :angle 0}
{"op" "zoom" "amount" 1.0} {:op "zoom" :amount 1.0}
{"op" "hue_shift" "degrees" 30} {:op "hue_shift" :degrees 30}
{"op" "ripple" "amplitude" 15 "frequency" 10 "decay" 2 "phase" 0 "center_x" 960 "center_y" 540} {:op "ripple" :amplitude 15 :frequency 10 :decay 2 :phase 0 :center_x 960 :center_y 540}
{"op" "brightness" "factor" 1.0}]) {:op "brightness" :factor 1.0}])
;; Frame pipeline ;; Frame pipeline
(frame (frame