Transforms operator/function references in the global namespace based on the presence of 'static_op_' prefixes. Args: global_ns (dict): The global namespace (typically globals()) to modify. flag (bool): Determines transformation behavior.
(global_ns)
| 92 | |
| 93 | |
| 94 | def preprocess_static_op(global_ns): |
| 95 | """ |
| 96 | Transforms operator/function references in the global namespace based on the presence of 'static_op_' prefixes. |
| 97 | |
| 98 | Args: |
| 99 | global_ns (dict): The global namespace (typically globals()) to modify. |
| 100 | flag (bool): Determines transformation behavior. |
| 101 | """ |
| 102 | static_op_prefix = "static_op_" |
| 103 | static_op_names = [k for k in global_ns if k.startswith(static_op_prefix)] |
| 104 | |
| 105 | for static_op_name in static_op_names: |
| 106 | op_name = static_op_name.removeprefix(static_op_prefix) |
| 107 | if op_name not in global_ns: |
| 108 | global_ns[op_name] = global_ns[static_op_name] |
| 109 | continue |
| 110 | |
| 111 | original_cpp_ext_op = global_ns[op_name] |
| 112 | original_custom_op = global_ns[static_op_name] |
| 113 | global_ns[op_name] = wrap_unified_op(original_cpp_ext_op, original_custom_op) |
no test coverage detected