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
10bcbcae
"...resnet50_tensorflow.git" did not exist on "8b6c2c462b6614063f8535451a1aa86449717ed6"
Unverified
Commit
10bcbcae
authored
Mar 07, 2023
by
regisss
Committed by
GitHub
Mar 07, 2023
Browse files
Remove unneeded casts to bool (#21983)
Remove cast to Bool
parent
95408e99
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
3 deletions
+3
-3
src/transformers/models/decision_transformer/modeling_decision_transformer.py
...els/decision_transformer/modeling_decision_transformer.py
+1
-1
src/transformers/models/gpt2/modeling_gpt2.py
src/transformers/models/gpt2/modeling_gpt2.py
+1
-1
src/transformers/models/imagegpt/modeling_imagegpt.py
src/transformers/models/imagegpt/modeling_imagegpt.py
+1
-1
No files found.
src/transformers/models/decision_transformer/modeling_decision_transformer.py
View file @
10bcbcae
...
@@ -231,7 +231,7 @@ class DecisionTransformerGPT2Attention(nn.Module):
...
@@ -231,7 +231,7 @@ class DecisionTransformerGPT2Attention(nn.Module):
if
not
self
.
is_cross_attention
:
if
not
self
.
is_cross_attention
:
# if only "normal" attention layer implements causal mask
# if only "normal" attention layer implements causal mask
query_length
,
key_length
=
query
.
size
(
-
2
),
key
.
size
(
-
2
)
query_length
,
key_length
=
query
.
size
(
-
2
),
key
.
size
(
-
2
)
causal_mask
=
self
.
bias
[:,
:,
key_length
-
query_length
:
key_length
,
:
key_length
]
.
bool
()
causal_mask
=
self
.
bias
[:,
:,
key_length
-
query_length
:
key_length
,
:
key_length
]
mask_value
=
torch
.
finfo
(
attn_weights
.
dtype
).
min
mask_value
=
torch
.
finfo
(
attn_weights
.
dtype
).
min
# Need to be a tensor, otherwise we get error: `RuntimeError: expected scalar type float but found double`.
# Need to be a tensor, otherwise we get error: `RuntimeError: expected scalar type float but found double`.
# Need to be on the same device, otherwise `RuntimeError: ..., x and y to be on the same device`
# Need to be on the same device, otherwise `RuntimeError: ..., x and y to be on the same device`
...
...
src/transformers/models/gpt2/modeling_gpt2.py
View file @
10bcbcae
...
@@ -243,7 +243,7 @@ class GPT2Attention(nn.Module):
...
@@ -243,7 +243,7 @@ class GPT2Attention(nn.Module):
if
not
self
.
is_cross_attention
:
if
not
self
.
is_cross_attention
:
# if only "normal" attention layer implements causal mask
# if only "normal" attention layer implements causal mask
query_length
,
key_length
=
query
.
size
(
-
2
),
key
.
size
(
-
2
)
query_length
,
key_length
=
query
.
size
(
-
2
),
key
.
size
(
-
2
)
causal_mask
=
self
.
bias
[:,
:,
key_length
-
query_length
:
key_length
,
:
key_length
]
.
bool
()
causal_mask
=
self
.
bias
[:,
:,
key_length
-
query_length
:
key_length
,
:
key_length
]
mask_value
=
torch
.
finfo
(
attn_weights
.
dtype
).
min
mask_value
=
torch
.
finfo
(
attn_weights
.
dtype
).
min
# Need to be a tensor, otherwise we get error: `RuntimeError: expected scalar type float but found double`.
# Need to be a tensor, otherwise we get error: `RuntimeError: expected scalar type float but found double`.
# Need to be on the same device, otherwise `RuntimeError: ..., x and y to be on the same device`
# Need to be on the same device, otherwise `RuntimeError: ..., x and y to be on the same device`
...
...
src/transformers/models/imagegpt/modeling_imagegpt.py
View file @
10bcbcae
...
@@ -294,7 +294,7 @@ class ImageGPTAttention(nn.Module):
...
@@ -294,7 +294,7 @@ class ImageGPTAttention(nn.Module):
if
not
self
.
is_cross_attention
:
if
not
self
.
is_cross_attention
:
# if only "normal" attention layer implements causal mask
# if only "normal" attention layer implements causal mask
query_length
,
key_length
=
query
.
size
(
-
2
),
key
.
size
(
-
2
)
query_length
,
key_length
=
query
.
size
(
-
2
),
key
.
size
(
-
2
)
causal_mask
=
self
.
bias
[:,
:,
key_length
-
query_length
:
key_length
,
:
key_length
]
.
bool
()
causal_mask
=
self
.
bias
[:,
:,
key_length
-
query_length
:
key_length
,
:
key_length
]
mask_value
=
torch
.
finfo
(
attn_weights
.
dtype
).
min
mask_value
=
torch
.
finfo
(
attn_weights
.
dtype
).
min
# Need to be a tensor, otherwise we get error: `RuntimeError: expected scalar type float but found double`.
# Need to be a tensor, otherwise we get error: `RuntimeError: expected scalar type float but found double`.
# Need to be on the same device, otherwise `RuntimeError: ..., x and y to be on the same device`
# Need to be on the same device, otherwise `RuntimeError: ..., x and y to be on the same 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