MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / preprocess_static_op

Function preprocess_static_op

fastdeploy/import_ops.py:94–113  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

92
93
94def 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)

Callers 1

import_custom_opsFunction · 0.85

Calls 1

wrap_unified_opFunction · 0.85

Tested by

no test coverage detected