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
0b54046f
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "69ee46243c40ea61f63d4b8f78d171ad27b4a046"
Unverified
Commit
0b54046f
authored
Aug 23, 2021
by
Kamal Raj
Committed by
GitHub
Aug 23, 2021
Browse files
remove unwanted code (#13145)
parent
2e20c0f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
14 deletions
+0
-14
src/transformers/models/deberta_v2/modeling_deberta_v2.py
src/transformers/models/deberta_v2/modeling_deberta_v2.py
+0
-14
No files found.
src/transformers/models/deberta_v2/modeling_deberta_v2.py
View file @
0b54046f
...
...
@@ -753,8 +753,6 @@ class DisentangledSelfAttention(nn.Module):
r_pos
=
relative_pos
p2c_pos
=
torch
.
clamp
(
-
r_pos
+
att_span
,
0
,
att_span
*
2
-
1
)
if
query_layer
.
size
(
-
2
)
!=
key_layer
.
size
(
-
2
):
pos_index
=
relative_pos
[:,
:,
:,
0
].
unsqueeze
(
-
1
)
if
"p2c"
in
self
.
pos_att_type
:
p2c_att
=
torch
.
bmm
(
key_layer
,
pos_query_layer
.
transpose
(
-
1
,
-
2
))
...
...
@@ -763,12 +761,6 @@ class DisentangledSelfAttention(nn.Module):
dim
=-
1
,
index
=
p2c_pos
.
squeeze
(
0
).
expand
([
query_layer
.
size
(
0
),
key_layer
.
size
(
-
2
),
key_layer
.
size
(
-
2
)]),
).
transpose
(
-
1
,
-
2
)
if
query_layer
.
size
(
-
2
)
!=
key_layer
.
size
(
-
2
):
p2c_att
=
torch
.
gather
(
p2c_att
,
dim
=-
2
,
index
=
pos_index
.
expand
(
p2c_att
.
size
()[:
2
]
+
(
pos_index
.
size
(
-
2
),
key_layer
.
size
(
-
2
))),
)
score
+=
p2c_att
/
scale
# position->position
...
...
@@ -776,12 +768,6 @@ class DisentangledSelfAttention(nn.Module):
pos_query
=
pos_query_layer
[:,
:,
att_span
:,
:]
p2p_att
=
torch
.
matmul
(
pos_query
,
pos_key_layer
.
transpose
(
-
1
,
-
2
))
p2p_att
=
p2p_att
.
expand
(
query_layer
.
size
()[:
2
]
+
p2p_att
.
size
()[
2
:])
if
query_layer
.
size
(
-
2
)
!=
key_layer
.
size
(
-
2
):
p2p_att
=
torch
.
gather
(
p2p_att
,
dim
=-
2
,
index
=
pos_index
.
expand
(
query_layer
.
size
()[:
2
]
+
(
pos_index
.
size
(
-
2
),
p2p_att
.
size
(
-
1
))),
)
p2p_att
=
torch
.
gather
(
p2p_att
,
dim
=-
1
,
...
...
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