tff.framework.transform_preorder
Stay organized with collections
Save and categorize content based on your preferences.
Walks the AST of comp
preorder, calling transform
on the way down.
tff.framework.transform_preorder(
comp: tff.framework.ComputationBuildingBlock
,
transform: Callable[[building_blocks.ComputationBuildingBlock], TransformReturnType]
) -> tff.framework.ComputationBuildingBlock
Notice that this function will stop walking the tree when its transform
function modifies a node; this is to prevent the caller from unexpectedly
kicking off an infinite recursion. For this purpose the transform function
must identify when it has transformed the structure of a building block; if
the structure of the building block is modified but False
is returned as
the second element of the tuple returned by transform
, transform_preorder
may result in an infinite recursion.
Args |
comp
|
Instance of building_blocks.ComputationBuildingBlock to be
transformed in a preorder fashion.
|
transform
|
Transform function to be applied to the nodes of comp . Must
return a two-tuple whose first element is a
building_blocks.ComputationBuildingBlock and whose second element is a
Boolean. If the computation which is passed to comp is returned in a
modified state, must return True for the second element. This Boolean
controls whether or not to stop traversing the tree under comp ; if this
Bool is True , transform_preorder will not traverse this subtree.
|
Returns |
A two-tuple, whose first element is modified version of comp , and
whose second element is a Boolean indicating whether comp was transformed
during the walk.
|
Raises |
TypeError
|
If the argument types don't match those specified above.
|
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 2024-09-20 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 2024-09-20 UTC."],[],[]]