Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple backends #207

Closed
4 of 8 tasks
fritzo opened this issue Aug 31, 2019 · 3 comments
Closed
4 of 8 tasks

Support multiple backends #207

fritzo opened this issue Aug 31, 2019 · 3 comments
Labels

Comments

@fritzo
Copy link
Member

fritzo commented Aug 31, 2019

This issue tracks changes needed to fully support multiple backends in an interchangeable/generic way. The initial release of Funsor implements most funsors using PyTorch (funsor.torch implements Tensor, but all of funsor.gaussian, .joint, .distributions use PyTorch internally.

Approach 1

One possibility is to replicate backend-specific logic in a consistent way, e.g. with module structure

  • funsor
    • torch
      • tensor
      • gaussian
      • cnf
      • distributions
    • numpy / jax
      • tensor
      • gaussian
      • cnf
      • distributions
    • tensorflow
      • ...
    • birch
      • ...

Approach 2

A second possibility (suggested by @eb8680 below and in #159) is to

  1. subclass Tensor into TorchTensor and NumpyTensor, then
  2. refactor Gaussian and Contraction etc. to use Tensors rather than torch.Tensors internally.

This approach would still require duplicating distributions.

Potential backends

Other tasks

  • Remove stray dependencies on PyTorch or NumPy e.g. in funsor.testing and funsor.domains
  • Add backend-specific installation options funsor[torch], funsor[numpy] etc.
@eb8680
Copy link
Member

eb8680 commented Sep 1, 2019

Related suggestion in #159. Agree we should be able to make Number, Tensor, Gaussian, Delta, Distribution interfaces backend-agnostic and have backend independence follow easily from there.

@eb8680
Copy link
Member

eb8680 commented May 17, 2020

I believe the bulk of this work is finished for the PyTorch and JAX backends as of #327, but I'll leave this issue open until #332 is addressed.

@eb8680
Copy link
Member

eb8680 commented Jan 27, 2021

I'm going to close this as resolved. If we want to add more backends in the future or make Gaussian use funsor.Tensor for its parameters, we can track progress in separate issues.

@eb8680 eb8680 closed this as completed Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants