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
OpenDAS
OpenFold
Commits
f63f2f6e
"...git@developer.sourcefind.cn:OpenDAS/openpcdet.git" did not exist on "72d587d4c603da1d15f4f53d5d861f1a95bc67ad"
Commit
f63f2f6e
authored
Nov 17, 2021
by
Gustaf Ahdritz
Browse files
Move TorchScript utils
parent
d3acabd1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
openfold/model/torchscript.py
openfold/model/torchscript.py
+8
-1
No files found.
openfold/
utils
/torchscript
_utils
.py
→
openfold/
model
/torchscript.py
View file @
f63f2f6e
...
...
@@ -3,6 +3,11 @@ from typing import Optional, Sequence
import
torch
import
torch.nn
as
nn
from
openfold.model.primitives
import
Attention
,
GlobalAttention
def
script_primitives_
(
model
):
script_submodules_
(
model
,
[
Attention
,
GlobalAttention
])
def
script_submodules_
(
model
:
nn
.
Module
,
...
...
@@ -13,12 +18,14 @@ def script_submodules_(
list to recursively scripted equivalents in place. To script the entire
model, just call torch.jit.script on it directly.
When types is None, all submodules are scripted.
Args:
model: A torch.nn.Module
types: A list of types of submodules to script
"""
for
name
,
child
in
model
.
named_children
():
if
(
any
(
isinstance
(
child
,
t
)
for
t
in
types
)):
if
(
types
is
None
or
any
(
isinstance
(
child
,
t
)
for
t
in
types
)):
setattr
(
model
,
name
,
torch
.
jit
.
script
(
child
))
else
:
script_submodules_
(
child
,
types
)
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