Apply IPEX to CUDA hijacks using `library.ipex.ipex_init`. This function should run right after importing torch and before doing anything else. If xpu is not available, this function does nothing.
()
| 88 | |
| 89 | |
| 90 | def init_ipex(): |
| 91 | """ |
| 92 | Apply IPEX to CUDA hijacks using `library.ipex.ipex_init`. |
| 93 | |
| 94 | This function should run right after importing torch and before doing anything else. |
| 95 | |
| 96 | If xpu is not available, this function does nothing. |
| 97 | """ |
| 98 | try: |
| 99 | if HAS_XPU: |
| 100 | from library.ipex import ipex_init |
| 101 | |
| 102 | is_initialized, error_message = ipex_init() |
| 103 | if not is_initialized: |
| 104 | print("failed to initialize ipex:", error_message) |
| 105 | else: |
| 106 | return |
| 107 | except Exception as e: |
| 108 | print("failed to initialize ipex:", e) |
no test coverage detected