Empty cache after embedding to cpu (#9477)
This commit is contained in:
parent
c487b53f21
commit
731b0aaade
1 changed files with 1 additions and 0 deletions
|
|
@ -23,4 +23,5 @@ class LLMEmbedding(torch.nn.Embedding):
|
||||||
def forward(self, x: Tensor):
|
def forward(self, x: Tensor):
|
||||||
if self.weight.device != 'cpu':
|
if self.weight.device != 'cpu':
|
||||||
self.to('cpu')
|
self.to('cpu')
|
||||||
|
torch.xpu.empty_cache()
|
||||||
return super().forward(x.to('cpu')).to(x.device)
|
return super().forward(x.to('cpu')).to(x.device)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue