autoppl  v0.8
A C++ template library for probabilistic programming
ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > > Struct Template Reference

#include <lower.hpp>

Public Types

using value_t = ValueType
 
using shape_t = ShapeType
 
using var_t = util::var_t< value_t, shape_t >
 
using constraint_t = Lower< ExprType >
 
using uc_view_t = ad::util::shape_to_raw_view_t< value_t, shape_t >
 
using view_t = uc_view_t
 

Public Member Functions

 Transformer (size_t rows, size_t cols, const constraint_t &c)
 
void transform ()
 
void inv_transform (size_t refcnt)
 
template<class CurrPtrPack , class PtrPack >
auto inv_transform_ad (const CurrPtrPack &curr_pack, const PtrPack &pack, size_t refcnt) const
 
template<class CurrPtrPack , class PtrPack >
auto logj_inv_transform_ad (const CurrPtrPack &curr_pack, const PtrPack &) const
 
template<class GenType , class ContDist >
void init (GenType &gen, ContDist &dist)
 
void activate_refcnt (size_t curr_refcnt) const
 
var_tget_c ()
 
const var_tget_c () const
 
constexpr size_t size_uc () const
 
constexpr size_t rows_uc () const
 
constexpr size_t cols_uc () const
 
constexpr size_t size_c () const
 
constexpr size_t rows_c () const
 
constexpr size_t cols_c () const
 
constexpr size_t bind_size_uc () const
 
constexpr size_t bind_size_c () const
 
constexpr size_t bind_size_v () const
 
template<class CurrPtrPack , class PtrPack >
void bind (const CurrPtrPack &curr_pack, const PtrPack &pack)
 

Member Typedef Documentation

◆ constraint_t

template<class ValueType , class ShapeType , class ExprType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::constraint_t = Lower<ExprType>

◆ shape_t

template<class ValueType , class ShapeType , class ExprType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::shape_t = ShapeType

◆ uc_view_t

template<class ValueType , class ShapeType , class ExprType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::uc_view_t = ad::util::shape_to_raw_view_t<value_t, shape_t>

◆ value_t

template<class ValueType , class ShapeType , class ExprType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::value_t = ValueType

◆ var_t

template<class ValueType , class ShapeType , class ExprType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::var_t = util::var_t<value_t, shape_t>

◆ view_t

template<class ValueType , class ShapeType , class ExprType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::view_t = uc_view_t

Constructor & Destructor Documentation

◆ Transformer()

template<class ValueType , class ShapeType , class ExprType >
ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::Transformer ( size_t  rows,
size_t  cols,
const constraint_t c 
)
inline

Constructs a Transformer object. It represents a lower-bounded scalar.

Parameters
cconstraint object must be provided since it cannot be default-constructed

Member Function Documentation

◆ activate_refcnt()

template<class ValueType , class ShapeType , class ExprType >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::activate_refcnt ( size_t  curr_refcnt) const
inline

Activates reference count for the constraint expression. Since the constraint expression will only be evaluated once per model evaluation, we chose to only activate constraint when the current reference count is 1, i.e. only the first reference to a parameter gets to activate the constraint.

◆ bind()

template<class ValueType , class ShapeType , class ExprType >
template<class CurrPtrPack , class PtrPack >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::bind ( const CurrPtrPack &  curr_pack,
const PtrPack &  pack 
)
inline

Binds unconstrained viewer to unconstrained region, constrained viewer to constrained region, and internal visit count to visit count region.

◆ bind_size_c()

template<class ValueType , class ShapeType , class ExprType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::bind_size_c ( ) const
inlineconstexpr

◆ bind_size_uc()

template<class ValueType , class ShapeType , class ExprType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::bind_size_uc ( ) const
inlineconstexpr

Returns the number of elements required to bind and compute unconstrained, constrained parameters and visit count.

◆ bind_size_v()

template<class ValueType , class ShapeType , class ExprType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::bind_size_v ( ) const
inlineconstexpr

◆ cols_c()

template<class ValueType , class ShapeType , class ExprType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::cols_c ( ) const
inlineconstexpr

◆ cols_uc()

template<class ValueType , class ShapeType , class ExprType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::cols_uc ( ) const
inlineconstexpr

◆ get_c() [1/2]

template<class ValueType , class ShapeType , class ExprType >
var_t& ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::get_c ( )
inline

◆ get_c() [2/2]

template<class ValueType , class ShapeType , class ExprType >
const var_t& ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::get_c ( ) const
inline

◆ init()

template<class ValueType , class ShapeType , class ExprType >
template<class GenType , class ContDist >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::init ( GenType &  gen,
ContDist &  dist 
)
inline

Initializes unconstrained values such that unconstrained value is randomly generated determined by dist.

◆ inv_transform()

template<class ValueType , class ShapeType , class ExprType >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::inv_transform ( size_t  refcnt)
inline

Inverse transforms from unconstrained parameters to constrained parameters. Only the first visitor of the visit count will invoke the actual transformation. The reference count is used to reset the visit count if the visit count has reached refcnt.

◆ inv_transform_ad()

template<class ValueType , class ShapeType , class ExprType >
template<class CurrPtrPack , class PtrPack >
auto ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::inv_transform_ad ( const CurrPtrPack &  curr_pack,
const PtrPack &  pack,
size_t  refcnt 
) const
inline

Creates an AD expression representing the inverse transform. User must ensure that this gets called exactly refcnt number of times.

Parameters
uc_valbeginning of unconstrained parameter values
uc_adjbeginning of unconstrained parameter adjoints
c_valbeginning of constrained value region.
v_valbeginning of visit count
refcnttotal reference count to determine when to loop visit count back to 0

◆ logj_inv_transform_ad()

template<class ValueType , class ShapeType , class ExprType >
template<class CurrPtrPack , class PtrPack >
auto ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::logj_inv_transform_ad ( const CurrPtrPack &  curr_pack,
const PtrPack &   
) const
inline

Creates an AD expression representing the log-jacobian of inverse transform. Log-jacobian of inverse transform is identical to the unconstrained variable itself.

◆ rows_c()

template<class ValueType , class ShapeType , class ExprType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::rows_c ( ) const
inlineconstexpr

◆ rows_uc()

template<class ValueType , class ShapeType , class ExprType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::rows_uc ( ) const
inlineconstexpr

◆ size_c()

template<class ValueType , class ShapeType , class ExprType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::size_c ( ) const
inlineconstexpr

◆ size_uc()

template<class ValueType , class ShapeType , class ExprType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::size_uc ( ) const
inlineconstexpr

Returns the dimension information for the viewers of unconstrained and constrained parameters.

◆ transform()

template<class ValueType , class ShapeType , class ExprType >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Lower< ExprType > >::transform ( )
inline

This method is currently only used by Param::inv_eval. It should not handle any reference counting. It also assumes all other variables that are referenced in the constraint expression have already been evaluated.


The documentation for this struct was generated from the following file: