Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix question answering error when running pipeline model on cuda #2291

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ def predict_qa(self, questions, start):
for q in questions:
question, context = q.split(SEP)
d = self._qa_model.tokenizer(question, context)
device = self._qa_model.device
out = self._qa_model.model.forward(
**{k: torch.tensor(d[k]).reshape(1, -1) for k in d})
**{k: torch.tensor(
d[k], device=device).reshape(1, -1) for k in d})
logits = out.start_logits if start else out.end_logits
outs.append(logits.reshape(-1).detach().numpy())
outs.append(logits.reshape(-1).detach().cpu().numpy())
return outs

def predict_qa_start(self, questions):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ def _initialize_managers(self):
self.image_mode,
self.max_evals,
self.num_masks,
self.mask_res)
self.mask_res,
self.device)
self._error_analysis_manager = ErrorAnalysisManager(
self._wrapped_model, self.test, self._ext_test_df,
self.target_column,
Expand Down