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
"lib/bindings/git@developer.sourcefind.cn:OpenDAS/dynamo.git" did not exist on "c70de37fcb50559ecd051df140db38250077c245"
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
...
@@ -3,6 +3,11 @@ from typing import Optional, Sequence
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
from
openfold.model.primitives
import
Attention
,
GlobalAttention
def
script_primitives_
(
model
):
script_submodules_
(
model
,
[
Attention
,
GlobalAttention
])
def
script_submodules_
(
def
script_submodules_
(
model
:
nn
.
Module
,
model
:
nn
.
Module
,
...
@@ -13,12 +18,14 @@ def script_submodules_(
...
@@ -13,12 +18,14 @@ def script_submodules_(
list to recursively scripted equivalents in place. To script the entire
list to recursively scripted equivalents in place. To script the entire
model, just call torch.jit.script on it directly.
model, just call torch.jit.script on it directly.
When types is None, all submodules are scripted.
Args:
Args:
model: A torch.nn.Module
model: A torch.nn.Module
types: A list of types of submodules to script
types: A list of types of submodules to script
"""
"""
for
name
,
child
in
model
.
named_children
():
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
))
setattr
(
model
,
name
,
torch
.
jit
.
script
(
child
))
else
:
else
:
script_submodules_
(
child
,
types
)
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