27 #ifndef LBANN_LAYERS_LEARNING_CHANNELWISE_FULLY_CONNECTED_HPP_INCLUDED 28 #define LBANN_LAYERS_LEARNING_CHANNELWISE_FULLY_CONNECTED_HPP_INCLUDED 31 #ifdef LBANN_HAS_DISTCONV 37 #ifdef LBANN_HAS_DISTCONV 39 template <
typename TensorDataType>
40 using ChannelwiseFullyConnected =
41 ::distconv::ChannelwiseFullyConnected<Backend, TensorDataType>;
44 template <
typename TensorDataType, data_layout Layout, El::Device Device>
45 class channelwise_fully_connected_distconv_adapter
46 :
public data_type_distconv_adapter<TensorDataType>
53 channelwise_fully_connected_distconv_adapter(Layer& layer)
54 : data_type_distconv_adapter<TensorDataType>(layer)
56 virtual ~channelwise_fully_connected_distconv_adapter() =
default;
58 void setup_fp_tensors()
override;
59 void setup_bp_tensors()
override;
60 void setup_distributions(tensor_overlap_constraints& constraints)
override;
61 void setup_layer(
size_t workspace_capacity)
override;
66 dc::Shape get_activations_local_shape(
int index = 0)
const override;
68 std::unique_ptr<dc::ChannelwiseFullyConnected<TensorDataType>>
70 std::unique_ptr<TensorDevType> m_linear;
71 std::unique_ptr<TensorDevType> m_bias;
72 std::unique_ptr<TensorDevType> m_linearity_gradient;
73 std::unique_ptr<TensorDevType> m_bias_gradient;
76 #endif // LBANN_HAS_DISTCONV 93 template <
typename TensorDataType, data_layout Layout, El::Device Device>
98 "channelwise_fully_connected layer " 99 "only supports data parallel layout");
120 std::string get_type()
const override;
122 El::Device get_device_allocation()
const override;
134 template <
typename ArchiveT>
141 void write_specific_proto(lbann_data::Layer& proto)
const final;
143 friend class cereal::access;
146 void setup_dims()
override;
147 void setup_data(
size_t max_mini_batch_size)
override;
149 void fp_compute()
override;
150 void bp_compute()
override;
151 std::vector<int> get_linearity_dims()
const;
152 std::vector<int> get_bias_dims()
const;
154 #ifdef LBANN_HAS_DISTCONV 155 friend class channelwise_fully_connected_distconv_adapter<TensorDataType,
160 void setup_distconv_adapter()
override;
161 bool is_distconv_supported()
const override;
162 channelwise_fully_connected_distconv_adapter<TensorDataType, Layout, Device>&
163 get_distconv_adapter()
override;
164 const channelwise_fully_connected_distconv_adapter<TensorDataType,
167 get_distconv_adapter()
const override;
181 #ifndef LBANN_CHANNELWISE_FULLY_CONNECTED_LAYER_INSTANTIATE 182 #define PROTO_DEVICE(T, Device) \ 183 extern template class channelwise_fully_connected_layer< \ 185 data_layout::DATA_PARALLEL, \ 189 #endif // LBANN_CHANNELWISE_FULLY_CONNECTED_LAYER_INSTANTIATE 193 #endif // LBANN_LAYERS_LEARNING_CHANNELWISE_FULLY_CONNECTED_HPP_INCLUDED
std::map< El::Int, std::set< El::Int > > transpose(const std::set< El::Int > &nodes, const std::map< El::Int, std::set< El::Int >> &edges)
void serialize(std::ostream &os, google::protobuf::Message const &msg)
Serialize the protobuf message to a stream.
Generates nicely formatted description messages.
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...
constexpr El::Device Device
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
Apply affine transformation to tensor channels.
::distconv::tensor::Shape Shape
data_layout
Data layout that is optimized for different modes of parallelism.
LBANN_DEFINE_LAYER_BUILDER(elu)
dc::TensorDev< OutputTensorDataType > TensorDevType