mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-02 19:21:31 +06:00
Optimize inference only mode memory if ipex is used (#21083)
* Optimize inference only mode memory if ipex is used Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> * fix code style Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> Signed-off-by: Wang, Yi A <yi.a.wang@intel.com>
This commit is contained in:
parent
6767ce71d6
commit
e849e5bb4a
@ -1309,8 +1309,9 @@ class Trainer:
|
||||
|
||||
if not training:
|
||||
model.eval()
|
||||
dtype = torch.bfloat16 if not self.is_in_train and self.args.bf16_full_eval else dtype
|
||||
# conv_bn_folding is disabled as it fails in symbolic tracing, resulting in ipex warnings
|
||||
model = ipex.optimize(model, dtype=dtype, level="O1", conv_bn_folding=False)
|
||||
model = ipex.optimize(model, dtype=dtype, level="O1", conv_bn_folding=False, inplace=not self.is_in_train)
|
||||
else:
|
||||
if not model.training:
|
||||
model.train()
|
||||
|
Loading…
Reference in New Issue
Block a user