Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
27c888db
Commit
27c888db
authored
Oct 26, 2021
by
Lysandre
Browse files
Fix copies
parent
3f23634a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
src/transformers/models/sew_d/modeling_sew_d.py
src/transformers/models/sew_d/modeling_sew_d.py
+15
-0
No files found.
src/transformers/models/sew_d/modeling_sew_d.py
View file @
27c888db
...
@@ -494,6 +494,21 @@ class XSoftmax(torch.autograd.Function):
...
@@ -494,6 +494,21 @@ class XSoftmax(torch.autograd.Function):
inputGrad
=
_softmax_backward_data
(
grad_output
,
output
,
self
.
dim
,
output
)
inputGrad
=
_softmax_backward_data
(
grad_output
,
output
,
self
.
dim
,
output
)
return
inputGrad
,
None
,
None
return
inputGrad
,
None
,
None
@
staticmethod
def
symbolic
(
g
,
self
,
mask
,
dim
):
import
torch.onnx.symbolic_helper
as
sym_help
from
torch.onnx.symbolic_opset9
import
masked_fill
,
softmax
mask_cast_value
=
g
.
op
(
"Cast"
,
mask
,
to_i
=
sym_help
.
cast_pytorch_to_onnx
[
"Long"
])
r_mask
=
g
.
op
(
"Cast"
,
g
.
op
(
"Sub"
,
g
.
op
(
"Constant"
,
value_t
=
torch
.
tensor
(
1
,
dtype
=
torch
.
int64
)),
mask_cast_value
),
to_i
=
sym_help
.
cast_pytorch_to_onnx
[
"Byte"
],
)
output
=
masked_fill
(
g
,
self
,
r_mask
,
g
.
op
(
"Constant"
,
value_t
=
torch
.
tensor
(
float
(
"-inf"
))))
output
=
softmax
(
g
,
output
,
dim
)
return
masked_fill
(
g
,
output
,
r_mask
,
g
.
op
(
"Constant"
,
value_t
=
torch
.
tensor
(
0
,
dtype
=
torch
.
uint8
)))
# Copied from transformers.models.deberta.modeling_deberta.DropoutContext
# Copied from transformers.models.deberta.modeling_deberta.DropoutContext
class
DropoutContext
(
object
):
class
DropoutContext
(
object
):
...
...
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