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
ec026747
Unverified
Commit
ec026747
authored
Jul 30, 2020
by
Lysandre Debut
Committed by
GitHub
Jul 30, 2020
Browse files
Fix FlauBERT GPU test (#6142)
* Fix GPU test * Remove legacy constructor
parent
91cb9546
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/transformers/modeling_flaubert.py
src/transformers/modeling_flaubert.py
+3
-3
No files found.
src/transformers/modeling_flaubert.py
View file @
ec026747
...
@@ -163,11 +163,13 @@ class FlaubertModel(XLMModel):
...
@@ -163,11 +163,13 @@ class FlaubertModel(XLMModel):
else
:
else
:
bs
,
slen
=
inputs_embeds
.
size
()[:
-
1
]
bs
,
slen
=
inputs_embeds
.
size
()[:
-
1
]
device
=
input_ids
.
device
if
input_ids
is
not
None
else
inputs_embeds
.
device
if
lengths
is
None
:
if
lengths
is
None
:
if
input_ids
is
not
None
:
if
input_ids
is
not
None
:
lengths
=
(
input_ids
!=
self
.
pad_index
).
sum
(
dim
=
1
).
long
()
lengths
=
(
input_ids
!=
self
.
pad_index
).
sum
(
dim
=
1
).
long
()
else
:
else
:
lengths
=
torch
.
LongT
ensor
([
slen
]
*
bs
)
lengths
=
torch
.
t
ensor
([
slen
]
*
bs
,
device
=
device
)
# mask = input_ids != self.pad_index
# mask = input_ids != self.pad_index
# check inputs
# check inputs
...
@@ -184,8 +186,6 @@ class FlaubertModel(XLMModel):
...
@@ -184,8 +186,6 @@ class FlaubertModel(XLMModel):
# if self.is_decoder and src_enc is not None:
# if self.is_decoder and src_enc is not None:
# src_mask = torch.arange(src_len.max(), dtype=torch.long, device=lengths.device) < src_len[:, None]
# src_mask = torch.arange(src_len.max(), dtype=torch.long, device=lengths.device) < src_len[:, None]
device
=
input_ids
.
device
if
input_ids
is
not
None
else
inputs_embeds
.
device
# position_ids
# position_ids
if
position_ids
is
None
:
if
position_ids
is
None
:
position_ids
=
torch
.
arange
(
slen
,
dtype
=
torch
.
long
,
device
=
device
)
position_ids
=
torch
.
arange
(
slen
,
dtype
=
torch
.
long
,
device
=
device
)
...
...
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