autoppl  v0.8
A C++ template library for probabilistic programming
ppl::ParamView< ValueType, ShapeType, ConstraintType > Struct Template Reference

#include <param.hpp>

Inheritance diagram for ppl::ParamView< ValueType, ShapeType, ConstraintType >:
ppl::util::VarExprBase< ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > > ppl::util::ParamBase< ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > > ppl::util::BaseCRTP< ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > > ppl::util::VarBase< ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > > ppl::util::BaseCRTP< ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > >

Public Types

using value_t = ValueType
 
using shape_t = ShapeType
 
using constraint_t = ConstraintType
 
using var_t = util::var_t< value_t, shape_t >
 
using id_t = const void *
 

Public Member Functions

 ParamView (details::ParamInfoPack *i_pack, size_t rows=1, size_t cols=1, constraint_t c=constraint_t()) noexcept
 
template<class Func >
void traverse (Func &&) const
 
const var_teval ()
 
void inv_eval ()
 
template<class TPValPtrType , class TPAdjPtrType >
auto ad (const util::PtrPack< value_t *, value_t *, TPValPtrType, TPAdjPtrType, value_t * > &pack) const
 
template<class TPValPtrType , class TPAdjPtrType >
auto logj_ad (const util::PtrPack< value_t *, value_t *, TPValPtrType, TPAdjPtrType, value_t * > &pack) const
 
template<class GenType , class ContDist >
void init (GenType &gen, ContDist &dist)
 
void activate (util::OffsetPack &pack) const
 
void activate_refcnt () const
 
template<class PtrPackType >
void bind (const PtrPackType &pack)
 
var_tget ()
 
const var_tget () const
 
constexpr size_t size () const
 
constexpr size_t rows () const
 
constexpr size_t cols () const
 
id_t id () const
 
auto & offset ()
 
auto offset () const
 
constexpr size_t size_uc () const
 
constexpr size_t size_c () const
 
- Public Member Functions inherited from ppl::util::BaseCRTP< ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > >
ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > & self ()
 
const ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > & self () const
 

Static Public Attributes

static constexpr bool has_param = true
 

Detailed Description

template<class ValueType, class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
struct ppl::ParamView< ValueType, ShapeType, ConstraintType >

ParamView is a class that views or references a parameter entity. It views the internal data of the first parameter object that was created. This is our way of making sure that all references to a parameter object when creating a model expression indeed refers to that first object.

Users will likely not need to create these objects directly. The easier-to-use Param class template will likely be used. When constructing a model expression, both Param and ParamView objects will be converted to a ParamView.

Template Parameters
ValueTypevalue type to view
ShapeTypeshape of the object it is viewing.
ConstraintTypeconstraint expression type

Member Typedef Documentation

◆ constraint_t

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
using ppl::ParamView< ValueType, ShapeType, ConstraintType >::constraint_t = ConstraintType

◆ id_t

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
using ppl::ParamView< ValueType, ShapeType, ConstraintType >::id_t = const void*

◆ shape_t

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
using ppl::ParamView< ValueType, ShapeType, ConstraintType >::shape_t = ShapeType

◆ value_t

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
using ppl::ParamView< ValueType, ShapeType, ConstraintType >::value_t = ValueType

◆ var_t

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
using ppl::ParamView< ValueType, ShapeType, ConstraintType >::var_t = util::var_t<value_t, shape_t>

Constructor & Destructor Documentation

◆ ParamView()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
ppl::ParamView< ValueType, ShapeType, ConstraintType >::ParamView ( details::ParamInfoPack i_pack,
size_t  rows = 1,
size_t  cols = 1,
constraint_t  c = constraint_t() 
)
inlinenoexcept

Member Function Documentation

◆ activate()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
void ppl::ParamView< ValueType, ShapeType, ConstraintType >::activate ( util::OffsetPack pack) const
inline

Set the common offsets with pack and resets reference count to 0. Updates pack to contain the next offsets after accounting for current ParamView.

Note: this should only be called exactly once per parameter referenced in a model. Since a model must assign a distribution to every parameter referenced in the model, it suffices to activate parameters in those expressions.

