LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
lbann::WeightsProxy< TensorDataType > Class Template Reference

Proxy a weights object as a different data type. More...

#include <weights_proxy.hpp>

Public Member Functions

Constructors
 WeightsProxy ()=default
 Construct an empty proxy. More...
 
 WeightsProxy (ViewingWeightsPtr const &w)
 Construct a proxy given the master object. More...
 
 WeightsProxy (WeightsProxy const &other)
 Copy a WeightsProxy object. More...
 
template<typename T >
 WeightsProxy (WeightsProxy< T > const &other)
 Copy a WeightsProxy object. More...
 
 WeightsProxy (WeightsProxy &&other) noexcept
 Move a WeightsProxy object. More...
 
 ~WeightsProxy () noexcept
 Destructor. More...
 
Assignment operators
WeightsProxyoperator= (WeightsProxy const &other)
 Copy assignment operator. More...
 
template<typename T >
WeightsProxyoperator= (WeightsProxy< T > const &other)
 Assignment from WeightsProxy object of a different type. More...
 
WeightsProxyoperator= (WeightsProxy &&other) noexcept
 Move assignment from another proxy object. More...
 
Master object management and synchronization.
void clear () noexcept
 Restore the default state of the proxy. More...
 
void setup (ViewingWeightsPtr const &w)
 Provide setup function for delayed construction. More...
 
void synchronize_with_master ()
 Synchronize the held values with the master set. More...
 
Queries and accessors
bool empty () const noexcept
 Check if the proxy is referencing a weights object. More...
 
ValuesType const & values () const noexcept(!LBANN_IN_DEBUG_MODE)
 Access the values. More...
 
weights const & master_weights () const
 Access the master weights object directly. More...
 
ViewingWeightsPtr master_weights_pointer () const noexcept(!LBANN_IN_DEBUG_MODE)
 
Utility functions
void swap (WeightsProxy< TensorDataType > &other)
 Swap contents with another WeightsProxy object. More...
 

Private Types

using ValuesType = El::AbstractDistMatrix< TensorDataType >
 The type of weights values. More...
 
using ValuesPtrType = std::unique_ptr< ValuesType >
 Convenience typedef for poitners to weights values. More...
 

Private Member Functions

Private setup functions
ValuesPtrType setup_values_ (data_type_weights< TensorDataType > const &dtw) const
 Establish the view of the master data. More...
 
template<typename OtherT >
ValuesPtrType setup_values_ (data_type_weights< OtherT > const &w) const
 Establish the target matrix storage. More...
 
ValuesPtrType setup_values_ (weights const &w) const
 Establish the target matrix storage. More...
 
ValuesPtrType setup_values_as_copy_ (weights const &w) const
 Create the matrix object to store the copied weights. More...
 

Private Attributes

Private members
ViewingWeightsPtr master_weights_
 The proxied master weights. More...
 
ValuesPtrType values_
 The values in this data type. More...
 

Detailed Description

template<typename TensorDataType>
class lbann::WeightsProxy< TensorDataType >

Proxy a weights object as a different data type.

This class is intended to be an implementation detail of the layers' interactions with weights objects. Thus, the implementation employs a programming-by-contract approach in an effort to avoid, e.g., safe dereferences to internal pointer members.

The class contract is as follows:

Template Parameters
TensorDataTypeThe type to which the weights are proxied.

Definition at line 77 of file weights_proxy.hpp.

Member Typedef Documentation

◆ ValuesPtrType

template<typename TensorDataType>
using lbann::WeightsProxy< TensorDataType >::ValuesPtrType = std::unique_ptr<ValuesType>
private

Convenience typedef for poitners to weights values.

Definition at line 82 of file weights_proxy.hpp.

◆ ValuesType

template<typename TensorDataType>
using lbann::WeightsProxy< TensorDataType >::ValuesType = El::AbstractDistMatrix<TensorDataType>
private

The type of weights values.

Definition at line 80 of file weights_proxy.hpp.

Constructor & Destructor Documentation

◆ WeightsProxy() [1/5]

template<typename TensorDataType>
lbann::WeightsProxy< TensorDataType >::WeightsProxy ( )
default

Construct an empty proxy.

◆ WeightsProxy() [2/5]

template<typename TensorDataType>
lbann::WeightsProxy< TensorDataType >::WeightsProxy ( ViewingWeightsPtr const &  w)
inline

Construct a proxy given the master object.

Parameters
wMaster weights object, which must have a valid storage matrix initialized internally.

Definition at line 96 of file weights_proxy.hpp.

Here is the call graph for this function:

◆ WeightsProxy() [3/5]

template<typename TensorDataType>
lbann::WeightsProxy< TensorDataType >::WeightsProxy ( WeightsProxy< TensorDataType > const &  other)
inline

Copy a WeightsProxy object.

Creates a new proxy to the same weights object.

Definition at line 107 of file weights_proxy.hpp.

Here is the call graph for this function:

◆ WeightsProxy() [4/5]

template<typename TensorDataType>
template<typename T >
lbann::WeightsProxy< TensorDataType >::WeightsProxy ( WeightsProxy< T > const &  other)
inline

Copy a WeightsProxy object.

Creates a new proxy to the same weights object.

Template Parameters
T(Deduced) The type of the input weights object's values.

Definition at line 122 of file weights_proxy.hpp.

Here is the call graph for this function:

◆ WeightsProxy() [5/5]

template<typename TensorDataType>
lbann::WeightsProxy< TensorDataType >::WeightsProxy ( WeightsProxy< TensorDataType > &&  other)
inlinenoexcept

Move a WeightsProxy object.

Unlike copy construction, move construction is only supported for WeightsProxy objects of the same static type.

