[Function inlining] Add flag to enable pruning before function calls are inlined. #67707
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[Function inlining] Add flag to enable pruning before function calls are inlined.
Currently, the behavior of lowered functional ("V2") control flow is subtly different from V1 control flow. In V1 control flow, the fetches for a
Session::Run()
call will determine whether or not operations within the loop will be pruned. However, in V2 control flow, pruning may not always occur for multi-device functions, because the graph is partitioned (inserting stateful Send/Recv nodes) into multiple sub-functions, before the individual sub-functions are pruned.While this should not affect the correctness of the execution, it may cause unnecessary computations and data transfers.
To address this problem, we introduce a new flag to enable pruning when inlining function calls, including as part of control flow V2 lowering, which inlines the condition and body functions of while loops, and true and false branches of conditionals.
Set
TF_FLAG_ENABLE_FUNCTION_PRUNING_BEFORE_INLINING=1
to enable this option.