@@ -994,34 +994,45 @@ def apply(self, **kwargs):
994994 # Get items expected to be specialized
995995 specialize = as_tuple (kwargs .pop ('specialize' , []))
996996
997- if not specialize :
998- # Compile the operator before building the arguments list
999- # to avoid out of memory with greedy compilers
1000- cfunction = self .cfunction
1001-
1002- # Build the arguments list to invoke the kernel function
1003- with self ._profiler .timer_on ('arguments-preprocess' ):
1004- args = self .arguments (** kwargs )
1005- with switch_log_level (comm = args .comm ):
1006- self ._emit_args_profiling ('arguments-preprocess' )
1007-
1008997 # In the case of specialization, arguments must be processed before
1009998 # the operator can be compiled
1010999 if specialize :
10111000 # FIXME: Cannot cope with things like sizes/strides yet since it only
10121001 # looks at the parameters
1013- specialized_args = {p : sympify (args .pop (p .name ))
1014- for p in self .parameters if p .name in specialize }
10151002
1016- op = Specializer (specialized_args ).visit (self )
1003+ # Build the arguments list for specialization
1004+ with self ._profiler .timer_on ('specialized-arguments-preprocess' ):
1005+ args = self .arguments (** kwargs )
1006+ with switch_log_level (comm = args .comm ):
1007+ self ._emit_args_profiling ('specialized-arguments-preprocess' )
10171008
1018- specialized_kwargs = {k : v for k , v in kwargs .items ()
1019- if k not in specialize }
1009+ # Uses parameters here since Specializer needs {symbol: sympy value} mapper
1010+ specialized_values = {p : sympify (args [p .name ])
1011+ for p in self .parameters if p .name in specialize }
1012+
1013+ op = Specializer (specialized_values ).visit (self )
10201014
10211015 # TODO: Does this cause problems for profilers?
10221016 # FIXME: Need some way to inspect this Operator for testing
10231017 # FIXME: Perhaps this should use some separate method
1024- return op .apply (** specialized_kwargs )
1018+ unspecialized_kwargs = {k : v for k , v in kwargs .items ()
1019+ if k not in specialize }
1020+
1021+ return op .apply (** unspecialized_kwargs )
1022+
1023+ # Compile the operator before building the arguments list
1024+ # to avoid out of memory with greedy compilers
1025+ cfunction = self .cfunction
1026+
1027+ # Build the arguments list to invoke the kernel function
1028+ with self ._profiler .timer_on ('arguments-preprocess' ):
1029+ args = self .arguments (** kwargs )
1030+ with switch_log_level (comm = args .comm ):
1031+ self ._emit_args_profiling ('arguments-preprocess' )
1032+
1033+ args_string = ", " .join ([f"{ p .name } ={ args [p .name ]} "
1034+ for p in self .parameters if p .is_Symbol ])
1035+ debug (f"Invoking `{ self .name } ` with scalar arguments: { args_string } " )
10251036
10261037 # Invoke kernel function with args
10271038 arg_values = [args [p .name ] for p in self .parameters ]
0 commit comments