Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
28c77ddf
Unverified
Commit
28c77ddf
authored
Dec 07, 2020
by
Sylvain Gugger
Committed by
GitHub
Dec 07, 2020
Browse files
Fix QA pipeline on Windows (#8947)
parent
72d6c9c6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
0 deletions
+2
-0
src/transformers/pipelines.py
src/transformers/pipelines.py
+2
-0
No files found.
src/transformers/pipelines.py
View file @
28c77ddf
...
@@ -1883,6 +1883,8 @@ class QuestionAnsweringPipeline(Pipeline):
...
@@ -1883,6 +1883,8 @@ class QuestionAnsweringPipeline(Pipeline):
with
torch
.
no_grad
():
with
torch
.
no_grad
():
# Retrieve the score for the context tokens only (removing question tokens)
# Retrieve the score for the context tokens only (removing question tokens)
fw_args
=
{
k
:
torch
.
tensor
(
v
,
device
=
self
.
device
)
for
(
k
,
v
)
in
fw_args
.
items
()}
fw_args
=
{
k
:
torch
.
tensor
(
v
,
device
=
self
.
device
)
for
(
k
,
v
)
in
fw_args
.
items
()}
# On Windows, the default int type in numpy is np.int32 so we get some non-long tensors.
fw_args
=
{
k
:
v
.
long
()
if
v
.
dtype
==
torch
.
int32
else
v
for
(
k
,
v
)
in
fw_args
.
items
()}
start
,
end
=
self
.
model
(
**
fw_args
)[:
2
]
start
,
end
=
self
.
model
(
**
fw_args
)[:
2
]
start
,
end
=
start
.
cpu
().
numpy
(),
end
.
cpu
().
numpy
()
start
,
end
=
start
.
cpu
().
numpy
(),
end
.
cpu
().
numpy
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment