27 #ifndef LBANN_LAYERS_ACTIVATIONS_LOG_SOFTMAX_HPP_INCLUDED 28 #define LBANN_LAYERS_ACTIVATIONS_LOG_SOFTMAX_HPP_INCLUDED 32 #if defined LBANN_HAS_DNN_LIB 34 #endif // LBANN_HAS_DNN_LIB 35 #include "lbann/proto/layers.pb.h" 43 template <
typename TensorDataType, data_layout Layout, El::Device Device>
59 #ifdef LBANN_HAS_DNN_LIB
61 m_tensors_dnn_desc(this)
68 #ifdef LBANN_HAS_DNN_LIB
70 m_tensors_dnn_desc(other.m_tensors_dnn_desc)
73 #ifdef LBANN_HAS_DNN_LIB 74 m_tensors_dnn_desc.set_layer(
this);
75 #endif // LBANN_HAS_DNN_LIB 82 #ifdef LBANN_HAS_DNN_LIB 83 m_tensors_dnn_desc = other.m_tensors_dnn_desc;
84 m_tensors_dnn_desc.set_layer(
this);
85 #endif // LBANN_HAS_DNN_LIB 95 std::string
get_type()
const override {
return "log softmax"; }
117 dist.colDist = El::STAR;
118 m_workspace.reset(AbsDistMatrixType::Instantiate(dist));
119 #ifdef HYDROGEN_HAVE_CUB 120 if (
m_workspace->GetLocalDevice() == El::Device::GPU) {
123 #endif // HYDROGEN_HAVE_CUB 129 template <
typename U>
131 template <
typename U>
137 template <
typename ArchiveT>
150 #ifdef LBANN_HAS_DNN_LIB 154 #endif // LBANN_HAS_DNN_LIB 157 template <
typename T, data_layout L, El::Device D>
159 lbann_data::Layer& proto)
const 161 proto.set_datatype(proto::ProtoDataType<T>);
162 proto.mutable_log_softmax();
165 #ifndef LBANN_LOG_SOFTMAX_LAYER_INSTANTIATE 166 #define PROTO_DEVICE(T, Device) \ 167 extern template class log_softmax_layer<T, \ 168 data_layout::DATA_PARALLEL, \ 170 extern template class log_softmax_layer<T, \ 171 data_layout::MODEL_PARALLEL, \ 176 #endif // LBANN_LOG_SOFTMAX_LAYER_INSTANTIATE 180 #endif // LBANN_LAYERS_ACTIVATIONS_LOG_SOFTMAX_HPP_INCLUDED 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.
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
void bp_compute() override
Compute objective funciton gradients. Called by the 'back_prop' function. Given the input...
std::unique_ptr< AbsDistMatrixType > m_workspace
~log_softmax_layer()=default
std::vector< int > get_input_dims(size_t input_index=0) const
Get input tensor dimensions.
log_softmax_layer * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...
data_layout get_data_layout() const override
Get data layout of the data tensors. We assume that the data layouts of the previous activations...
constexpr El::Device Device
InputAbsDistMatrixType & get_prev_activations(int parent_index=0)
Logarithm of softmax function.
void set_output_dims(std::vector< int > dims, size_t output_index=0)
Set output tensor dimensions.
friend void bp_compute_impl(log_softmax_layer< U, Layout, Device > &l)
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::AbstractDistMatrix< TensorDataType > AbsDistMatrixType
The tensor type expected in this object.
log_softmax_layer(lbann_comm *comm)
log_softmax_layer & operator=(const log_softmax_layer &other)
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.
std::string get_type() const override
Get the layer type's name.
data_layout
Data layout that is optimized for different modes of parallelism.
void write_specific_proto(lbann_data::Layer &proto) const final
friend void fp_compute_impl(log_softmax_layer< U, Layout, Device > &l)
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...
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 setup_data(size_t max_mini_batch_size) override
void serialize(ArchiveT &ar)
data_type_layer & operator=(data_type_layer &&other)=default
void setup_data(size_t max_mini_batch_size) override
Setup layer data. Called by the 'setup' function. Memory is allocated for distributed matrices...
log_softmax_layer(const log_softmax_layer &other)