Simplifier class
(Shortest import: from brian2.codegen.optimisation import Simplifier)
- class brian2.codegen.optimisation.Simplifier(variables, scalar_statements, extra_lio_prefix='')[source]
Bases:
BrianASTRenderer
Carry out arithmetic simplifications (see
ArithmeticSimplifier
) and loop invariants- Parameters:
variables : dict of (str, Variable)
Usual definition of variables.
scalar_statements : sequence of Statement
Predefined scalar statements that can be used as part of simplification
Notes
After calling
render_expr
on a sequence of expressions (coming from vector statements typically), this object will have some new attributes:loop_invariants
OrderedDict of (expression, varname)varname will be of the form
_lio_N
whereN
is some integer, and the expressions will be strings that correspond to scalar-only expressions that can be evaluated outside of the vector block.loop_invariant_dtypes
dict of (varname, dtypename)dtypename will be one of
'boolean'
,'integer'
,'float'
.
Methods
render_expr
(expr)render_node
(node)Assumes that the node has already been fully processed by BrianASTRenderer
Details