MCPcopy Index your code
hub / github.com/apache/tvm / _create_python_packed_func

Function _create_python_packed_func

python/tvm/script/parser/core/entry.py:151–177  ·  view source on GitHub ↗

Create a PackedFunc wrapper for a Python function. This function creates a PackedFunc that can be called from TVM runtime and will execute the original Python function. Parameters ---------- pyfunc : Callable The Python function to wrap. Returns ------- Pac

(pyfunc)

Source from the content-addressed store, hash-verified

149
150
151def _create_python_packed_func(pyfunc):
152 """Create a PackedFunc wrapper for a Python function.
153
154 This function creates a PackedFunc that can be called from TVM runtime
155 and will execute the original Python function.
156
157 Parameters
158 ----------
159 pyfunc : Callable
160 The Python function to wrap.
161
162 Returns
163 -------
164 PackedFunc
165 A PackedFunc that wraps the Python function.
166 """
167
168 def packed_func_wrapper(*args, **kwargs):
169 """Wrapper function that calls the original Python function."""
170 try:
171 result = pyfunc(*args, **kwargs)
172 return result
173 except Exception as error:
174 print(f"Error calling Python function {pyfunc.__name__}: {error}")
175 raise
176
177 return packed_func_wrapper
178
179
180def _attach_pyfuncs_to_irmodule(irmodule, all_pyfuncs):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…