Fix xpu Pytorch nightly build from calling optimize which doesn't exist. (#4978)

This commit is contained in:
Simon Lui 2024-09-19 18:11:42 +09:00 committed by GitHub
parent a1e71cfad1
commit de8e8e3b0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -326,7 +326,7 @@ class LoadedModel:
self.model_unload()
raise e
if is_intel_xpu() and not args.disable_ipex_optimize and self.real_model is not None:
if is_intel_xpu() and not args.disable_ipex_optimize and 'ipex' in globals() and self.real_model is not None:
with torch.no_grad():
self.real_model = ipex.optimize(self.real_model.eval(), inplace=True, graph_mode=True, concat_linear=True)