Deeploy.CommonExtensions.CodeTransformationPasses.Closure.ClosureExecutionBlock
- class Deeploy.CommonExtensions.CodeTransformationPasses.Closure.ClosureExecutionBlock(nodeTemplate=None, closureBlock: ExecutionBlock | None = None)
Bases:
ExecutionBlock
Methods
- __init__(nodeTemplate=None, closureBlock: ExecutionBlock | None = None)
Initialize a new ExecutionBlock object from a CodeSnippet
- Parameters:
codeSnippet (Optional[CodeSnippet]) – NodeTemplate + operatorRepresentation combination that makes up this ExecutionBlock
__init__
([nodeTemplate, closureBlock])Initialize a new ExecutionBlock object from a CodeSnippet
addLeft
(template, operatorRepresentation)Adds a code snippet that is generated BEFORE any of the other code snippets in this ExecutionBlock
addRight
(template, operatorRepresentation)Adds a code snippet that is generated AFTER any of the other code snippets in this ExecutionBlock
generate
(ctxt, **kwargs)Generates the code for all registered NodeTemplates and joins it to construct a single snippet
hoisting
(ctxt, **kwargs)Helper function to run the underlying NodeTemplate's hooks to add TransientBuffers into the NetworkContext and call their alignToContext methods
Attributes
baseBlock
ordered list of code snippets that need to be generated to implemented the associated operator
Tiling information of the operator which is annotated in the midend
- addLeft(template: NodeTemplate, operatorRepresentation: Dict[str, str | Any])
Adds a code snippet that is generated BEFORE any of the other code snippets in this ExecutionBlock
- Parameters:
template (NodeTemplate) – NodeTemplate that represents the code snippet to be added
operatorRepresentation (OperatorRepresentation) – Dictionary that holds all expressions to generate code from the template
- addRight(template: NodeTemplate, operatorRepresentation: Dict[str, str | Any])
Adds a code snippet that is generated AFTER any of the other code snippets in this ExecutionBlock
- Parameters:
template (NodeTemplate) – NodeTemplate that represents the code snippet to be added
operatorRepresentation (OperatorRepresentation) – Dictionary that holds all expressions to generate code from the template
- generate(ctxt: NetworkContext, **kwargs) str
Generates the code for all registered NodeTemplates and joins it to construct a single snippet
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
- Returns:
Code snippet that represent the entire ExecutionBlock
- Return type:
str
- hoisting(ctxt: NetworkContext, **kwargs) Tuple[NetworkContext, List[str]]
Helper function to run the underlying NodeTemplate’s hooks to add TransientBuffers into the NetworkContext and call their alignToContext methods
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
- Returns:
Updated NetworkContext and a list of newly registered buffer names
- Return type:
Tuple[NetworkContext, List[str]]
- codeSnippets
ordered list of code snippets that need to be generated to implemented the associated operator
- Type:
Sequence[CodeSnippet]
- patternMemoryConstraint: Optional
Tiling information of the operator which is annotated in the midend
- Type:
Optional[PatternMemoryConstraint]