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
5f5e264a
Unverified
Commit
5f5e264a
authored
Oct 11, 2022
by
Partho
Committed by
GitHub
Oct 10, 2022
Browse files
wrap forward passes with torch.no_grad() (#19413)
parent
c6a928ca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
tests/models/fnet/test_modeling_fnet.py
tests/models/fnet/test_modeling_fnet.py
+6
-3
No files found.
tests/models/fnet/test_modeling_fnet.py
View file @
5f5e264a
...
@@ -493,6 +493,7 @@ class FNetModelIntegrationTest(unittest.TestCase):
...
@@ -493,6 +493,7 @@ class FNetModelIntegrationTest(unittest.TestCase):
model
.
to
(
torch_device
)
model
.
to
(
torch_device
)
input_ids
=
torch
.
tensor
([[
0
,
1
,
2
,
3
,
4
,
5
]],
device
=
torch_device
)
input_ids
=
torch
.
tensor
([[
0
,
1
,
2
,
3
,
4
,
5
]],
device
=
torch_device
)
with
torch
.
no_grad
():
output
=
model
(
input_ids
)[
0
]
output
=
model
(
input_ids
)[
0
]
vocab_size
=
32000
vocab_size
=
32000
...
@@ -536,6 +537,7 @@ class FNetModelIntegrationTest(unittest.TestCase):
...
@@ -536,6 +537,7 @@ class FNetModelIntegrationTest(unittest.TestCase):
model
.
to
(
torch_device
)
model
.
to
(
torch_device
)
input_ids
=
torch
.
tensor
([[
0
,
1
,
2
,
3
,
4
,
5
]],
device
=
torch_device
)
input_ids
=
torch
.
tensor
([[
0
,
1
,
2
,
3
,
4
,
5
]],
device
=
torch_device
)
with
torch
.
no_grad
():
output
=
model
(
input_ids
)[
0
]
output
=
model
(
input_ids
)[
0
]
expected_shape
=
torch
.
Size
((
1
,
2
))
expected_shape
=
torch
.
Size
((
1
,
2
))
...
@@ -551,6 +553,7 @@ class FNetModelIntegrationTest(unittest.TestCase):
...
@@ -551,6 +553,7 @@ class FNetModelIntegrationTest(unittest.TestCase):
model
.
to
(
torch_device
)
model
.
to
(
torch_device
)
input_ids
=
torch
.
tensor
([[
0
,
1
,
2
,
3
,
4
,
5
]],
device
=
torch_device
)
input_ids
=
torch
.
tensor
([[
0
,
1
,
2
,
3
,
4
,
5
]],
device
=
torch_device
)
with
torch
.
no_grad
():
output
=
model
(
input_ids
)[
0
]
output
=
model
(
input_ids
)[
0
]
expected_shape
=
torch
.
Size
((
1
,
6
,
model
.
config
.
hidden_size
))
expected_shape
=
torch
.
Size
((
1
,
6
,
model
.
config
.
hidden_size
))
...
...
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