Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 3a80b29
Author: eb8680 <[email protected]>
Date:   Thu Jun 27 14:17:26 2019 -0700

    Make substitution an interpretation (#155)

    * make substitute into an interpretation

    * simplify interpretation and add numpy+tco test to Makefile

    * tweak Independent

    * remove substitute_funsor

    * uncomment long examples

    * conditionally xfail some numpy tests

    * update semantics of Independent to be compatible with substitution changes

    * add Module to ground types

commit ce5cdeb
Author: eb8680 <[email protected]>
Date:   Wed Jun 26 10:18:32 2019 -0700

    Remove eager_subs method from Joint (#154)

commit ba0dfcb
Author: eb8680 <[email protected]>
Date:   Tue Jun 25 15:04:38 2019 -0700

    Separate generic and fresh variables in substitute (#153)

commit 14766ef
Author: eb8680 <[email protected]>
Date:   Tue Jun 25 14:52:19 2019 -0700

    Remove most eager_subs methods from terms with no fresh variables (#152)

commit 7e456e6
Author: eb8680 <[email protected]>
Date:   Tue Jun 25 13:34:58 2019 -0700

    Alpha renaming of bound variables (#148)

commit 3edfb0f
Author: Fritz Obermeyer <[email protected]>
Date:   Wed Jun 5 09:58:30 2019 -0700

    Use classifiers to specify the license (#150)

commit d1cd1d2
Author: eb8680 <[email protected]>
Date:   Fri May 24 11:10:14 2019 -0700

    Add an explicit stack-based interpreter (#147)

commit ac02dcc
Author: Fritz Obermeyer <[email protected]>
Date:   Mon May 6 11:02:20 2019 -0700

    Update badge to point to travis-ci.com (#143)

commit 416cff6
Author: Fritz Obermeyer <[email protected]>
Date:   Thu May 2 14:45:10 2019 -0700

    Promote Einsum to a funsor for pattern matching (#142)

commit 30e4255
Author: Fritz Obermeyer <[email protected]>
Date:   Thu May 2 10:46:24 2019 -0700

    Update CI to use PyTorch 1.1.0 (#141)

    * Update CI to use PyTorch 1.1.0

    * Fix travis version

    * Accommodate change to torch.max return type

commit 00c467d
Author: eb8680 <[email protected]>
Date:   Wed May 1 22:57:54 2019 -0700

    Add model and guide auxiliary variable elimination to minipyro.elbo (#126)

    * add auxiliary variable elimination to minipyro.elbo to mimic TraceEnum_ELBO

    * optional partial_sum_product

    * Common subexpression elimination

    * add a test for traceenum_elbo

    * add two more tests, one of which is xfailing...

    * Simplify test and minipyro (#140)

    * Add smoke test for gaussian-probit model

    * Remove bogus assertion

    * Fix TraceEnum_ELBO to use EnumerateMessenger

    * remove EnumerateMessenger

    * add optional optimization to traceenum_elbo and mark monte carlo test xfail

commit c77dc99
Author: JP <[email protected]>
Date:   Wed May 1 21:26:07 2019 -0700

    rtd fix to not install torch 1.0 (#139)

commit 2e5fd40
Author: JP <[email protected]>
Date:   Wed May 1 14:10:27 2019 -0700

    deploy documentation (#138)

commit cb09325
Author: Fritz Obermeyer <[email protected]>
Date:   Wed May 1 12:19:14 2019 -0700

    Add generic Bernoulli wrapper around probs,logits version (#137)

commit 45e0434
Author: Fritz Obermeyer <[email protected]>
Date:   Wed May 1 12:11:03 2019 -0700

    Refactor elbos (#136)

    * Refactor elbos

    * Fix jit classes

commit 1f5f602
Author: Fritz Obermeyer <[email protected]>
Date:   Tue Apr 30 23:57:13 2019 -0700

    Add BernoulliLogits distribution (#135)

commit df25607
Author: Fritz Obermeyer <[email protected]>
Date:   Tue Apr 30 15:51:38 2019 -0700

    Avoid legacy constructors (#134)

commit 92e85c3
Author: Fritz Obermeyer <[email protected]>
Date:   Mon Apr 29 11:14:31 2019 -0700

    Add JitTrace_ELBO class to minipyro (#133)

    * Add JitTrace_ELBO class to minipyro

    * Enable minipyro --jit test

    * Simplify JitTrace_ELBO

    * Make Gaussian math jit compatible

    * Add unit tests for BlockVector and BlockMatrix

    * Fix docs

    * Tweak docs

commit 5053f55
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Apr 12 14:09:23 2019 -0400

    Remove dependency on pyro ParamStoreDict (#129)

commit 79a8621
Author: Fritz Obermeyer <[email protected]>
Date:   Thu Apr 11 21:15:00 2019 -0700

    Support constraints in funsor.minipyro (#128)

    * Support constraints in funsor.minipyro

    * Make minipyro tests a little stronger

    * Save metadata to value.unconstrained()

commit a7f3b8a
Author: Fritz Obermeyer <[email protected]>
Date:   Tue Apr 9 21:29:29 2019 -0700

    Reinstate examples/minipyro.py, forked from pyro/examples (#125)

    * Reinstate examples/minipyro.py, forked from pyro/examples

    * Add a rule for eager evaluation of (p.exp() * f).reduce(ops.add) and a failing test showing numerical instability

    * compute most of expectation in log-space in minipyro

    * handle plates?

    * add

commit 48fa3f7
Author: Neeraj Pradhan <[email protected]>
Date:   Mon Apr 8 11:17:29 2019 -0700

    Add Beta, Dirichlet, and Binomial distributions (#120)

commit f74df0a
Author: eb8680 <[email protected]>
Date:   Sat Apr 6 19:28:39 2019 -0700

    Add rule for creating Gaussians from Affine inputs (#119)

commit 8fa1c32
Author: eb8680 <[email protected]>
Date:   Sat Apr 6 15:21:33 2019 -0700

    Add an Affine term to represent multilinear functions of real Variables (#116)

commit 627711e
Author: Fritz Obermeyer <[email protected]>
Date:   Sat Apr 6 10:09:42 2019 -0700

    Support wrapping PyTorch builtin functions (#118)

commit 216626c
Author: Fritz Obermeyer <[email protected]>
Date:   Sat Apr 6 09:06:51 2019 -0700

    Add a torch_tensordot operation (#117)

    * Add a torch_tensordot op

    * Fix docstrings to avoid sphinx warning

commit fcb4670
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Apr 5 10:30:03 2019 -0700

    Add moment_matching interpretation + SLDS example (#115)

    * Sketch imm example (no inference yet)

    * Sketch Gaussian.moment_matching_reduce

    * Use moment-matching interpretation in IMM example

    * Rename example to slds.py

    * Make SLDS params more interesting

    * Relax assumptions regarding reduced_vars

commit fd0dfe4
Author: Fritz Obermeyer <[email protected]>
Date:   Tue Apr 2 15:04:43 2019 -0700

    Add initial sphinx docs (#114)

commit 51b5489
Author: Fritz Obermeyer <[email protected]>
Date:   Sun Mar 31 23:14:38 2019 -0700

    Add a VAE example using the monte_carlo interpretation (#95)

    * Sketch Monte Carlo interpretation of logaddexp reduction

    * Use AssociativeOp in patterns

    * Fix op pattern matcher

    * Try eager before monte_carlo

    * Drop ops.sample, ops.marginal

    * Sketch VAE example using monte carlo interpretation

    * Refactor, focusing on .sample() and .monte_carlo_logsumexp() methods

    * Fix vae example

    * Sketch Tensor.sample() (untested)

    * Fix cyclic import

    * Sketch Gaussian.sample() (untested)

    * Implement Delta.sample()

    * Sketch Expectation class

    * Sketch sampler implementations

    * Delete Expectation in favor of Integrate in a separate PR

    * Revert .sample() sketch

    * Update VAE example to use multi-output Functions

    * Fix reductions in VAE

    * Sketch support for multiple args in __getitem__

    * Fix bugs in getitem_tensor_tensor

    * Add stronger tests for tensor getitem

    * Add support for string indexing

    * Simplify vae example using multi-getitem

    * Add stub for Integrate

    * Fix typo

    * Sketch monte_carlo registration of Gaussian-Gaussian things

    * Add stubs for Joint integration

    * Fix typos

    * Sketch support for multiple samples

    * Fix test usage of registry

    * Fix bugs in gaussian integral

    * Handle scale factors in Funsor.sample()

    * Use Integrate in test_samplers.py

    * Fix bug in Integrate; be less clever

    * Add implementations of gaussian-linear integrals

    * Add interpretation logging controlled by FUNSOR_DEBUG

    * Simplify debug printing

    * Fix lazy reduction for Joint.reduce()

    * Fix recursion bug

    * Get univariate Gaussian sampling to mostly work

    * Fix bug in Tensor.eager_reduce with nontrivial output

    * Fix output shape broadcasting in Tensor

    * Fix assert_close in test_samplers.py

    * Fix cholesky bugs

    * Fix bug in _trace_mm()

    * Fixes for examples/vae.py

    * Remove examples/vae.py

    * Revert "Remove examples/vae.py"

    This reverts commit bee75b9.

    * Use funsor.Lambda in VAE example

    * Add a Lambda funsor, inverse to getitem

    * Use lazy substitution rather than Lambda

    * Add --pdb argument to examples/vae.py

    * Add function logging and filename logging when FUNSOR_DEBUG=1

    * Enable more functions to be logged

    * Little fixes

    * Fixes to support vae example

    * Fix comment

    * Revert product sample rules

    * WIP sketch plates

    * Simplify vae example (still not working)

    * Sketch Uncurry funsor

    * Sketch Uncurry-Delta-Lambda pattern

    * Sketch Joint-Uncurry-Delta rule

    * Sketch uncurry-distribution test

    * Change to_funsor second arg from dtype to Domain

    * Add Funsor.__contains__

    * Use Uncurry in VAE example

    * Fix test_normal_uncurry

    * Rename Uncurry to Independent

    * Revert irrelevant changes

    * Support sampling from mixtures

    * Update VAE example to use Independent

    * Get VAE example to start working

    * Flake8

    * Revert nan validation

    * Add torchvision to setup.py

commit 306aca6
Author: Fritz Obermeyer <[email protected]>
Date:   Sun Mar 31 22:51:42 2019 -0700

    Add Lambda and Independent funsors (#97)

    * Add a Lambda funsor, inverse to getitem

    * Sketch Uncurry funsor

    * Sketch Uncurry-Delta-Lambda pattern

    * Sketch Joint-Uncurry-Delta rule

    * Sketch uncurry-distribution test

    * Change to_funsor second arg from dtype to Domain

    * Add Funsor.__contains__

    * Fix test_normal_uncurry

    * Rename Uncurry to Independent

commit 89313ef
Author: Fritz Obermeyer <[email protected]>
Date:   Sun Mar 31 13:40:43 2019 -0700

    Refactor .unscaled_sample() interface (#113)

commit 366e9e3
Author: Fritz Obermeyer <[email protected]>
Date:   Sun Mar 31 13:39:35 2019 -0700

    Change to_funsor second arg from dtype to Domain (#112)

commit bddcc2c
Author: Fritz Obermeyer <[email protected]>
Date:   Sat Mar 30 18:15:54 2019 -0700

    Support event_dim kwarg in pyro.param (#111)

    * Support event_dim kwarg in pyro.param

    * Use local-param branch of Pyro

    * Use pyro dev for CI

commit 36e57ae
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 29 13:00:36 2019 -0700

    Add a working minipyro with tests (#100)

    * Add pristine copy of pyro/contrib/minipyro.py

    * First pass at fixing minipyro

    * First pass at transformed distributions

    * Add test for sampling transformed Gaussian

    * Add test for renaming a Gaussian variable

    * Add dist.LogNormal distribution and density test

    * Add xfailing test for LogNormal sampler

    * Attempt to fix minipyro.elbo

    * Implement negation and subtraction ops for R-N derivatives

    * Fix bug in log_joint.process of sample

    * Implement reduction along a plate dimension

    * Implement correct but non-monte-carlo elbo

    * Fix bugs in Gaussian

    * Implement plate reductions for Gaussian, Joint

    * Use Expectation(...) in elbo computation

    * Fix typos in elbo

    * Add tests for plate reduction

    * Use Expectation interface by default

    * Add initial test_minipyro.py

    * Add more minipyro tests

    * Add shape assertions to gaussian math

    * Refactor minipyro

    * Add an observation to plate test

    * Add more plates tests

    * Support sampling in funsor.minipyro

commit b9cdbac
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 29 11:02:00 2019 -0700

    Implement plate reductions for Gaussian, Joint (#108)

commit 37ce962
Author: Fritz Obermeyer <[email protected]>
Date:   Thu Mar 28 14:43:45 2019 -0700

    Make distributions lazy when used Pyro-style (#107)

commit 16a2fbb
Author: eb8680 <[email protected]>
Date:   Wed Mar 27 18:04:50 2019 -0700

    Add Contract to optimizer (#105)

commit c339f1a
Author: Fritz Obermeyer <[email protected]>
Date:   Wed Mar 27 17:57:22 2019 -0700

    Implement negation and subtraction ops for R-N derivatives (#104)

commit 830e430
Author: Fritz Obermeyer <[email protected]>
Date:   Wed Mar 27 14:58:14 2019 -0700

    Implement basic transformed distributions (#103)

    * First pass at transformed distributions

    * Add test for sampling transformed Gaussian

    * Add test for renaming a Gaussian variable

    * Add dist.LogNormal distribution and density test

    * Add xfailing test for LogNormal sampler

commit a54defa
Author: eb8680 <[email protected]>
Date:   Wed Mar 27 14:02:34 2019 -0700

    Support for pattern matching with the unification library (#78)

commit 364745e
Author: Fritz Obermeyer <[email protected]>
Date:   Tue Mar 26 19:08:23 2019 -0700

    Remove modified version of minipyro (#102)

commit ea7feb2
Author: Fritz Obermeyer <[email protected]>
Date:   Tue Mar 26 13:29:12 2019 -0700

    Log function and filename when FUNSOR_DEBUG=1 (#101)

    * Add function logging and filename logging when FUNSOR_DEBUG=1

    * Enable more functions to be logged

commit 951630c
Author: Fritz Obermeyer <[email protected]>
Date:   Tue Mar 26 00:14:21 2019 -0700

    Resurrect lazy Subs funsor (again) (#99)

    * Sketch Monte Carlo interpretation of logaddexp reduction

    * Use AssociativeOp in patterns

    * Fix op pattern matcher

    * Try eager before monte_carlo

    * Drop ops.sample, ops.marginal

    * Sketch VAE example using monte carlo interpretation

    * Refactor, focusing on .sample() and .monte_carlo_logsumexp() methods

    * Fix vae example

    * Sketch Tensor.sample() (untested)

    * Fix cyclic import

    * Sketch Gaussian.sample() (untested)

    * Implement Delta.sample()

    * Sketch Expectation class

    * Sketch sampler implementations

    * Delete Expectation in favor of Integrate in a separate PR

    * Revert .sample() sketch

    * Update VAE example to use multi-output Functions

    * Fix reductions in VAE

    * Sketch support for multiple args in __getitem__

    * Fix bugs in getitem_tensor_tensor

    * Add stronger tests for tensor getitem

    * Add support for string indexing

    * Simplify vae example using multi-getitem

    * Add stub for Integrate

    * Fix typo

    * Sketch monte_carlo registration of Gaussian-Gaussian things

    * Add stubs for Joint integration

    * Fix typos

    * Sketch support for multiple samples

    * Fix test usage of registry

    * Fix bugs in gaussian integral

    * Handle scale factors in Funsor.sample()

    * Use Integrate in test_samplers.py

    * Fix bug in Integrate; be less clever

    * Add implementations of gaussian-linear integrals

    * Add interpretation logging controlled by FUNSOR_DEBUG

    * Simplify debug printing

    * Fix lazy reduction for Joint.reduce()

    * Fix recursion bug

    * Get univariate Gaussian sampling to mostly work

    * Fix bug in Tensor.eager_reduce with nontrivial output

    * Fix output shape broadcasting in Tensor

    * Fix assert_close in test_samplers.py

    * Fix cholesky bugs

    * Fix bug in _trace_mm()

    * Fixes for examples/vae.py

    * Remove examples/vae.py

    * Add docstrings

    * Resurrect lazy Subs funsor (again)

    * Fix typo

    * Allow completely lazy eager_subs method

commit 15b0c73
Author: Fritz Obermeyer <[email protected]>
Date:   Mon Mar 25 17:04:45 2019 -0700

    Implement Monte Carlo interpretation of Integrate (#54)

    * Sketch Monte Carlo interpretation of logaddexp reduction

    * Use AssociativeOp in patterns

    * Fix op pattern matcher

    * Try eager before monte_carlo

    * Drop ops.sample, ops.marginal

    * Sketch VAE example using monte carlo interpretation

    * Refactor, focusing on .sample() and .monte_carlo_logsumexp() methods

    * Fix vae example

    * Sketch Tensor.sample() (untested)

    * Fix cyclic import

    * Sketch Gaussian.sample() (untested)

    * Implement Delta.sample()

    * Sketch Expectation class

    * Sketch sampler implementations

    * Delete Expectation in favor of Integrate in a separate PR

    * Revert .sample() sketch

    * Update VAE example to use multi-output Functions

    * Fix reductions in VAE

    * Sketch support for multiple args in __getitem__

    * Fix bugs in getitem_tensor_tensor

    * Add stronger tests for tensor getitem

    * Add support for string indexing

    * Simplify vae example using multi-getitem

    * Add stub for Integrate

    * Fix typo

    * Sketch monte_carlo registration of Gaussian-Gaussian things

    * Add stubs for Joint integration

    * Fix typos

    * Sketch support for multiple samples

    * Fix test usage of registry

    * Fix bugs in gaussian integral

    * Handle scale factors in Funsor.sample()

    * Use Integrate in test_samplers.py

    * Fix bug in Integrate; be less clever

    * Add implementations of gaussian-linear integrals

    * Add interpretation logging controlled by FUNSOR_DEBUG

    * Simplify debug printing

    * Fix lazy reduction for Joint.reduce()

    * Fix recursion bug

    * Get univariate Gaussian sampling to mostly work

    * Fix bug in Tensor.eager_reduce with nontrivial output

    * Fix output shape broadcasting in Tensor

    * Fix assert_close in test_samplers.py

    * Fix cholesky bugs

    * Fix bug in _trace_mm()

    * Fixes for examples/vae.py

    * Remove examples/vae.py

    * Add docstrings

    * Updates per review

    * Revert accidental change

commit d2d4c4a
Author: Fritz Obermeyer <[email protected]>
Date:   Sat Mar 23 13:44:16 2019 -0700

    Fix lazy reduction for Joint.reduce() (#94)

    * Fix lazy reduction for Joint.reduce()

    * Fix recursion bug

commit 270d168
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 22 16:44:01 2019 -0700

    Add interpretation logging controlled by FUNSOR_DEBUG=1 (#93)

    * Add interpretation logging controlled by FUNSOR_DEBUG

    * Simplify debug printing

    * Improve pretty printing of Stack and Joint

commit 5d0a291
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 22 12:55:34 2019 -0700

    Implement advanced indexing in Funsor.__getitem__() (#88)

    * Sketch support for multiple args in __getitem__

    * Fix bugs in getitem_tensor_tensor

    * Add stronger tests for tensor getitem

    * Add support for string indexing

commit 028f640
Author: Fritz Obermeyer <[email protected]>
Date:   Thu Mar 21 15:45:29 2019 -0700

    Add isort command to Makefile (#92)

commit 7bbfb3a
Author: Fritz Obermeyer <[email protected]>
Date:   Thu Mar 21 13:39:40 2019 -0700

    Sketched a simple PCFG example (#87)

commit 3fe2581
Author: Fritz Obermeyer <[email protected]>
Date:   Thu Mar 21 13:39:14 2019 -0700

    Refactor contract dependencies (#91)

    * Refactor contract dependencies

    * Fix optimize(Contract, Tensor, Tensor)

    * Fix dtype computation

    * Address review comment

    * Fix typo

commit 7cca0f8
Author: eb8680 <[email protected]>
Date:   Wed Mar 20 12:22:44 2019 -0700

    Implement Contract term (#77)

commit 876070f
Author: Fritz Obermeyer <[email protected]>
Date:   Wed Mar 20 00:19:26 2019 -0700

    Add a to_data() helper (#84)

    * Add a to_nonfunsor() helper

    * Fix typo; add more tests

    * Rename to_nonfunsor to to_data

commit 05649ae
Author: Fritz Obermeyer <[email protected]>
Date:   Tue Mar 19 20:50:04 2019 -0700

    Support torch functions that return nested tuples of tensors (#82)

commit 2b8c0e5
Author: eb8680 <[email protected]>
Date:   Tue Mar 19 14:39:51 2019 -0700

    Rename funsor.contract module to funsor.sum_product (#81)

commit 0139a70
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 15 15:58:11 2019 -0700

    Implement monte carlo .sample() methods (#75)

commit b5ea615
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 15 15:40:08 2019 -0700

    Implement sequential interpretation (#76)

commit 5fa7fa6
Author: Fritz Obermeyer <[email protected]>
Date:   Wed Mar 13 11:29:21 2019 -0700

    Implement a Joint normal form funsor (#69)

    * Add a simple delta distribution

    * Add tests for nontrivial event dim

    * Simplify unit test

    * Sketch a general Delta funsor class

    * Simplify to binding a single name in Delta

    * Add some tests for Delta

    * Add test for ground substitution

    * Add tests for reduction

    * Add test for conversion from dist.Delta to Delta

    * Sketch JointNormalForm funsor

    * Settle on Joint interface

    * Add more + handling

    * Remove .log_density field from Delta funsor

    * Drop handling of .log_density from Joint

    * Add logic promoting various Binary(-,-) to Joint

    * Revert "Remove .log_density field from Delta funsor"

    This reverts commit 897f523.

    * Revert "Drop handling of .log_density from Joint"

    This reverts commit a7d0082.

    * Simplify Gaussian funsor

    * WIP Refactor Joint patterns

    * Get Gaussian working with Joint

    * Add a smoke test for Joint

    * Add test for reduction

    * Make xfail more targeted

    * Update docstring on Joint

    * Remove unnecessary handling of Binary(ops.add,...)

commit 9dbb231
Author: Neeraj Pradhan <[email protected]>
Date:   Tue Mar 12 18:46:00 2019 -0700

     Separate out ops implementations based on backend (#74)

    * Separate out ops implementations based on backend

    * rebase with master

    * fix failing tests

    * fix error in safediv; get tests working

    * use object for binary ops

    * address comment

    * address comments

commit b130f17
Author: Fritz Obermeyer <[email protected]>
Date:   Mon Mar 11 16:21:14 2019 -0700

    Implement a general Delta funsor (#65)

    * Add a simple delta distribution

    * Add tests for nontrivial event dim

    * Simplify unit test

    * Sketch a general Delta funsor class

    * Simplify to binding a single name in Delta

    * Add some tests for Delta

    * Add test for ground substitution

    * Add tests for reduction

    * Add test for conversion from dist.Delta to Delta

    * Remove .log_density field from Delta funsor

    * Revert "Remove .log_density field from Delta funsor"

    This reverts commit 897f523.

    * Fix failing test

    * Add tests for log_density

    * Update __init__.py

commit 34a1d9c
Author: Fritz Obermeyer <[email protected]>
Date:   Mon Mar 11 15:53:09 2019 -0700

    Implement MultivariateNormal distribution (#73)

    * Add multivariate distribution

    * Reduce test tolerance to fix CI build

commit 8108b78
Author: Neeraj Pradhan <[email protected]>
Date:   Mon Mar 11 12:48:37 2019 -0700

    Add numpy backend for funsor (#58)

commit 89540d6
Author: eb8680 <[email protected]>
Date:   Mon Mar 11 12:43:22 2019 -0700

    Add prototype funsor.adjoint module (#64)

commit 27b4a76
Author: Fritz Obermeyer <[email protected]>
Date:   Sun Mar 10 19:38:57 2019 -0700

    Make reduction methods operate over events (#66)

    * Make reduction ops operate over events

    * Update existing tests

    * Update examples

    * Update README.md

    * Add tests for event reduction ops

    * Fix shape bug

    * Update README.md

commit db497c4
Author: eb8680 <[email protected]>
Date:   Sat Mar 9 19:43:27 2019 -0800

    Add lazy option to HMM examples (#67)

commit e46c2df
Author: Fritz Obermeyer <[email protected]>
Date:   Sat Mar 9 01:56:27 2019 -0800

    Refactor contract (#60)

    * Sketch funsor.contract module

    * Add unit test for _partition

    * Add tests for partial_sum_product()

    * Fix test in python 3

commit 97153c7
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 8 16:37:47 2019 -0800

    Match Op type rather than object (#63)

commit d960182
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 8 15:56:34 2019 -0800

    Add type check in Funsor.__call__() (#62)

commit 72fedac
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 8 15:14:15 2019 -0800

    Update minipyro storyboard to correctly handle plates (#56)

    * Update minipyro storyboard to correctly handle plates

    * Revert changes to einsum.py

commit 52f4366
Author: Fritz Obermeyer <[email protected]>
Date:   Fri Mar 8 14:57:21 2019 -0800

    Implement Op wrapper class to enable pattern matching (#55)

commit e64a730
Author: Fritz Obermeyer <[email protected]>
Date:   Wed Mar 6 17:41:20 2019 -0800

    Add a simple Delta distribution (#49)

    * Add a simple delta distribution

    * Add tests for nontrivial event dim

    * Simplify unit test

commit c47a17f
Author: eb8680 <[email protected]>
Date:   Wed Mar 6 09:12:29 2019 -0800

    Fix path evaluation order in optimizer (#47)

commit 4537e90
Author: eb8680 <[email protected]>
Date:   Tue Mar 5 18:27:36 2019 -0800

    Add plated einsum implementation (#46)

commit 448c1fa
Author: Fritz Obermeyer <[email protected]>
Date:   Mon Mar 4 17:12:54 2019 -0800

    Implement general Gaussian funsor (#37)

    * WIP sketch Gaussian funsor

    * Partially implement binary_gaussian_gaussian

    * Implement marginalization along a dimension; add smoke test

    * Add more comments

    * Implement binary_gaussian_gaussian

    * Sketch to_affine() and Affine funsor

    * Add xfailing test for to_affine()

    * Sketch more of eager_subs

    * Remove affine stuff

    * WIP fix align_gaussian() using align_tensor()

    * Refactor and simplify align_tensor()

    * Fix eager_subs

    * Get smoke tests working

    * Switch from scale_tril to precision representation

    * Implement basic Normal -> Gaussian transform

    * Rename normal conversions

    * Fix filling in of defaults for distribution classes

    * Add test for binary_gaussian_number

    * Add test for binary_gaussian_tensor

    * Add xfailing test for gaussian + gaussian

    * Add more tests

    * Add test of Normal vs Gaussian

    * Fix math error in Gaussian .logsumexp()

    * Fix bugs in Gaussian+Gaussian, align_gaussian()

    * Fix kalman_filter.py, add to make test

    * Add more distribution tests

commit d333418
Author: eb8680 <[email protected]>
Date:   Sun Mar 3 10:35:23 2019 -0800

    Reinstate opt_einsum-based optimizer (#40)
  • Loading branch information
eb8680 committed Jun 28, 2019
1 parent 5b038ce commit 216f3da
Show file tree
Hide file tree
Showing 68 changed files with 9,535 additions and 1,077 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ cache:
install:
- pip install -U pip
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then
pip install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp27-cp27mu-linux_x86_64.whl;
pip install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp27-cp27mu-linux_x86_64.whl;
else
pip install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp36-cp36m-linux_x86_64.whl;
pip install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp36-cp36m-linux_x86_64.whl;
fi

# Keep track of Pyro dev branch
- pip install https://github.com/pyro-ppl/pyro/archive/dev.zip

- pip install .[test]
- pip freeze

Expand Down
30 changes: 26 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
all: test
.PHONY: all install docs lint format test clean FORCE

all: docs test

install:
pip install -e .[dev]

docs: FORCE
$(MAKE) -C docs html

lint: FORCE
flake8

format: FORCE
isort -y

test: lint FORCE
pytest -v test
FUNSOR_DEBUG=1 pytest -v test/test_gaussian.py
FUNSOR_USE_TCO=1 pytest -v test/test_terms.py
FUNSOR_USE_TCO=1 pytest -v test/test_einsum.py
FUNSOR_USE_TCO=1 pytest -v test/test_numpy.py
python examples/discrete_hmm.py -n 2
@#python examples/kalman_filter.py --xfail-if-not-implemented
python examples/discrete_hmm.py -n 2 -t 50 --lazy
FUNSOR_USE_TCO=1 python examples/discrete_hmm.py -n 1 -t 50 --lazy
FUNSOR_USE_TCO=1 python examples/discrete_hmm.py -n 1 -t 500 --lazy
python examples/kalman_filter.py -n 2
python examples/kalman_filter.py -n 2 -t 50 --lazy
FUNSOR_USE_TCO=1 python examples/kalman_filter.py -n 1 -t 50 --lazy
FUNSOR_USE_TCO=1 python examples/kalman_filter.py -n 1 -t 500 --lazy
python examples/minipyro.py
python examples/minipyro.py --jit
python examples/slds.py -n 2 -t 50
python examples/pcfg.py --size 3
python examples/vae.py --smoke-test
@#python examples/ss_vae_delayed.py --xfail-if-not-implemented
@#python examples/minipyro.py --xfail-if-not-implemented
@echo PASS

clean: FORCE
git clean -dfx -e pyro-egg.info
git clean -dfx -e funsor-egg.info

FORCE:
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Funsor ![unstable](https://img.shields.io/badge/status-unstable-red.svg)
![unstable](https://img.shields.io/badge/status-unstable-red.svg)
[![Build Status](https://travis-ci.com/pyro-ppl/funsor.svg?branch=master)](https://travis-ci.com/pyro-ppl/funsor)
[![Documentation Status](https://readthedocs.org/projects/funsor/badge)](http://funsor.readthedocs.io)

# Funsor

Functional analysis + tensors + symbolic algebra.

Expand Down Expand Up @@ -59,8 +63,8 @@ def pyro_sample(name, dist, obs=None):
return value

# ...later during inference...
log_prob = trace_log_prob.logsumexp() # collapses delayed variables
loss = -funsor.eval(log_prob) # performs variable elimination
log_prob = trace_log_prob.reduce(logaddexp) # collapses delayed variables
loss = -funsor.eval(log_prob) # performs variable elimination
```
See [examples/minipyro.py](examples/minipyro.py) for a more complete example.

Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = funsor
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
36 changes: 36 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=funsor

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%

:end
popd
6 changes: 6 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
contextlib2
multipledispatch
numpy>=1.7
opt_einsum>=2.3.2
six>=1.10.0
unification
7 changes: 7 additions & 0 deletions docs/source/adjoint.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Adjoint Algorithms
------------------
.. automodule:: funsor.adjoint
:members:
:undoc-members:
:show-inheritance:
:member-order: bysource
199 changes: 199 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import os
import sys

import sphinx_rtd_theme

# import pkg_resources

# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
sys.path.insert(0, os.path.abspath('../..'))

# -- Project information -----------------------------------------------------

project = u'Funsor'
copyright = u'2019, Uber Technologies, Inc'
author = u'Uber AI Labs'

# The short X.Y version
version = u'0.0'
# The full version, including alpha/beta/rc tags
release = u'0.0'


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
]

# Disable documentation inheritance so as to avoid inheriting
# docstrings in a different format, e.g. when the parent class
# is a PyTorch class.

autodoc_inherit_docstrings = False

autodoc_default_options = {
'member-order': 'bysource',
'show-inheritance': True,
'special-members': True,
'undoc-members': True,
'exclude-members': '__dict__,__module__,__weakref__',
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


# do not prepend module name to functions
add_module_names = False

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'funsordoc'


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Funsor.tex', u'Funsor Documentation', u'Uber AI Labs', 'manual'),
]

# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'Funsor', u'Funsor Documentation',
[author], 1)
]

# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Funsor', u'Funsor Documentation',
author, 'Funsor', 'Functional analysis + tensors + symbolic algebra.',
'Miscellaneous'),
]


# -- Extension configuration -------------------------------------------------

# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
'torch': ('http://pytorch.org/docs/master/', None),
'pyro': ('http://docs.pyro.ai/en/stable/', None),
'opt_einsum': ('https://optimized-einsum.readthedocs.io/en/stable/', None)
}

# @jpchen's hack to get rtd builder to install latest pytorch
if 'READTHEDOCS' in os.environ:
os.system('pip install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp37-cp37m-linux_x86_64.whl')
# pyro needs to be installed after torch so pyro doesnt install the bloated torch-1.0 wheel
os.system('pip install pyro-ppl')
7 changes: 7 additions & 0 deletions docs/source/distributions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Distributions
-------------
.. automodule:: funsor.distributions
:members:
:undoc-members:
:show-inheritance:
:member-order: bysource
7 changes: 7 additions & 0 deletions docs/source/domains.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Domains
-------
.. automodule:: funsor.domains
:members:
:undoc-members:
:show-inheritance:
:member-order: bysource
7 changes: 7 additions & 0 deletions docs/source/einsum.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Einsum Interface
----------------
.. automodule:: funsor.einsum
:members:
:undoc-members:
:show-inheritance:
:member-order: bysource
Loading

0 comments on commit 216f3da

Please sign in to comment.