python_code
stringlengths
0
4.04M
repo_name
stringlengths
8
58
file_path
stringlengths
5
147
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch from beanmachine.ppl.inference.bmg_inference import BMGInference from torch impor...
beanmachine-main
tests/ppl/compiler/bmg_bad_models_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder from beanmachine.ppl.compiler.error_repor...
beanmachine-main
tests/ppl/compiler/size_assessment_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.compiler.gen_dot import to_dot from beanmachine.ppl.compiler.runtime impo...
beanmachine-main
tests/ppl/compiler/sizer_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch import torch.distributions as dist from beanmachine.ppl.inference import BMGInfer...
beanmachine-main
tests/ppl/compiler/gep_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Test performance of multiary multiplication optimization """ import platform import unittest import beanmachine.ppl as bm from beanmachi...
beanmachine-main
tests/ppl/compiler/binary_vs_multiary_multiplication_perf_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for bmg_types.py""" import unittest from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder from beanmachine.ppl.comp...
beanmachine-main
tests/ppl/compiler/bmg_types_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for rules.py""" import ast import re import unittest from typing import Any import astor from beanmachine.ppl.compiler.ast_pattern...
beanmachine-main
tests/ppl/compiler/rules_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch from beanmachine.ppl.inference import BMGInference from to...
beanmachine-main
tests/ppl/compiler/transpose_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Test performance of multiary addition optimization """ import platform import unittest import beanmachine.ppl as bm from beanmachine.ppl...
beanmachine-main
tests/ppl/compiler/binary_vs_multiary_addition_perf_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl.compiler.bmg_nodes as bn from beanmachine.ppl.compiler.bm_graph_builder impor...
beanmachine-main
tests/ppl/compiler/typer_base_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import operator import unittest import beanmachine.ppl as bm import torch from beanmachine.ppl.inference import BMGInference from torch imp...
beanmachine-main
tests/ppl/compiler/matrix_multiplication_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Compare original and conjugate prior transformed Beta-Bernoulli model with operations on Bernoulli samples""" import unittest from b...
beanmachine-main
tests/ppl/compiler/fix_beta_bernoulli_ops_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for gen_builder.py""" import unittest import beanmachine.ppl as bm from beanmachine.ppl.compiler.gen_builder import generate_build...
beanmachine-main
tests/ppl/compiler/gen_builder_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Compare original and conjugate prior transformed Beta-Binomial model""" import unittest import beanmachine.ppl as bm from beanmachin...
beanmachine-main
tests/ppl/compiler/fix_binomial_logit_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference.bmg_inference import BMGInference from torch import tensor from...
beanmachine-main
tests/ppl/compiler/gen_bm_python_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Compare original and conjugate prior transformed Beta-Bernoulli model with a hyperparameter given by calling a non-random_variable ...
beanmachine-main
tests/ppl/compiler/fix_beta_bernoulli_const_added_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BMGInference from torch.distributions import Normal @b...
beanmachine-main
tests/ppl/compiler/query_type_zero_bug_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder from beanmachine.ppl.compiler.gen_bmg_cpp import to_bm...
beanmachine-main
tests/ppl/compiler/bmg_factor_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BMGInference from torch import tensor from torch.distrib...
beanmachine-main
tests/ppl/compiler/bmg_query_test.py
beanmachine-main
tests/ppl/compiler/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for bmg_nodes.py""" import unittest import torch from beanmachine.ppl.compiler.bmg_nodes import ( ConstantRealMatrixNode, ...
beanmachine-main
tests/ppl/compiler/bmg_nodes_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder from beanmachine.ppl.comp...
beanmachine-main
tests/ppl/compiler/to_matrix_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """End-to-end test for tutorial on GMM with Poisson number of components""" # This file is a manual replica of the Bento tutorial with the s...
beanmachine-main
tests/ppl/compiler/gmm_1d_2comp_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import graphviz from beanmachine.ppl.inference.bmg_inference import BMG...
beanmachine-main
tests/ppl/compiler/neals_funnel_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Comparison operators are not supported in BMG yet but we need to be able to detect use of them and give an error. Here we verify that we ...
beanmachine-main
tests/ppl/compiler/comparison_rewriting_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest # The item() member function should be treated as an identity by the compiler # for the purposes of graph generation. impo...
beanmachine-main
tests/ppl/compiler/item_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from beanmachine.ppl.compiler.profiler import ProfilerData class ProfilerTest(unittest.TestCase): def test_profiler(s...
beanmachine-main
tests/ppl/compiler/profiler_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference.bmg_inference import BMGInference from torch.distributions impo...
beanmachine-main
tests/ppl/compiler/cycle_detector_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch import torch.distributions as dist from beanmachine.ppl.in...
beanmachine-main
tests/ppl/compiler/bug_regression_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # """End-to-end test for n-schools model based on the one in PPL Bench""" # See for example https://github.com/facebookresearch/pplbench/blo...
beanmachine-main
tests/ppl/compiler/n-schools_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for single_assignment.py""" import ast import unittest import astor from beanmachine.ppl.compiler.ast_patterns import ast_domain f...
beanmachine-main
tests/ppl/compiler/single_assignment_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for bm_to_bmg.py""" import unittest import astor import beanmachine.ppl as bm from beanmachine.ppl.compiler.bm_to_bmg import _bm_f...
beanmachine-main
tests/ppl/compiler/bm_to_bmg_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """End-to-end test of realistic logistic regression model""" import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference.bm...
beanmachine-main
tests/ppl/compiler/logistic_regression_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for error_report.py""" import unittest from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder from beanmachine.ppl.c...
beanmachine-main
tests/ppl/compiler/error_report_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BMGInference from torch import tensor from torch.distrib...
beanmachine-main
tests/ppl/compiler/fix_vectorized_models_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for bm_graph_builder.py""" import unittest from typing import Any import torch from beanmachine.ppl.compiler.bm_graph_builder impo...
beanmachine-main
tests/ppl/compiler/bm_graph_builder_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # LKJ Cholesky compiler tests import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BM...
beanmachine-main
tests/ppl/compiler/lkj_cholesky_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for bm_to_bmg.py""" import math import unittest import astor import beanmachine.ppl as bm from beanmachine.ppl.compiler.bm_to_bmg ...
beanmachine-main
tests/ppl/compiler/jit_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Compilation test of Todd's Bayesian Multiple Testing model""" import unittest import beanmachine.ppl as bm import torch.distributions as...
beanmachine-main
tests/ppl/compiler/bmt_model_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from beanmachine.ppl.compiler.broadcaster import broadcast_fnc from torch import Size class BroadcastTest(unittest.TestCa...
beanmachine-main
tests/ppl/compiler/broadcaster_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for patterns.py""" import ast import re import unittest from beanmachine.ppl.compiler.ast_patterns import ( ast_str, binop...
beanmachine-main
tests/ppl/compiler/patterns_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch from beanmachine.ppl.inference import BMGInference from torch import exp, log, lo...
beanmachine-main
tests/ppl/compiler/fix_logsumexp_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch from beanmachine.ppl.inference import BMGInference from torch.distributions impor...
beanmachine-main
tests/ppl/compiler/fix_logaddexp_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """End-to-end test for tutorial on Robust Linear Regression""" # This file is a manual replica of the Bento tutorial with the same name ##...
beanmachine-main
tests/ppl/compiler/tutorial_Robust_Linear_Regression_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # BM -> BMG compiler arithmetic tests import math import operator import unittest import beanmachine.ppl as bm impo...
beanmachine-main
tests/ppl/compiler/bmg_arithmetic_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder from beanmachine.ppl.compiler.gen_bmg_gra...
beanmachine-main
tests/ppl/compiler/fix_matrix_type_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Bernoulli compiler tests import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BMGIn...
beanmachine-main
tests/ppl/compiler/bernoulli_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch import torch.distributions as dist from beanmachine.ppl.inference import BMGInfer...
beanmachine-main
tests/ppl/compiler/annotated_assignment_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Categorical compiler tests import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BMG...
beanmachine-main
tests/ppl/compiler/categorical_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.compiler.runtime import BMGRuntime from torch.distributions import Bernou...
beanmachine-main
tests/ppl/compiler/node_context_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Compare original and conjugate prior transformed model""" import random import unittest import scipy import torch from beanmachine.ppl....
beanmachine-main
tests/ppl/compiler/fix_normal_normal_basic_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """End-to-end compiler test for Bayesian Meta-Analysis model""" import platform import unittest import beanmachine.ppl as bm from beanmach...
beanmachine-main
tests/ppl/compiler/bma_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.compiler.gen_dot import to_dot from beanmachine.ppl.compiler.runtime impo...
beanmachine-main
tests/ppl/compiler/stochastic_control_flow_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """End-to-end test for log1mexp""" import math import unittest import beanmachine.ppl as bm import torch from beanmachine.ppl.inference.bmg...
beanmachine-main
tests/ppl/compiler/log1mexp_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference.bmg_inference import BMGInference from torch.distributions impo...
beanmachine-main
tests/ppl/compiler/boolean_comparisons_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BMGInference from torch import tensor from torch.distrib...
beanmachine-main
tests/ppl/compiler/fix_observe_true_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BMGInference from torch.distributions import Bernoulli, ...
beanmachine-main
tests/ppl/compiler/fix_multiary_ops_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.compiler.gen_dot import to_dot from beanmachine.ppl.compiler.runtime impo...
beanmachine-main
tests/ppl/compiler/tensor_operations_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Beta-Bernoulli model conjugacy transformation check when hyperparameter is a random variable.""" import unittest import beanmachine....
beanmachine-main
tests/ppl/compiler/fix_beta_bernoulli_alpha_rv_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.compiler.copy_and_replace import copy_and_replace from beanmachine.ppl.c...
beanmachine-main
tests/ppl/compiler/tensorize_transformer_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BMGInference from torch import tensor from torch.distrib...
beanmachine-main
tests/ppl/compiler/broadcast_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference.bmg_inference import BMGInference from torch import tensor from...
beanmachine-main
tests/ppl/compiler/gen_mini_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from beanmachine.ppl.compiler.bm_graph_builder import BMGraphBuilder from beanmachine.ppl.compiler.gen_dot import to_dot f...
beanmachine-main
tests/ppl/compiler/fix_if_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """End-to-end test for tutorial on Neal's Funnel""" # This file is a manual replica of the Bento tutorial with the same name # This is a blo...
beanmachine-main
tests/ppl/compiler/tutorial_Neals_Funnel_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """End-to-end test of realistic linear regression model""" # This is copied from bento workbook N140350, simplified, and # modified to use ...
beanmachine-main
tests/ppl/compiler/linear_regression_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Compilation test of Todd's Linear Regression Outliers Marginalized model""" import unittest import beanmachine.ppl as bm from beanmachin...
beanmachine-main
tests/ppl/compiler/lromm_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import platform import unittest import beanmachine.ppl as bm from beanmachine.ppl.inference import BMGInference from torch import exp, log ...
beanmachine-main
tests/ppl/compiler/fix_logsumexp_perf_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import torch from beanmachine.ppl.inference import BMGInference from torch.distributions impor...
beanmachine-main
tests/ppl/compiler/fix_matrix_scale_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm import scipy from beanmachine.ppl.inference import BMGInference from torch.distributions impor...
beanmachine-main
tests/ppl/compiler/disable_transformations_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Compare original and conjugate prior transformed Beta-Binomial model""" import random import unittest import beanmachine.ppl as bm i...
beanmachine-main
tests/ppl/compiler/fix_beta_binomial_basic_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for bm_to_bmg.py""" import unittest import beanmachine.ppl as bm from beanmachine.ppl.compiler.gen_bmg_graph import to_bmg_graph f...
beanmachine-main
tests/ppl/compiler/graph_accumulation_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import beanmachine.ppl as bm from beanmachine.ppl.compiler.gen_bmg_cpp import to_bmg_cpp from beanmachine.ppl.compiler.gen_...
beanmachine-main
tests/ppl/compiler/lse_vector_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from typing import Any import beanmachine.ppl as bm from beanmachine.ppl.compiler.runtime import BMGRuntime from beanmachin...
beanmachine-main
tests/ppl/compiler/support_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Dirichlet compiler tests import unittest import beanmachine.ppl as bm from beanmachine.graph import ( AtomicT...
beanmachine-main
tests/ppl/compiler/dirichlet_test.py
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Dirichlet compiler tests import unittest import beanmachine.ppl as bm import torch from beanmachine.ppl.inference...
beanmachine-main
tests/ppl/compiler/cholesky_test.py
beanmachine-main
tests/ppl/compiler/testlib/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict import beanmachine.ppl as bm import torch.distributions as dist from beanmachine.ppl.model.rv_identifier import RVI...
beanmachine-main
tests/ppl/compiler/testlib/conjugate_models.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Parameterized test to compare samples from original and conjugate prior transformed models""" import random import pytest import sci...
beanmachine-main
tests/ppl/compiler/testlib/fix_beta_conjugacy_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import unittest import beanmachine.graph as bmg import numpy as np def tidy(s: str) -> str: return "\n".join(c.strip() fo...
beanmachine-main
tests/graph/operator_test.py
beanmachine-main
tests/graph/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import unittest import numpy as np from beanmachine import graph class TestNMC(unittest.TestCase): # see https://www.jsta...
beanmachine-main
tests/graph/nmc_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import numpy as np from beanmachine import graph class TestBayesNet(unittest.TestCase): def test_simple_dep(self): ...
beanmachine-main
tests/graph/graph_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import unittest import numpy as np from beanmachine import graph class TestCAVI(unittest.TestCase): def test_interface(se...
beanmachine-main
tests/graph/cavi_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. __version__ = "0.2.0"
beanmachine-main
src/beanmachine/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ The file contains MiniBM, a minimal implementation of Bean Machine PPL with a Metropolis Hastings implementation and a coin flipping mod...
beanmachine-main
src/beanmachine/minibm.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from torch.distributions import Distribution from . import experimental from .diagnostics import Diagnostics from .diagnostics.common_stati...
beanmachine-main
src/beanmachine/ppl/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
beanmachine-main
src/beanmachine/ppl/experimental/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import warnings from enum import Enum from typing import Callable from beanmachine.ppl.inference.proposer.nnc import nnc_jit class Torch...
beanmachine-main
src/beanmachine/ppl/experimental/torch_jit_backend.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import gpytorch as gpt import torch from botorch.models.gpytorch import GPyTorchModel from botorch.posteriors.gpytorch import GPyTorchPoster...
beanmachine-main
src/beanmachine/ppl/experimental/gp/models.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict import beanmachine.ppl as bm import gpytorch from beanmachine.ppl import RVIdentifier from beanmachine.ppl.world im...
beanmachine-main
src/beanmachine/ppl/experimental/gp/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/models/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import List, Optional, Union import torch from beanmachine.ppl.experimental.causal_inference.models.bart.exceptions import ( ...
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/models/bart/tree.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from abc import ABC from dataclasses import dataclass from typing import Union from beanmachine.ppl.experimental.causal_inference.models.ba...
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/models/bart/mutation.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from abc import ABCMeta, abstractmethod import torch from .tree import Tree class TreeProposer(metaclass=ABCMeta): @abstractmethod ...
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/models/bart/tree_proposer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/models/bart/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from collections import Counter from math import log from typing import cast, List, NamedTuple, Optional, Tuple import torch f...
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/models/bart/grow_from_root_tree_proposer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import enum from dataclasses import dataclass from typing import List, Optional import torch class Operator(enum.Enum): le = "less th...
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/models/bart/split_rule.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. class TreeStructureError(Exception): """Base class for errors related to tree structure""" pass class PruneError(TreeStructureEr...
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/models/bart/exceptions.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # For now supports only ordered numeric variables from __future__ import annotations import math from copy import deepcopy from typing imp...
beanmachine-main
src/beanmachine/ppl/experimental/causal_inference/models/bart/bart_model.py