From 1442216a15576fe40f20f20843b05a129d18d77e Mon Sep 17 00:00:00 2001 From: giles Date: Wed, 4 Feb 2026 09:53:28 +0000 Subject: [PATCH] Handle Keyword dict keys in fused-pipeline primitive --- sexp_effects/primitive_libs/streaming_gpu.py | 16 ++++++++++++++++ test_fused_pipeline.sexp | 11 ++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sexp_effects/primitive_libs/streaming_gpu.py b/sexp_effects/primitive_libs/streaming_gpu.py index e7ac693..78a3f6c 100644 --- a/sexp_effects/primitive_libs/streaming_gpu.py +++ b/sexp_effects/primitive_libs/streaming_gpu.py @@ -858,6 +858,19 @@ except ImportError as e: _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): """ 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 """ + # Normalize effects list - convert Keyword keys to strings + effects_list = [_normalize_effect_dict(e) for e in effects_list] + if not _FUSED_KERNELS_AVAILABLE: # Fallback: apply effects one by one result = img diff --git a/test_fused_pipeline.sexp b/test_fused_pipeline.sexp index 2e682bb..72ee033 100644 --- a/test_fused_pipeline.sexp +++ b/test_fused_pipeline.sexp @@ -15,12 +15,13 @@ (require-primitives "math") ;; Define the effects pipeline (compiled to single CUDA kernel) + ;; Each effect is a map with :op and effect-specific parameters (def effects-pipeline - [{"op" "rotate" "angle" 0} - {"op" "zoom" "amount" 1.0} - {"op" "hue_shift" "degrees" 30} - {"op" "ripple" "amplitude" 15 "frequency" 10 "decay" 2 "phase" 0 "center_x" 960 "center_y" 540} - {"op" "brightness" "factor" 1.0}]) + [{:op "rotate" :angle 0} + {:op "zoom" :amount 1.0} + {:op "hue_shift" :degrees 30} + {:op "ripple" :amplitude 15 :frequency 10 :decay 2 :phase 0 :center_x 960 :center_y 540} + {:op "brightness" :factor 1.0}]) ;; Frame pipeline (frame