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
OpenDAS
ColossalAI
Commits
d70f43dd
"vscode:/vscode.git/clone" did not exist on "377f854c4f61dad5b72aba1d4fe63a688b2b4cdd"
Unverified
Commit
d70f43dd
authored
Mar 21, 2022
by
ver217
Committed by
GitHub
Mar 21, 2022
Browse files
embedding remove attn mask (#474)
parent
75443471
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
model_zoo/gpt/gpt.py
model_zoo/gpt/gpt.py
+4
-4
No files found.
model_zoo/gpt/gpt.py
View file @
d70f43dd
...
...
@@ -43,7 +43,7 @@ class GPTEmbedding(nn.Module):
def
word_embedding_weight
(
self
):
return
self
.
word_embeddings
.
weight
def
forward
(
self
,
input_ids
,
attention_mask
=
None
,
position_ids
=
None
,
tokentype_ids
=
None
):
def
forward
(
self
,
input_ids
,
position_ids
=
None
,
tokentype_ids
=
None
):
seq_length
=
input_ids
.
size
(
1
)
if
position_ids
is
None
:
position_ids
=
torch
.
arange
(
seq_length
,
dtype
=
torch
.
long
,
device
=
get_current_device
()).
unsqueeze
(
0
)
...
...
@@ -52,7 +52,7 @@ class GPTEmbedding(nn.Module):
x
=
x
+
self
.
tokentype_embeddings
(
tokentype_ids
)
x
=
self
.
dropout
(
x
)
return
x
,
attention_mask
return
x
@
LAYERS
.
register_module
...
...
@@ -285,7 +285,7 @@ class GPT(nn.Module):
dtype
=
dtype
)
def
forward
(
self
,
input_ids
,
attention_mask
=
None
):
x
,
attention_mask
=
self
.
embed
(
input_ids
,
attention_mask
)
x
=
self
.
embed
(
input_ids
)
# We create a 3D attention mask from a 2D tensor mask.
# Sizes are [batch_size, 1, 1, to_seq_length]
...
...
@@ -362,7 +362,7 @@ class PipelineGPT(nn.Module):
def
forward
(
self
,
x
=
None
,
input_ids
=
None
,
attention_mask
=
None
):
if
self
.
first
:
x
,
attention_mask
=
self
.
embed
(
input_ids
,
attention_mask
)
x
=
self
.
embed
(
input_ids
)
# We create a 3D attention mask from a 2D tensor mask.
# Sizes are [batch_size, 1, 1, to_seq_length]
...
...
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