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)
| 149 | |
| 150 | |
| 151 | def _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 | |
| 180 | def _attach_pyfuncs_to_irmodule(irmodule, all_pyfuncs): |
no outgoing calls
no test coverage detected
searching dependent graphs…