Generic Interface

The pyro.generic module provides an interface to dynamically dispatch Pyro code to custom backends.

class GenericModule(name, default_backend)[source]

Bases: object

Wrapper for a module that can be dynamically routed to a custom backend.

current_backend = {'distributions': 'pyro.distributions', 'infer': 'pyro.infer', 'optim': 'pyro.optim', 'pyro': 'pyro'}
pyro_backend(*aliases, **new_backends)[source]

Context manager to set a custom backend for Pyro models.

Backends can be specified either by name (for standard backends) or by providing a dict mapping module name to backend module name. Standard backends include: pyro, minipyro, funsor, and numpy.