27 #ifndef LBANN_LAYERS_LOSS_L2_NORM2_HPP_INCLUDED 28 #define LBANN_LAYERS_LOSS_L2_NORM2_HPP_INCLUDED 32 #include "lbann/proto/layers.pb.h" 40 template <
typename TensorDataType, data_layout T_layout, El::Device Dev>
71 template <
typename ArchiveT>
76 std::string
get_type()
const override {
return "L2 norm squared"; }
97 dist.colDist = El::STAR;
98 m_workspace.reset(AbsDistMatrixType::Instantiate(dist));
99 #ifdef HYDROGEN_HAVE_CUB 100 if (
m_workspace->GetLocalDevice() == El::Device::GPU) {
103 #endif // HYDROGEN_HAVE_CUB 127 #ifndef LBANN_L2_NORM2_LAYER_INSTANTIATE 129 #define PROTO_DEVICE(T, Device) \ 130 extern template class l2_norm2_layer<T, data_layout::DATA_PARALLEL, Device>; \ 131 extern template class l2_norm2_layer<T, data_layout::MODEL_PARALLEL, Device> 136 #endif // LBANN_L2_NORM2_LAYER_INSTANTIATE 140 #endif // LBANN_LAYERS_LOSS_L2_NORM2_HPP_INCLUDED l2_norm2_layer(lbann_comm *comm)
virtual void setup_dims()
Setup tensor dimensions Called by the 'setup' function. If there are any input tensors, the base method sets all uninitialized output tensor dimensions equal to the first input tensor dimensions.
std::string get_type() const override
Get the layer type's name.
El::Device get_device_allocation() const override
Get the device allocation for the data tensors. We assume that the decice allocation of the previous ...
std::unique_ptr< AbsDistMatrixType > m_workspace
l2_norm2_layer * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...
void fp_compute() override
Apply layer operation. Called by the 'forward_prop' function. Given the input tensors, the output tensors are populated with computed values.
constexpr El::Device Device
InputAbsDistMatrixType & get_prev_activations(int parent_index=0)
void bp_compute() override
Compute objective funciton gradients. Called by the 'back_prop' function. Given the input...
l2_norm2_layer(const l2_norm2_layer &other)
void set_output_dims(std::vector< int > dims, size_t output_index=0)
Set output tensor dimensions.
El::AbstractDistMatrix< TensorDataType > AbsDistMatrixType
The tensor type expected in this object.
Square of L2 vector norm.
void serialize(ArchiveT &ar)
void write_specific_proto(lbann_data::Layer &proto) const final
friend class cereal::access
void setup_dims() override
Setup tensor dimensions Called by the 'setup' function. If there are any input tensors, the base method sets all uninitialized output tensor dimensions equal to the first input tensor dimensions.
data_layout
Data layout that is optimized for different modes of parallelism.
l2_norm2_layer & operator=(const l2_norm2_layer &other)
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...
void setup_data(size_t max_mini_batch_size) override
void setup_data(size_t max_mini_batch_size) override
Setup layer data. Called by the 'setup' function. Memory is allocated for distributed matrices...
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
data_type_layer & operator=(data_type_layer &&other)=default
data_layout get_data_layout() const override
Get data layout of the data tensors. We assume that the data layouts of the previous activations...