27 #ifndef LBANN_LAYERS_ACTIVATIONS_IDENTITY_HPP_INCLUDED 28 #define LBANN_LAYERS_ACTIVATIONS_IDENTITY_HPP_INCLUDED 35 #ifdef LBANN_HAS_DISTCONV 36 template <
typename TensorDataType, data_layout Layout, El::Device Device>
37 class identity_distconv_adapter
38 :
public data_type_distconv_adapter<TensorDataType>
43 identity_distconv_adapter(Layer& layer)
44 : data_type_distconv_adapter<TensorDataType>(layer)
46 virtual ~identity_distconv_adapter() =
default;
47 void setup_distributions(tensor_overlap_constraints& constraints)
override;
48 std::unique_ptr<TensorDevType> setup_activations_i(
int index)
const override;
49 std::unique_ptr<TensorDevType>
50 setup_error_signals_i(
int index)
const override;
52 #endif // LBANN_HAS_DISTCONV 59 template <
typename TensorDataType, data_layout Layout, El::Device Device>
65 std::string
get_type()
const override {
return "identity"; }
72 std::string get_onnx_op_type()
const override {
return "Identity"; }
73 #endif // LBANN_HAS_ONNX 78 template <
typename ArchiveT>
85 void write_specific_proto(lbann_data::Layer& proto)
const final;
90 this->set_output_dims(this->get_input_dims());
94 #ifdef LBANN_HAS_DISTCONV 97 if (this->distconv_enabled()) {
102 #endif // LBANN_HAS_DISTCONV 103 El::LockedView(this->get_activations(), this->get_prev_activations());
107 #ifdef LBANN_HAS_DISTCONV 110 if (this->distconv_enabled()) {
115 #endif // LBANN_HAS_DISTCONV 116 El::LockedView(this->get_error_signals(), this->get_prev_error_signals());
120 #ifdef LBANN_HAS_DISTCONV 122 bool is_distconv_supported()
const override 126 void setup_distconv_adapter()
override 128 this->get_distconv_adapter_ptr() = std::make_unique<
129 identity_distconv_adapter<TensorDataType, Layout, Device>>(*this);
131 #endif // LBANN_HAS_DISTCONV 134 #ifndef LBANN_IDENTITY_LAYER_INSTANTIATE 135 #define PROTO_DEVICE(T, Device) \ 136 extern template class identity_layer<T, data_layout::DATA_PARALLEL, Device>; \ 137 extern template class identity_layer<T, data_layout::MODEL_PARALLEL, Device> 141 #endif // LBANN_IDENTITY_LAYER_INSTANTIATE 145 #endif // LBANN_LAYERS_ACTIVATIONS_IDENTITY_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.
std::string get_type() const override
Get the layer type's name.
identity_layer * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
void serialize(std::ostream &os, google::protobuf::Message const &msg)
Serialize the protobuf message to a stream.
constexpr El::Device Device
void fp_setup_outputs() override
void bp_compute() override
Compute objective funciton gradients. Called by the 'back_prop' function. Given the input...
void bp_setup_gradient_wrt_inputs() override
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...
void bp_setup_gradient_wrt_inputs() override
Setup gradient w.r.t. input tensors. Called by the 'back_prop' function. Each gradient w...
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.
El::Device get_device_allocation() const override
Get the device allocation for the data tensors. We assume that the decice allocation of the previous ...
data_layout
Data layout that is optimized for different modes of parallelism.
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.
void fp_setup_outputs() override
Setup output tensors. Called by the 'forward_prop' function. Each output tensor is resized to match t...
dc::TensorDev< OutputTensorDataType > TensorDevType