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
4818bf7a
Unverified
Commit
4818bf7a
authored
Feb 25, 2022
by
Pavel Belevich
Committed by
GitHub
Feb 25, 2022
Browse files
HFTracer.trace should use/return self.graph to be compatible with torch.fx.Tracer (#15824)
parent
ad0d7d17
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
src/transformers/utils/fx.py
src/transformers/utils/fx.py
+4
-4
No files found.
src/transformers/utils/fx.py
View file @
4818bf7a
...
...
@@ -472,7 +472,7 @@ class HFTracer(Tracer):
self
.
_patch_leaf_functions_for_root
(
root
)
graph
=
super
().
trace
(
root
,
concrete_args
=
concrete_args
)
self
.
graph
=
super
().
trace
(
root
,
concrete_args
=
concrete_args
)
self
.
_patch_leaf_functions_for_root
(
root
,
restore
=
True
)
...
...
@@ -482,16 +482,16 @@ class HFTracer(Tracer):
# This is necessary because concrete args are added as input to the traced module since
# https://github.com/pytorch/pytorch/pull/55888.
# A PR that solves this was posted: https://github.com/pytorch/pytorch/pull/59569 but it was not merged yet.
for
node
in
graph
.
nodes
:
for
node
in
self
.
graph
.
nodes
:
if
node
.
op
==
"placeholder"
:
# Removing default values for inputs as the forward pass will fail with them.
if
node
.
target
in
input_names
:
node
.
args
=
()
# It is a concrete arg so it is not used and should be removed.
else
:
graph
.
erase_node
(
node
)
self
.
graph
.
erase_node
(
node
)
return
graph
return
self
.
graph
def
_insert_module_as_submodule
(
self
,
mod
:
nn
.
Module
)
->
str
:
"""
...
...
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