Skip to content

Commit 200d3d0

Browse files
mlazospytorchmergebot
authored andcommitted
Remove static param counting if inlining NN modules (#130503)
Pull Request resolved: #130503 Approved by: https://github.com/bdhirsh ghstack dependencies: #130391, #130392
1 parent 0d0c097 commit 200d3d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

torch/_inductor/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,15 @@ def num_fw_fixed_arguments(dynamo_gm_num_inputs: int, aot_fw_gm_num_inputs: int)
15371537
num_rng_seed_offset_inputs = (
15381538
2 if torch._functorch.config.functionalize_rng_ops else 0
15391539
)
1540+
# AOT won't lift any parameters if we're inlining NN Modules
1541+
# however desugaring subclasses will still add arguments
1542+
# resulted in extra fixed inputs https://github.com/pytorch/pytorch/issues/130502
1543+
if (
1544+
torch._dynamo.config.inline_inbuilt_nn_modules
1545+
and not torch._dynamo.utils.is_parameter_freezing()
1546+
):
1547+
return 0
1548+
15401549
return aot_fw_gm_num_inputs - dynamo_gm_num_inputs - num_rng_seed_offset_inputs
15411550

15421551

0 commit comments

Comments
 (0)