Skip to content

Instantly share code, notes, and snippets.

@jamesr66a
Created March 24, 2022 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesr66a/db1401015ad4d05eac17e9dd3f651288 to your computer and use it in GitHub Desktop.
Save jamesr66a/db1401015ad4d05eac17e9dd3f651288 to your computer and use it in GitHub Desktop.
diff --git a/src/transformers/utils/fx.py b/src/transformers/utils/fx.py
index 0270295dd..acf3deaf4 100644
--- a/src/transformers/utils/fx.py
+++ b/src/transformers/utils/fx.py
@@ -485,18 +485,18 @@ class HFTracer(Tracer):
_reset_tensor_methods(self.original_methods)
- # TODO: keep this until necessary.
- # 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 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:
- self.graph.erase_node(node)
+ # # TODO: keep this until necessary.
+ # # 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 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:
+ # self.graph.erase_node(node)
return self.graph
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment