Deeploy.Targets.Generic.Templates.ClosureTemplate.ClosureTemplate
- class Deeploy.Targets.Generic.Templates.ClosureTemplate.ClosureTemplate(templateStr)
Bases:
NodeTemplate
,Dict
[str
,str
|Any
]Methods
- __init__(templateStr)
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.
clear
()computeTransientBuffersSize
(ctxt, ...)Computes the size of transient buffers hoisted by this template given expressions for each variable added by the operator's parser.
copy
()fromkeys
([value])Create a new dictionary with keys from iterable and values set to value.
generate
([operatorRepresentation])Generated the operator's C implementation
get
(key[, default])Return the value for key if key is in the dictionary, else default.
hoistTransientBuffers
(ctxt, ...)Registers the transient buffers required by this template.
Return the byte size of internal memory buffers used by this template
items
()keys
()pop
(k[,d])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem
()Remove and return a (key, value) pair as a 2-tuple.
setdefault
(key[, default])Insert key with a value of default if key is not in the dictionary.
update
([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values
()- alignToContext(ctxt: NetworkContext, operatorRepresentation: Dict[str, str | Any]) Tuple[NetworkContext, Dict[str, str | Any], 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]]
- clear() None. Remove all items from D.
- 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]]]
- copy() a shallow copy of D
- fromkeys(value=None, /)
Create a new dictionary with keys from iterable and values set to value.
- 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
- get(key, default=None, /)
Return the value for key if key is in the dictionary, else default.
- hoistTransientBuffers(ctxt: NetworkContext, operatorRepresentation: Dict[str, str | Any]) Tuple[NetworkContext, Dict[str, str | Any], 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]]
- 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
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- pop(k[, d]) v, remove specified key and return the corresponding value.
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values