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
Megatron-LM
Commits
fabd3e4e
Commit
fabd3e4e
authored
Nov 10, 2022
by
Yu Yao
Committed by
Jared Casper
Nov 10, 2022
Browse files
ViT Backbone Tensor Shape Fix
parent
1a26b291
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
megatron/model/vision/vit_backbone.py
megatron/model/vision/vit_backbone.py
+8
-2
No files found.
megatron/model/vision/vit_backbone.py
View file @
fabd3e4e
...
...
@@ -234,14 +234,20 @@ class VitBackbone(MegatronModule):
token_embeddings
=
concatenated_tokens
+
\
self
.
position_embeddings
(
self
.
position_ids
[:,
:
concatenated_tokens
.
shape
[
1
]])
# [b, s, h] => [s, b, h]
token_embeddings
=
token_embeddings
.
transpose
(
0
,
1
).
contiguous
()
hidden_states
=
self
.
embedding_dropout
(
token_embeddings
)
else
:
hidden_states
=
input
hidden_states
=
self
.
transformer
(
hidden_states
,
None
)
if
self
.
single_token_output
:
hidden_states
=
hidden_states
[:,
0
,:]
if
self
.
post_process
:
# [s b h] => [b s h]
if
self
.
single_token_output
:
hidden_states
=
hidden_states
[
0
]
else
:
hidden_states
=
hidden_states
.
transpose
(
0
,
1
).
contiguous
()
return
hidden_states
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