Move tensors to GPU
Browse files- handler.py +1 -0
handler.py
CHANGED
@@ -25,6 +25,7 @@ class EndpointHandler():
|
|
25 |
"""
|
26 |
sentences = data.pop("inputs",data)
|
27 |
encoded_input = self.tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
|
|
|
28 |
# Compute token embeddings
|
29 |
with torch.no_grad():
|
30 |
model_output = self.model(**encoded_input)
|
|
|
25 |
"""
|
26 |
sentences = data.pop("inputs",data)
|
27 |
encoded_input = self.tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
|
28 |
+
encoded_input = {key: value.to(self.device) for key, value in encoded_input.items()}
|
29 |
# Compute token embeddings
|
30 |
with torch.no_grad():
|
31 |
model_output = self.model(**encoded_input)
|