Interpretations

Interpreter

set_interpretation(new)[source]
interpretation(new)[source]
reinterpret(x)[source]

Overloaded reinterpretation of a deferred expression.

This handles a limited class of expressions, raising ValueError in unhandled cases.

Parameters:x (A funsor or data structure holding funsors.) – An input, typically involving deferred Funsor s.
Returns:A reinterpreted version of the input.
Raises:ValueError
dispatched_interpretation(fn)[source]

Decorator to create a dispatched interpretation function.

exception PatternMissingError[source]

Bases: NotImplementedError

Monte Carlo

monte_carlo(cls, *args)[source]

A Monte Carlo interpretation of Integrate expressions. This falls back to eager in other cases.

monte_carlo_interpretation(**sample_inputs)[source]

Context manager to set monte_carlo.sample_inputs and install the monte_carlo() interpretation.

Memoize

memoize(cache=None)[source]

Exploit cons-hashing to do implicit common subexpression elimination