@@ -82,11 +82,13 @@ def annotation_type(cls):
8282 return DtypeConversionConfig
8383
8484 @classmethod
85- def parameter (cls ) -> inspect .Parameter :
85+ def parameter (
86+ cls , * , default_value : "DtypeConversionConfig | None" = None
87+ ) -> inspect .Parameter :
8688 return inspect .Parameter (
8789 cls .require_parameter_name (),
8890 inspect .Parameter .KEYWORD_ONLY ,
89- default = cls .default_value (),
91+ default = cls .default_value () if default_value is None else default_value ,
9092 annotation = cls .annotation_type (),
9193 )
9294
@@ -355,6 +357,7 @@ def wrap_dtype_preserving_callable(
355357 mem_type : MemoryType ,
356358 * ,
357359 slice_by_slice_default : bool = False ,
360+ dtype_config_default : DtypeConversionConfig | None = None ,
358361):
359362 """
360363 Return a callable with ArrayBridge dtype and slice controls.
@@ -366,18 +369,25 @@ def wrap_dtype_preserving_callable(
366369 input_memory_type = MemoryType (MemoryContractAttribute .INPUT .read (func , mem_type .value ))
367370 output_memory_type = MemoryType (MemoryContractAttribute .OUTPUT .read (func , mem_type .value ))
368371 scale_func = output_memory_type .scale_dtype
372+ default_dtype_config = (
373+ DtypeConversionConfig .default_value ()
374+ if dtype_config_default is None
375+ else dtype_config_default
376+ )
377+ if not isinstance (default_dtype_config , DtypeConversionConfig ):
378+ raise TypeError ("Callable dtype default must be a DtypeConversionConfig." )
369379
370380 @functools .wraps (func )
371381 def dtype_wrapper (image , * args , ** kwargs ):
372382 # Pipeline runtimes may inject dtype_config; direct calls use the same
373- # preserve-input default explicitly.
383+ # callable-owned default explicitly (preserve-input when undeclared) .
374384 slice_by_slice = kwargs .pop (
375385 SliceBySliceRuntimeParameter .require_parameter_name (),
376386 slice_by_slice_default ,
377387 )
378388 dtype_config : DtypeConversionConfig = kwargs .pop (
379389 DtypeConversionConfig .require_parameter_name (),
380- DtypeConversionConfig . default_value () ,
390+ default_dtype_config ,
381391 )
382392 dtype_conversion = dtype_config .default_dtype_conversion
383393
@@ -427,7 +437,7 @@ def _apply_dtype_conversion(array):
427437 )
428438 )
429439 dtype_signature = KeywordOnlySignatureExtension (dtype_signature ).with_parameter (
430- DtypeConversionConfig .parameter ()
440+ DtypeConversionConfig .parameter (default_value = default_dtype_config )
431441 )
432442 setattr (dtype_wrapper , "__signature__" , dtype_signature )
433443
@@ -513,6 +523,7 @@ def decorator(
513523 oom_recovery = True ,
514524 contract = None ,
515525 slice_by_slice_default = False ,
526+ dtype_config_default : DtypeConversionConfig | None = None ,
516527 ):
517528 """
518529 Decorator for {mem_type} memory type functions.
@@ -524,6 +535,8 @@ def decorator(
524535 oom_recovery: Enable automatic OOM recovery (default: True)
525536 contract: Optional validation function for outputs
526537 slice_by_slice_default: Default for the decorator-owned slice control
538+ dtype_config_default: Callable-owned dtype policy for direct calls;
539+ explicit runtime dtype_config still overrides this default.
527540
528541 Returns:
529542 Decorated function with memory type metadata and dtype preservation
@@ -541,6 +554,7 @@ def inner_decorator(func):
541554 func ,
542555 mem_type ,
543556 slice_by_slice_default = slice_by_slice_default ,
557+ dtype_config_default = dtype_config_default ,
544558 )
545559
546560 # Apply GPU wrapper if this is a GPU memory type
0 commit comments