Skip to content

Commit 4abbbff

Browse files
linlifanrootmichaelrun
authored
fix an issue that ipex occupy too much memory, it will not impact per… (#5625)
* fix an issue that ipex occupy too much memory, it will not impact performance * make style --------- Co-authored-by: root <[email protected]> Co-authored-by: Meng Guoqing <[email protected]>
1 parent fda2977 commit 4abbbff

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

examples/community/stable_diffusion_ipex.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ def prepare_for_ipex(self, promt, dtype=torch.float32, height=None, width=None,
252252

253253
# optimize with ipex
254254
if dtype == torch.bfloat16:
255-
self.unet = ipex.optimize(
256-
self.unet.eval(), dtype=torch.bfloat16, inplace=True, sample_input=unet_input_example
257-
)
255+
self.unet = ipex.optimize(self.unet.eval(), dtype=torch.bfloat16, inplace=True)
258256
self.vae.decoder = ipex.optimize(self.vae.decoder.eval(), dtype=torch.bfloat16, inplace=True)
259257
self.text_encoder = ipex.optimize(self.text_encoder.eval(), dtype=torch.bfloat16, inplace=True)
260258
if self.safety_checker is not None:
@@ -264,24 +262,20 @@ def prepare_for_ipex(self, promt, dtype=torch.float32, height=None, width=None,
264262
self.unet.eval(),
265263
dtype=torch.float32,
266264
inplace=True,
267-
sample_input=unet_input_example,
268-
level="O1",
269265
weights_prepack=True,
270266
auto_kernel_selection=False,
271267
)
272268
self.vae.decoder = ipex.optimize(
273269
self.vae.decoder.eval(),
274270
dtype=torch.float32,
275271
inplace=True,
276-
level="O1",
277272
weights_prepack=True,
278273
auto_kernel_selection=False,
279274
)
280275
self.text_encoder = ipex.optimize(
281276
self.text_encoder.eval(),
282277
dtype=torch.float32,
283278
inplace=True,
284-
level="O1",
285279
weights_prepack=True,
286280
auto_kernel_selection=False,
287281
)
@@ -290,7 +284,6 @@ def prepare_for_ipex(self, promt, dtype=torch.float32, height=None, width=None,
290284
self.safety_checker.eval(),
291285
dtype=torch.float32,
292286
inplace=True,
293-
level="O1",
294287
weights_prepack=True,
295288
auto_kernel_selection=False,
296289
)

0 commit comments

Comments
 (0)