Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TORCH FX] Fix Impure Node Removal #3077

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

anzr299
Copy link
Contributor

@anzr299 anzr299 commented Nov 12, 2024

Changes

ignore placeholder nodes when checking for nodes to eliminate in _merge_node_and_bias function to ensure compatiability with Stable Diffusion models.

Reason for changes

Ignore placeholder nodes to ensure models that are exported with unused inputs are also considered.

@anzr299 anzr299 requested a review from a team as a code owner November 12, 2024 10:47
@@ -1026,7 +1026,7 @@ def _merge_node_and_bias(model: torch.fx.GraphModule, is_target_node: Callable[[
is_impure = lambda node: node in nodes_connected_to_output

for node in reversed(model.graph.nodes):
if not is_impure(node) and len(node.users) == 0:
if not (is_impure(node) or node.op == "placeholder") and len(node.users) == 0:
Copy link
Collaborator

@daniil-lyakhov daniil-lyakhov Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a small test case for the updated code

@anzr299 anzr299 marked this pull request as draft November 12, 2024 13:25
@anzr299 anzr299 closed this Nov 13, 2024
@anzr299 anzr299 deleted the fix_node_removal branch November 13, 2024 07:28
@anzr299 anzr299 restored the fix_node_removal branch November 23, 2024 14:28
@anzr299 anzr299 reopened this Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants