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
ec6cd763
Unverified
Commit
ec6cd763
authored
Jul 19, 2022
by
Joao Gante
Committed by
GitHub
Jul 19, 2022
Browse files
TF: Add missing cast to GPT-J (#18201)
* Fix TF GPT-J tests * add try/finally block
parent
05ed569c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
src/transformers/models/gptj/modeling_tf_gptj.py
src/transformers/models/gptj/modeling_tf_gptj.py
+1
-1
tests/utils/test_modeling_tf_core.py
tests/utils/test_modeling_tf_core.py
+10
-9
No files found.
src/transformers/models/gptj/modeling_tf_gptj.py
View file @
ec6cd763
...
...
@@ -222,7 +222,7 @@ class TFGPTJAttention(tf.keras.layers.Layer):
key
=
self
.
_split_heads
(
key
,
True
)
value
=
self
.
_split_heads
(
value
,
False
)
sincos
=
tf
.
gather
(
self
.
embed_positions
,
position_ids
,
axis
=
0
)
sincos
=
tf
.
cast
(
tf
.
gather
(
self
.
embed_positions
,
position_ids
,
axis
=
0
)
,
hidden_states
.
dtype
)
sincos
=
tf
.
split
(
sincos
,
2
,
axis
=-
1
)
if
self
.
rotary_dim
is
not
None
:
k_rot
=
key
[:,
:,
:,
:
self
.
rotary_dim
]
...
...
tests/utils/test_modeling_tf_core.py
View file @
ec6cd763
...
...
@@ -274,15 +274,16 @@ class TFCoreModelTesterMixin:
def
test_mixed_precision
(
self
):
tf
.
keras
.
mixed_precision
.
set_global_policy
(
"mixed_float16"
)
# try/finally block to ensure subsequent tests run in float32
try
:
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
class_inputs_dict
=
self
.
_prepare_for_class
(
inputs_dict
,
model_class
)
model
=
model_class
(
config
)
outputs
=
model
(
class_inputs_dict
)
self
.
assertIsNotNone
(
outputs
)
finally
:
tf
.
keras
.
mixed_precision
.
set_global_policy
(
"float32"
)
@
slow
...
...
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