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_invariantsOrderedDict of (expression, varname)

varname will be of the form _lio_N where N 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_dtypesdict 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

render_expr(expr)[source]
render_node(node)[source]

Assumes that the node has already been fully processed by BrianASTRenderer