tfp.experimental.auto_batching.stack_optimization.fuse_pop_push
Stay organized with collections
Save and categorize content based on your preferences.
Fuses pop+push sequences in the given Program
.
tfp.experimental.auto_batching.stack_optimization.fuse_pop_push(
program
)
A stack pop followed by a stack push (with no intervening read) is equivalent
to just updating the top of the stack. The latter is more efficient for FULL
variables, because it just updates the cache for the top, and avoids gathering
from and scattering to the backing stack Tensor.
This pass mutates the ControlFlowGraph
of the input Program
to convert
pop+push sequences into updates. The pass will work despite intervening
instructions that interact with other Variables, but will not cross basic
block boundaries. As a side-effect, the pass moves non-optimized pops to the
last place in their basic block where they are still sound. This has no
effect on the runtime behavior of the program.
Args |
program
|
A lowered Program whose pop+push sequences to fuse. Block s in
the program may be mutated.
|
Returns |
fused
|
A Program with statically redundant pop+push sequences eliminated
in favor of PrimOp s with non-trivial skip_push_mask fields.
|
Raises |
ValueError
|
If the input Program has not been lowered (i.e., contains
FunctionCallOp ), or is ill-formed (e.g., contains invalid instructions).
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-11-21 UTC."],[],[]]