Definition at line 135 of file weights_proxy.hpp.

◆ ~WeightsProxy()

template<typename TensorDataType>
lbann::WeightsProxy< TensorDataType >::~WeightsProxy ( )
inlinenoexcept

Destructor.

Definition at line 143 of file weights_proxy.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ clear()

template<typename TensorDataType>
void lbann::WeightsProxy< TensorDataType >::clear ( )
inlinenoexcept

Restore the default state of the proxy.

After this function is called, the object will be empty().

Definition at line 188 of file weights_proxy.hpp.

Here is the caller graph for this function:

◆ empty()

template<typename TensorDataType>
bool lbann::WeightsProxy< TensorDataType >::empty ( ) const
inlinenoexcept

Check if the proxy is referencing a weights object.

Definition at line 236 of file weights_proxy.hpp.

Here is the caller graph for this function:

◆ master_weights()

template<typename TensorDataType>
weights const& lbann::WeightsProxy< TensorDataType >::master_weights ( ) const
inline

Access the master weights object directly.

The contract of this class specifies that this function is only valid if not empty(). Users are expected to ensure this contract.

Definition at line 256 of file weights_proxy.hpp.

◆ master_weights_pointer()

template<typename TensorDataType>
ViewingWeightsPtr lbann::WeightsProxy< TensorDataType >::master_weights_pointer ( ) const
inlinenoexcept

Definition at line 262 of file weights_proxy.hpp.

Here is the caller graph for this function:

◆ operator=() [1/3]

template<typename TensorDataType>
WeightsProxy& lbann::WeightsProxy< TensorDataType >::operator= ( WeightsProxy< TensorDataType > const &  other)
inline

Copy assignment operator.

Definition at line 151 of file weights_proxy.hpp.

Here is the call graph for this function:

◆ operator=() [2/3]

template<typename TensorDataType>
template<typename T >
WeightsProxy& lbann::WeightsProxy< TensorDataType >::operator= ( WeightsProxy< T > const &  other)
inline

Assignment from WeightsProxy object of a different type.

After assignment, this and other both proxy the weights proxied by other.

Template Parameters
T(Deduced) The type of the input weights object's values.

Definition at line 166 of file weights_proxy.hpp.

Here is the call graph for this function:

◆ operator=() [3/3]

template<typename TensorDataType>
WeightsProxy& lbann::WeightsProxy< TensorDataType >::operator= ( WeightsProxy< TensorDataType > &&  other)
inlinenoexcept

Move assignment from another proxy object.

Definition at line 173 of file weights_proxy.hpp.

Here is the call graph for this function:

◆ setup()

template<typename TensorDataType>
void lbann::WeightsProxy< TensorDataType >::setup ( ViewingWeightsPtr const &  w)
inline

Provide setup function for delayed construction.

This overwrites any existing data.

Parameters
wThe weights object to be proxied.

Definition at line 200 of file weights_proxy.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_values_() [1/3]

template<typename TensorDataType>
ValuesPtrType lbann::WeightsProxy< TensorDataType >::setup_values_ ( data_type_weights< TensorDataType > const &  dtw) const
inlineprivate

Establish the view of the master data.

Definition at line 288 of file weights_proxy.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_values_() [2/3]

template<typename TensorDataType>
template<typename OtherT >
ValuesPtrType lbann::WeightsProxy< TensorDataType >::setup_values_ ( data_type_weights< OtherT > const &  w) const
inlineprivate

Establish the target matrix storage.

This only participates in overload resolution if OtherT is different from TensorDataType, which has a dedicated overload.

Template Parameters
OtherT(Deduced) The type of the input weights object's values.

Definition at line 306 of file weights_proxy.hpp.

Here is the call graph for this function:

◆ setup_values_() [3/3]

template<typename TensorDataType>
ValuesPtrType lbann::WeightsProxy< TensorDataType >::setup_values_ ( weights const &  w) const
inlineprivate

Establish the target matrix storage.

Definition at line 312 of file weights_proxy.hpp.

Here is the call graph for this function:

◆ setup_values_as_copy_()

template<typename TensorDataType>
ValuesPtrType lbann::WeightsProxy< TensorDataType >::setup_values_as_copy_ ( weights const &  w) const
inlineprivate

Create the matrix object to store the copied weights.

Definition at line 320 of file weights_proxy.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap()

template<typename TensorDataType>
void lbann::WeightsProxy< TensorDataType >::swap ( WeightsProxy< TensorDataType > &  other)
inline

Swap contents with another WeightsProxy object.

Definition at line 274 of file weights_proxy.hpp.

Here is the caller graph for this function:

◆ synchronize_with_master()

template<typename TensorDataType>
void lbann::WeightsProxy< TensorDataType >::synchronize_with_master ( )
inline

Synchronize the held values with the master set.

If empty(), this function takes the view that there is no master with which to synchronize, so no action is required – it is a no-op.

Definition at line 217 of file weights_proxy.hpp.

Here is the call graph for this function:

◆ values()

template<typename TensorDataType>
ValuesType const& lbann::WeightsProxy< TensorDataType >::values ( ) const
inlinenoexcept

Access the values.

The contract of this class specifies that this function is only valid if not empty(). Users are expected to ensure this contract.

Definition at line 244 of file weights_proxy.hpp.

Member Data Documentation

◆ master_weights_

template<typename TensorDataType>
ViewingWeightsPtr lbann::WeightsProxy< TensorDataType >::master_weights_
private

The proxied master weights.

Definition at line 336 of file weights_proxy.hpp.

◆ values_

template<typename TensorDataType>
ValuesPtrType lbann::WeightsProxy< TensorDataType >::values_
private

The values in this data type.

Definition at line 339 of file weights_proxy.hpp.


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