26 #ifndef LBANN_WEIGHTS_WEIGHTS_PROXY_HPP_INCLUDED 27 #define LBANN_WEIGHTS_WEIGHTS_PROXY_HPP_INCLUDED 29 #include "lbann_config.hpp" 35 #if defined LBANN_DEBUG 37 #define LBANN_DEBUG_ASSERT_POINTER(ptr) \ 40 LBANN_ERROR("Pointer \"" #ptr "\" is null."); \ 42 #define LBANN_IN_DEBUG_MODE true 44 #define LBANN_DEBUG_ASSERT_POINTER(ptr) 45 #define LBANN_IN_DEBUG_MODE false 76 template <
typename TensorDataType>
80 using ValuesType = El::AbstractDistMatrix<TensorDataType>;
121 template <
typename T>
125 if (!ptr.expired()) {
137 values_{std::move(other.values_)}
165 template <
typename T>
223 dynamic_cast<const ValuesType&>(master_values));
226 El::Copy(master_values, *
values_);
292 El::LockedView(*ret, vals);
305 template <
typename OtherT>
345 template <
typename TensorDataType>
349 #undef LBANN_IN_DEBUG_MODE 350 #endif // LBANN_WEIGHTS_WEIGHTS_PROXY_HPP_INCLUDED void clear() noexcept
Restore the default state of the proxy.
WeightsProxy(WeightsProxy &&other) noexcept
Move a WeightsProxy object.
std::unique_ptr< ValuesType > ValuesPtrType
Convenience typedef for poitners to weights values.
AbsDistMatrixType & get_values() override
WeightsProxy(WeightsProxy< T > const &other)
Copy a WeightsProxy object.
bool empty() const noexcept
Check if the proxy is referencing a weights object.
void synchronize_with_master()
Synchronize the held values with the master set.
size_t get_matrix_width() const
#define LBANN_DEBUG_ASSERT_POINTER(ptr)
WeightsProxy(WeightsProxy const &other)
Copy a WeightsProxy object.
ValuesType const & values() const noexcept(!LBANN_IN_DEBUG_MODE)
Access the values.
ViewingWeightsPtr master_weights_pointer() const noexcept(!LBANN_IN_DEBUG_MODE)
El::DistData get_matrix_distribution() const
ValuesPtrType setup_values_(data_type_weights< OtherT > const &w) const
Establish the target matrix storage.
Proxy a weights object as a different data type.
ValuesPtrType setup_values_(weights const &w) const
Establish the target matrix storage.
ValuesPtrType values_
The values in this data type.
ValuesPtrType setup_values_(data_type_weights< TensorDataType > const &dtw) const
Establish the view of the master data.
void setup(ViewingWeightsPtr const &w)
Provide setup function for delayed construction.
WeightsProxy(ViewingWeightsPtr const &w)
Construct a proxy given the master object.
std::weak_ptr< weights > ViewingWeightsPtr
Smart pointer to reference a weights object.
WeightsProxy()=default
Construct an empty proxy.
El::AbstractDistMatrix< TensorDataType > ValuesType
The type of weights values.
void swap(WeightsProxy< TensorDataType > &other)
Swap contents with another WeightsProxy object.
WeightsProxy & operator=(WeightsProxy const &other)
Copy assignment operator.
size_t get_matrix_height() const
ValuesPtrType setup_values_as_copy_(weights const &w) const
Create the matrix object to store the copied weights.
#define LBANN_IN_DEBUG_MODE
WeightsProxy & operator=(WeightsProxy &&other) noexcept
Move assignment from another proxy object.
ViewingWeightsPtr master_weights_
The proxied master weights.
weights const & master_weights() const
Access the master weights object directly.
~WeightsProxy() noexcept
Destructor.
WeightsProxy & operator=(WeightsProxy< T > const &other)
Assignment from WeightsProxy object of a different type.