Deeploy.Targets.PULPOpen.Templates.iSoftmaxTemplate.PULPiSoftmaxTemplate
- class Deeploy.Targets.PULPOpen.Templates.iSoftmaxTemplate.PULPiSoftmaxTemplate(templateStr: str)
Bases:
NodeTemplate
Methods
- __init__(templateStr: str)
Initialize a NodeTemplate object
- Parameters:
templateStr (str) – Mako template string. If tiling is supposed to be supported, this template string may only contain direct expressions that get added by either the operator’s parser or the alignToContext method.
__init__
(templateStr)Initialize a NodeTemplate object
alignToContext
(ctxt, operatorRepresentation)Helper method to extract Mako template expressions used in the backend's code generation step.
computeTransientBuffersSize
(ctxt, ...)Computes the size of transient buffers hoisted by this template given expressions for each variable added by the operator's parser.
generate
([operatorRepresentation])Generated the operator's C implementation
hoistTransientBuffers
(ctxt, ...)Registers the transient buffers required by this template.
Return the byte size of internal memory buffers used by this template
- static computeTransientBuffersSize(ctxt: NetworkContext, operatorRepresentation: Dict[str, str | Any]) List[Tuple[str, int | IntVar]]
Computes the size of transient buffers hoisted by this template given expressions for each variable added by the operator’s parser.
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
operatorRepresentation (OperatorRepresentation) – The parser’s node representation
- Returns:
Returns a list of tuples containing the hoisted buffer’s name and either a symbolic expression or an integer representing its size.
- Return type:
List[Tuple[str, Union[int, IntVar]]]
- hoistTransientBuffers(ctxt: NetworkContext, operatorRepresentation: Dict[str, str | Any]) Tuple[NetworkContext, Dict, List[str]]
Registers the transient buffers required by this template. If tiling is applied, this method is called AFTER tiling.
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
operatorRepresentation (OperatorRepresentation) – The parser’s node representation
- Returns:
Tuple containing the updated NetworkContext object, updated node representation and a list of names of all hoisted TransientBuffers
- Return type:
Tuple[NetworkContext, OperatorRepresentation, List[str]]
- alignToContext(ctxt: NetworkContext, operatorRepresentation: Dict[str, str | Any]) Tuple[NetworkContext, Dict, List[str]]
Helper method to extract Mako template expressions used in the backend’s code generation step. Also hoists transient buffers.
- Parameters:
ctxt (NetworkContext) – Current NetworkContext. Modifying is allowed within this method.
operatorRepresentation (OperatorRepresentation) – Current node representation. Modifying is allowed within this method.
- Returns:
Tuple of the updated NetworkContext, operatorRepresentation and a list of the names of hoisted transient buffers
- Return type:
Tuple[NetworkContext, OperatorRepresentation, List[str]]
- generate(operatorRepresentation={}, **kwargs) str
Generated the operator’s C implementation
- Parameters:
operatorRepresentation (The parser's node representation)
- Returns:
Returns the operator’s C implementation
- Return type:
str
- Raises:
KeyError – Raises an error whenever an expression in the NodeTemplate’s templateString is not matched against the available expressions in the operatorRepresentation
- internalSize() int
Return the byte size of internal memory buffers used by this template
- Returns:
byte size of all transient internal buffers
- Return type:
int