◆ activate_refcnt()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
void ppl::ParamView< ValueType, ShapeType, ConstraintType >::activate_refcnt ( ) const
inline

Increments the reference count to activate the current ParamView. The total number of reference counts for a parameter is defined to be the number of inverse-transforms required for the paarameter during model evaluation. This is identical to the number of ParamView objects referencing the parrameter in the model. In general, constraint expression may need to be activated as well. It requires the current reference count to determine if the activation is needed.

◆ ad()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
template<class TPValPtrType , class TPAdjPtrType >
auto ppl::ParamView< ValueType, ShapeType, ConstraintType >::ad ( const util::PtrPack< value_t *, value_t *, TPValPtrType, TPAdjPtrType, value_t * > &  pack) const
inline

◆ bind()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
template<class PtrPackType >
void ppl::ParamView< ValueType, ShapeType, ConstraintType >::bind ( const PtrPackType &  pack)
inline

Finds the correct offsetted pointers for the three parameters using the common offsets in info pack and delegates binding to underlying transformer. This only needs to be called if user wishes to call eval(). For AD support only, this does not need to be called.

◆ cols()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
constexpr size_t ppl::ParamView< ValueType, ShapeType, ConstraintType >::cols ( ) const
inlineconstexpr

◆ eval()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
const var_t& ppl::ParamView< ValueType, ShapeType, ConstraintType >::eval ( )
inline

Evaluates the ParamView expression by first incrementing the visit count. If it is the first to visit such parameter when evaluating the model, it must first transform the unconstrained parameters to constrained parameters. If it is the last to visit such parameter, it must reset the visit count back to 0 for the next time we evaluate the model.

Returns
constrained parameter view

◆ get() [1/2]

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
var_t& ppl::ParamView< ValueType, ShapeType, ConstraintType >::get ( )
inline

◆ get() [2/2]

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
const var_t& ppl::ParamView< ValueType, ShapeType, ConstraintType >::get ( ) const
inline

◆ id()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
id_t ppl::ParamView< ValueType, ShapeType, ConstraintType >::id ( ) const
inline

◆ init()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
template<class GenType , class ContDist >
void ppl::ParamView< ValueType, ShapeType, ConstraintType >::init ( GenType &  gen,
ContDist &  dist 
)
inline

Initialize unconstrained values by generating constrained values and then transforming to unconstrained values. Undefined behavior if bind has not been called before.

◆ inv_eval()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
void ppl::ParamView< ValueType, ShapeType, ConstraintType >::inv_eval ( )
inline

This method is currently only used during pruning in initialization. It assumes that reference counting is not needed, since a full model evaluation is not required when this is called.

◆ logj_ad()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
template<class TPValPtrType , class TPAdjPtrType >
auto ppl::ParamView< ValueType, ShapeType, ConstraintType >::logj_ad ( const util::PtrPack< value_t *, value_t *, TPValPtrType, TPAdjPtrType, value_t * > &  pack) const
inline

◆ offset() [1/2]

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
auto& ppl::ParamView< ValueType, ShapeType, ConstraintType >::offset ( )
inline

◆ offset() [2/2]

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
auto ppl::ParamView< ValueType, ShapeType, ConstraintType >::offset ( ) const
inline

◆ rows()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
constexpr size_t ppl::ParamView< ValueType, ShapeType, ConstraintType >::rows ( ) const
inlineconstexpr

◆ size()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
constexpr size_t ppl::ParamView< ValueType, ShapeType, ConstraintType >::size ( ) const
inlineconstexpr

◆ size_c()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
constexpr size_t ppl::ParamView< ValueType, ShapeType, ConstraintType >::size_c ( ) const
inlineconstexpr

◆ size_uc()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
constexpr size_t ppl::ParamView< ValueType, ShapeType, ConstraintType >::size_uc ( ) const
inlineconstexpr

◆ traverse()

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
template<class Func >
void ppl::ParamView< ValueType, ShapeType, ConstraintType >::traverse ( Func &&  ) const
inline

Member Data Documentation

◆ has_param

template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
constexpr bool ppl::ParamView< ValueType, ShapeType, ConstraintType >::has_param = true
staticconstexpr

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