27 #ifndef LBANN_LAYERS_ACTIVATIONS_LEAKY_RELU_HPP_INCLUDED 28 #define LBANN_LAYERS_ACTIVATIONS_LEAKY_RELU_HPP_INCLUDED 33 #include "lbann/proto/layers.pb.h" 36 #ifdef LBANN_HAS_DISTCONV 37 #include "distconv/dnn_backend/leaky_relu.hpp" 43 #ifdef LBANN_HAS_DISTCONV 45 using Backend = ::distconv::BackendDNNLib;
46 using LeakyReLU = ::distconv::LeakyReLU<Backend>;
49 template <
typename TensorDataType, data_layout T_layout, El::Device Dev>
50 class leaky_relu_distconv_adapter
51 :
public data_type_distconv_adapter<TensorDataType>
57 leaky_relu_distconv_adapter(Layer& layer)
58 : data_type_distconv_adapter<TensorDataType>(layer)
60 virtual ~leaky_relu_distconv_adapter() =
default;
62 void setup_distributions(tensor_overlap_constraints& constraints)
override;
63 void setup_layer(
size_t workspace_capacity)
override;
65 std::unique_ptr<dc::LeakyReLU> m_leaky_relu;
67 #endif // LBANN_HAS_DISTCONV 83 template <
typename TensorDataType, data_layout Layout, El::Device Device>
90 TensorDataType negative_slope = El::To<TensorDataType>(0.01))
91 :
data_type_layer<TensorDataType>(comm), m_negative_slope(negative_slope)
97 std::string
get_type()
const override {
return "leaky ReLU"; }
104 desc.add(
"Negative slope", m_negative_slope);
111 template <
typename ArchiveT>
118 void write_specific_proto(lbann_data::Layer& proto)
const final;
123 this->set_output_dims(this->get_input_dims());
125 void fp_compute()
override;
126 void bp_compute()
override;
138 #ifdef LBANN_HAS_DISTCONV 140 bool is_distconv_supported()
const override 144 void setup_distconv_adapter()
override 146 this->get_distconv_adapter_ptr() = std::make_unique<
147 leaky_relu_distconv_adapter<TensorDataType, Layout, Device>>(*this);
149 leaky_relu_distconv_adapter<TensorDataType, Layout, Device>&
150 get_distconv_adapter()
override;
151 const leaky_relu_distconv_adapter<TensorDataType, Layout, Device>&
152 get_distconv_adapter()
const override;
153 #endif // LBANN_HAS_DISTCONV 156 #ifndef LBANN_LEAKY_RELU_LAYER_INSTANTIATE 157 #define PROTO_DEVICE(T, Device) \ 158 extern template class leaky_relu_layer<T, \ 159 data_layout::DATA_PARALLEL, \ 161 extern template class leaky_relu_layer<T, data_layout::MODEL_PARALLEL, Device> 165 #endif // LBANN_LEAKY_RELU_LAYER_INSTANTIATE 169 #endif // LBANN_LAYERS_ACTIVATIONS_LEAKY_RELU_HPP_INCLUDED data_layout get_data_layout() const override
Get data layout of the data tensors. We assume that the data layouts of the previous activations...
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.
leaky_relu_layer(lbann_comm *comm, TensorDataType negative_slope=El::To< TensorDataType >(0.01))
leaky_relu_layer * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...
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::string get_type() const override
Get the layer type's name.
void serialize(std::ostream &os, google::protobuf::Message const &msg)
Serialize the protobuf message to a stream.
Generates nicely formatted description messages.
virtual description get_description() const
Human-readable description.
constexpr El::Device Device
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.
description get_description() const override
Human-readable description.
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...
data_layout
Data layout that is optimized for different modes of parallelism.
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
TensorDataType m_negative_slope
dc::TensorDev< OutputTensorDataType > TensorDevType