llmcompressor.pipelines.sequential.ast_utils.control_flow_analyzer
Classes:
-
ControlFlowAnalyzer–Used to determine if a piece of code can be wrapped into a function. Includes any
ControlFlowAnalyzer
Bases: NodeVisitor
Used to determine if a piece of code can be wrapped into a function. Includes any code which includes return, continue, break, await, or yield without the proper context.
For example, this code can be wrapped:
Whereas the inner code cannot be wrapped without the while context
def wrapped():
if some_condition:
break # this control statement is now invalid
while True:
wrapped()
Methods:
-
is_valid–Returns False if a node contains control statements that are not in their
is_valid
Returns False if a node contains control statements that are not in their proper control flow context
Parameters:
-
(nodeAST) –code to analyze
Returns:
-
bool–True iff the code does not contain invalid control statements