27 #ifndef LBANN_LAYER_ACTIVATION_RELU_HPP_INCLUDED 28 #define LBANN_LAYER_ACTIVATION_RELU_HPP_INCLUDED 32 #include "lbann/proto/layers.pb.h" 35 #ifdef LBANN_HAS_DISTCONV 36 #include "distconv/dnn_backend/relu.hpp" 42 #ifdef LBANN_HAS_DISTCONV 44 using Backend = ::distconv::BackendDNNLib;
45 using ReLU = ::distconv::ReLU<Backend>;
48 template <
typename TensorDataType, data_layout T_layout, El::Device Dev>
49 class relu_distconv_adapter :
public data_type_distconv_adapter<TensorDataType>
54 relu_distconv_adapter(Layer& layer)
55 : data_type_distconv_adapter<TensorDataType>(layer)
57 virtual ~relu_distconv_adapter() =
default;
58 void setup_distributions(tensor_overlap_constraints& constraints)
override;
59 void setup_layer(
size_t workspace_capacity)
override;
60 std::unique_ptr<dc::ReLU> m_relu;
62 #endif // LBANN_HAS_DISTCONV 68 template <
typename TensorDataType, data_layout T_layout, El::Device Dev>
75 std::string
get_type()
const override {
return "ReLU"; }
85 std::string get_onnx_op_type()
const override {
return "Relu"; }
86 #endif // LBANN_HAS_ONNX 91 template <
typename ArchiveT>
98 void write_specific_proto(lbann_data::Layer& proto)
const final;
100 void fp_compute()
override;
101 void bp_compute()
override;
102 #ifdef LBANN_HAS_DISTCONV 103 bool is_distconv_supported()
const override 107 void setup_distconv_adapter()
override 109 this->get_distconv_adapter_ptr() =
110 std::make_unique<relu_distconv_adapter<TensorDataType, T_layout, Dev>>(
113 relu_distconv_adapter<TensorDataType, T_layout, Dev>&
114 get_distconv_adapter()
override;
115 const relu_distconv_adapter<TensorDataType, T_layout, Dev>&
116 get_distconv_adapter()
const override;
117 #endif // LBANN_HAS_DISTCONV 120 #ifndef LBANN_RELU_LAYER_INSTANTIATE 121 #define PROTO_DEVICE(T, Device) \ 122 extern template class relu_layer<T, data_layout::DATA_PARALLEL, Device>; \ 123 extern template class relu_layer<T, data_layout::MODEL_PARALLEL, Device> 127 #endif // LBANN_RELU_LAYER_INSTANTIATE 131 #endif // LBANN_LAYER_ACTIVATION_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...
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 ...
void serialize(std::ostream &os, google::protobuf::Message const &msg)
Serialize the protobuf message to a stream.
constexpr El::Device Device
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
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.
relu_layer(lbann_comm *comm)
relu_layer * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...
dc::TensorDev< OutputTensorDataType > TensorDevType