gEconpy.model.compile.sympy_to_pytensor#

gEconpy.model.compile.sympy_to_pytensor(inputs, outputs, cache=None, cse=False)#

Convert sympy expressions to pytensor graph nodes.

This is the sympytensor bridge: it takes sympy symbols and expressions and returns the corresponding pytensor input and output nodes, along with the updated cache that maintains the mapping between sympy and pytensor symbols.

Parameters:
inputslist of sympy Symbol

Sympy input symbols.

outputslist of sympy expression, or sympy MutableDenseMatrix

Sympy output expressions.

cachedict, optional

Dictionary mapping sympytensor cache keys to pytensor variables. Used to maintain a consistent namespace across multiple conversions. Default is an empty dictionary.

csebool, optional

Eliminate common subexpressions (sp.cse) before conversion. Shrinks the forward graph but inflates gradient compilation, because the shared subexpressions become high-fanout nodes that densify the reverse-mode backward graph; enable only for forward-only compiles. Default False.

Returns:
input_nodeslist of TensorVariable

Pytensor input nodes corresponding to the sympy inputs.

output_nodeslist of TensorVariable

Pytensor output nodes corresponding to the sympy outputs.

cachedict

Updated cache dictionary.