|
LBANN
0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
|
Computation kernels for convolution and deconvolution layers. More...
#include <base_convolution.hpp>
Public Types | |
Public Types | |
| using | WeightsType = data_type_weights< TensorDataType > |
| The concrete weights type used by this object. More... | |
| using | OptimizerType = data_type_optimizer< TensorDataType > |
| The concrete optimizer type used by this object. More... | |
| template<El::Device D> | |
| using | DMatDT = El::Matrix< TensorDataType, D > |
| using | ScalingType = TensorDataType |
Public Types inherited from lbann::data_type_layer< TensorDataType > | |
| using | InputAbsDistMatrixType = El::AbstractDistMatrix< TensorDataType > |
| The tensor type expected in this object. More... | |
| using | OutputAbsDistMatrixType = El::AbstractDistMatrix< TensorDataType > |
| using | InputAbsDistMatReadProxyType = El::AbstractDistMatrixReadDeviceProxy< TensorDataType, D > |
| The proxy tensor type expected in this object. More... | |
| using | OutputAbsDistMatReadProxyType = El::AbstractDistMatrixReadDeviceProxy< TensorDataType, D > |
| using | InputAbsMatrixType = El::AbstractMatrix< TensorDataType > |
| The local tensor type expected in this object. More... | |
| using | OutputAbsMatrixType = El::AbstractMatrix< TensorDataType > |
| using | WeightsProxyType = weights_proxy< TensorDataType > |
| The proxy type for weights used by this object. More... | |
Public Member Functions | |
| const std::vector< int > & | get_conv_dims () const |
| Get convolutional layer parameters. More... | |
| const std::vector< int > & | get_pads () const |
| const std::vector< int > & | get_strides () const |
| const std::vector< int > & | get_dilations () const |
| base_convolution_layer (int num_data_dims, int output_channels, std::vector< int > conv_dims, std::vector< int > pads, std::vector< int > strides, std::vector< int > dilations, int groups, bool has_bias) | |
| base_convolution_layer (const base_convolution_layer &other) | |
| base_convolution_layer & | operator= (const base_convolution_layer &other) |
| ~base_convolution_layer () | |
| description | get_description () const override |
| Human-readable description. More... | |
| 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. More... | |
| void | setup_data (size_t max_mini_batch_size) override |
| Setup layer data. The kernel weights are setup in the convolution and deconvolution classes. More... | |
| void | setup_gpu () override |
| Initialize GPU objects. More... | |
Serialization | |
| template<typename ArchiveT > | |
| void | serialize (ArchiveT &ar) |
Public Member Functions inherited from lbann::data_type_layer< TensorDataType > | |
| data_type_layer (lbann_comm *, bool persistent_error_signals=false) | |
| virtual | ~data_type_layer ()=default |
| std::string | get_datatype_name () const override |
| void | forward_prop () final |
| void | summarize_matrices (lbann_summary &summarizer, int step) override |
| void | check_setup () override |
| const OutputAbsDistMatrixType & | get_activations (const Layer &child) const override |
| OutputAbsDistMatrixType & | get_activations (int child_index=0) |
| const OutputAbsDistMatrixType & | get_activations (int child_index=0) const |
| const InputAbsDistMatrixType & | get_error_signals (const Layer &parent) const override |
| InputAbsDistMatrixType & | get_error_signals (int parent_index=0) |
| const InputAbsDistMatrixType & | get_error_signals (int parent_index=0) const |
| El::Int | current_output_mini_batch_size () const override |
| El::Int | infer_mini_batch_size_from_parents_or_default_to_current () const override |
| OutputAbsDistMatrixType & | get_temp_grad () |
| InputAbsDistMatrixType & | get_branch_tag_input (int tag) |
| std::vector< std::unique_ptr< InputAbsDistMatrixType > > & | get_branch_tag_input_vector () |
| std::vector< std::unique_ptr< OutputAbsDistMatrixType > > & | get_all_activations () |
| std::vector< std::unique_ptr< InputAbsDistMatrixType > > & | get_all_prev_activations () |
| std::vector< std::unique_ptr< OutputAbsDistMatrixType > > & | get_all_prev_error_signals () |
| std::vector< std::unique_ptr< InputAbsDistMatrixType > > & | get_all_error_signals () |
| OutputAbsMatrixType & | get_local_activations (int child_index=0) |
| const OutputAbsMatrixType & | get_local_activations (int child_index=0) const |
| InputAbsMatrixType & | get_local_error_signals (int parent_index=0) |
| const InputAbsMatrixType & | get_local_error_signals (int parent_index=0) const |
| void | set_keep_error_signals (bool) override |
| Set whether to keep or dynamically reallocate error signals. More... | |
| El::mpi::Comm & | get_subgrid_comm () |
| void | serialize (ArchiveT &ar) |
Public Member Functions inherited from lbann::Layer | |
| void | write_proto (lbann_data::Layer &proto) const |
| Write layer to proto file. More... | |
| lbann_comm * | get_comm () const |
| int | get_grid_tag () const noexcept |
| Identifying tag for process grid. More... | |
| void | set_grid_tag (int tag) |
| Set process grid. More... | |
| bool | runs_inplace () const |
| If true, the layer will run in-place (the input and output activations point to the same tensor). Value is set during graph setup (in setup_pointers) based on layer traits and neighboring layers. More... | |
| bool | distconv_enabled () const |
| Indicate whether distconv is enabled. More... | |
| Layer () | |
| virtual | ~Layer ()=default |
| virtual Layer * | copy () const =0 |
| Copy function. This function dynamically allocates memory for a layer instance and instantiates a copy. The caller is responsible for deallocating the instance. More... | |
| void | set_name (const std::string name) |
| Set the layer instance's name. Each layer in a model should have a unique, preferably human-readable, name. More... | |
| void | set_model (model *m) |
| Set the model that manages this layer. More... | |
| std::string | get_name () const |
| Get the layer instance's name. More... | |
| model * | get_model () const noexcept |
| Get a reference to the model that manages this layer. More... | |
| virtual std::string | get_type () const =0 |
| Get the layer type's name. More... | |
| virtual data_layout | get_data_layout () const =0 |
| Get data layout of the data tensors. We assume that the data layouts of the previous activations, activations, previous error signals, and error signals are the same. Each concrete layer that is templated on its data layout should override this function to return its template parameter. More... | |
| virtual El::Device | get_device_allocation () const =0 |
| Get the device allocation for the data tensors. We assume that the decice allocation of the previous activations, activations, previous error signals, and error signals are the same. Each concrete layer that is templated on its device allocation should override this function to return its template parameter. More... | |
| int | get_expected_num_parent_layers () const noexcept |
| Get expected number of parent layers. A negative value indicates no limit. More... | |
| int | get_expected_num_child_layers () const noexcept |
| Get expected number of child layers. A negative value indicates no limit. More... | |
| virtual int | get_backprop_requirements () const |
| Returns the necessary tensors for computing backpropagation. More... | |
| ParallelStrategy & | get_parallel_strategy () noexcept |
| Get the parallel strategy for the layer. More... | |
| ParallelStrategy const & | get_parallel_strategy () const noexcept |
| Get the parallel strategy for the layer. More... | |
| virtual bool | can_run_inplace () const |
| If True, the computation can run in-place (feeding each input activations tensor as the corresponding output activations) More... | |
| bool | using_gpus () const noexcept |
| Whether the layer is using a GPU implementation. More... | |
| void | back_prop () |
| Backward propagation step. Given the objective function gradients w.r.t. the output tensors, compute the gradients w.r.t. the input tensors and w.r.t. the weights. This is essentially an application of the chain rule. More... | |
| bool | update () |
| Update step. Update the layer's internal members. Note that the optimization step for the weights happens elsewhere. More... | |
| virtual void | setup (size_t max_mini_batch_size, const std::vector< El::Grid *> &grids) |
| Setup layer members. More... | |
| void | summarize_stats (lbann_summary &summarizer, int step) |
| void | reset_counters () |
| Reset layer stat counters. More... | |
| void | set_communication_flag (SubGraphCommunication type) |
| SubGraphCommunication | get_communication_flag () |
| void | set_num_spliting_groups (El::Int spliting_groups) |
| El::Int | get_num_spliting_groups () const |
| std::shared_ptr< El::Grid > | get_mygrid () const |
| void | reset_inter_subgrid_vc_comm (std::shared_ptr< El::mpi::Comm > mpi_comm) |
| void | set_subgraph_parallelism_execution () |
| bool | subgraph_parallelism_execution () const noexcept |
| void | set_run_layer_in_subgraph () |
| bool | get_run_layer_in_subgraph () const noexcept |
| const Layer & | get_parent_layer (size_t index=0) const |
| const Layer & | get_child_layer (size_t index=0) const |
| std::vector< const Layer * > | get_parent_layers () const |
| std::vector< const Layer * > | get_child_layers () const |
| size_t | find_parent_layer_index (const Layer &l) const |
| size_t | find_child_layer_index (const Layer &l) const |
| int | get_num_parents () const noexcept |
| Get number of parent layers. More... | |
| int | get_num_children () const noexcept |
| Get number of child layers. More... | |
| void | add_parent_layer (ViewingLayerPtr parent) |
| Add a parent layer. More... | |
| void | add_child_layer (ViewingLayerPtr child) |
| Add a child layer. More... | |
| void | replace_parent_layer (ViewingLayerPtr l, size_t index) |
| void | replace_child_layer (ViewingLayerPtr l, size_t index) |
| void | clear_parent_layers () |
| Remove pointers to parent layers. More... | |
| void | clear_child_layers () |
| Remove pointers to child layers. More... | |
| ViewingLayerPtr | get_parent_layer_pointer (size_t index) const |
| ViewingLayerPtr | get_child_layer_pointer (size_t index) const |
| virtual std::vector< ViewingLayerPtr > | get_layer_pointers () |
| List of pointers to other layers. More... | |
| virtual void | set_layer_pointers (std::vector< ViewingLayerPtr > layers) |
| Set list of pointers to other layers. More... | |
| std::vector< ViewingWeightsPtr > | get_weights_pointers () const |
| List of pointers to weights. More... | |
| void | set_weights_pointers (std::vector< ViewingWeightsPtr > ptrs) |
| Set list of pointers to weights. More... | |
| void | replace_weights (Layer const &other_layer) |
| Replace weights with another Layer's weights. More... | |
| std::vector< int > | get_input_dims (size_t input_index=0) const |
| Get input tensor dimensions. More... | |
| int | get_input_size (size_t input_index=0) const |
| Get input tensor size. More... | |
| std::vector< int > | get_output_dims (size_t output_index=0) const |
| Get output tensor dimensions. More... | |
| int | get_output_size (size_t output_index=0) const |
| Get output tensor size. More... | |
| void | set_output_dims (std::vector< int > dims, size_t output_index=0) |
| Set output tensor dimensions. More... | |
| El::Int | infer_mini_batch_size_from_parents () const |
| void | set_hint_layer (ViewingLayerPtr l) |
| Set hint layer. More... | |
| const Layer * | get_hint_layer () const |
| Get hint layer. More... | |
| void | freeze () |
| void | unfreeze () |
| bool | is_frozen () const |
| template<typename ArchiveT > | |
| void | serialize (ArchiveT &ar) |
Protected Member Functions | |
| virtual std::vector< int > | get_kernel_dims () const =0 |
| void | apply_convolution_dnn (bool during_forward_prop) |
| void | apply_transposed_convolution_dnn (bool during_forward_prop) |
| void | apply_bias_dnn () |
| void | compute_gradients_dnn (bool using_transposed_convolution) |
| void | apply_convolution_im2col (bool during_forward_prop) |
| void | apply_transposed_convolution_im2col (bool during_forward_prop) |
| void | apply_bias_cpu () |
| void | compute_gradients_im2col (bool using_transposed_convolution) |
Protected Member Functions inherited from lbann::data_type_layer< TensorDataType > | |
| InputAbsDistMatrixType & | get_prev_activations (int parent_index=0) |
| const InputAbsDistMatrixType & | get_prev_activations (int parent_index=0) const |
| OutputAbsDistMatrixType & | get_prev_error_signals (int child_index=0) |
| const OutputAbsDistMatrixType & | get_prev_error_signals (int child_index=0) const |
| const InputAbsMatrixType & | get_local_prev_activations (int parent_index=0) const |
| const OutputAbsMatrixType & | get_local_prev_error_signals (int child_index=0) const |
| void | setup_matrices (const std::vector< El::Grid * > &grids) override |
| void | setup_data (size_t max_mini_batch_size) override |
| void | fp_setup_inputs () override |
| void | fp_setup_outputs () override |
| void | bp_setup_gradient_wrt_inputs () override |
| void | bp_compute () override |
| InputAbsDistMatrixType const & | weights_values (size_t idx) const |
| Get the values matrix for a specific weights object. More... | |
| weights & | master_weights (size_t idx) |
| Get a specific master weights object. More... | |
| weights const & | master_weights (size_t idx) const |
| data_type_layer (data_type_layer &&other)=default | |
| Protected lifecycle functions. More... | |
| data_type_layer (data_type_layer const &other) | |
| data_type_layer & | operator= (data_type_layer &&other)=default |
| data_type_layer & | operator= (data_type_layer const &other) |
Protected Member Functions inherited from lbann::Layer | |
| void | setup_grid () |
| Setup process grid. More... | |
| virtual void | setup_pointers () |
| Setup layer pointers. Called by the 'setup' function. Pointers to parent/child layers are assumed to be already initialized. More... | |
| virtual void | fp_compute ()=0 |
| Apply layer operation. Called by the 'forward_prop' function. Given the input tensors, the output tensors are populated with computed values. More... | |
| virtual bool | update_compute () |
| Perform the computation for the update step. Returns false if the layer must reset for a new training epoch. More... | |
| Layer (Layer &&other)=default | |
| Layer (Layer const &other) | |
| Layer & | operator= (Layer &&other)=default |
| Layer & | operator= (Layer const &other) |
| void | add_weights (ViewingWeightsPtr w) |
| size_t | num_weights () const noexcept |
| bool | has_weights () const noexcept |
| bool | has_weights (size_t idx) const noexcept |
| void | set_num_weights (size_t n) |
| void | set_weights (size_t idx, ViewingWeightsPtr w) |
| weights const & | get_weights (size_t idx) const |
| weights & | get_weights (size_t idx) |
| void | add_as_gradient_source () |
| void | remove_as_gradient_source () |
Protected Attributes | |
| int | m_output_channels |
| std::vector< int > | m_conv_dims |
| Spatial dimensions for convolution kernel. More... | |
| std::vector< int > | m_pads |
| std::vector< int > | m_strides |
| std::vector< int > | m_dilations |
| int | m_groups |
| ScalingType | m_bias_scaling_factor |
Protected Attributes inherited from lbann::Layer | |
| int | m_expected_num_parent_layers = 1 |
| int | m_expected_num_child_layers = 1 |
| Expected number of child layers. A negative value indicates no limit. More... | |
| model * | m_model = nullptr |
| Reference to model managing this layer. More... | |
| bool | m_frozen |
| Avoid back prop if frozen. More... | |
| EvalType | m_fp_time |
| Time spent in forward propagation. More... | |
| EvalType | m_fp_compute_time |
| Time spent in the forward propagation computation. More... | |
| EvalType | m_bp_time |
| Time spent in backward propagation. More... | |
| EvalType | m_bp_compute_time |
| Time spent in the backward propagation computation. More... | |
| EvalType | m_update_time |
| Time spent in updates. More... | |
| std::string | m_name |
| Layer instance's name. Each layer in a model should have a unique, preferably human-readable, name. More... | |
| bool | m_runs_inplace = false |
| If true, the layer will run in-place (the input and output activations point to the same tensor). Value is set during graph setup (in setup_pointers) based on layer traits and neighboring layers. More... | |
| int | m_grid_tag = -1 |
| Identifying tag for process grid. More... | |
| SubGraphCommunication | subgraph_communication_method = PT2PT |
| bool | m_subgraph_parallelism_execution = false |
| bool | run_layer_in_subgraph = false |
| std::unique_ptr< std::set< int > > | m_subgrid_ranks |
| El::Int | m_num_spliting_groups = 1 |
| std::shared_ptr< El::mpi::Comm > | m_interSubGridVCComm |
Computation kernels for convolution and deconvolution layers.
Definition at line 94 of file base_convolution.hpp.
| using lbann::base_convolution_layer< TensorDataType, Device >::DMatDT = El::Matrix<TensorDataType, D> |
Definition at line 107 of file base_convolution.hpp.
| using lbann::base_convolution_layer< TensorDataType, Device >::OptimizerType = data_type_optimizer<TensorDataType> |
The concrete optimizer type used by this object.
Definition at line 104 of file base_convolution.hpp.
| using lbann::base_convolution_layer< TensorDataType, Device >::ScalingType = TensorDataType |
Definition at line 112 of file base_convolution.hpp.
| using lbann::base_convolution_layer< TensorDataType, Device >::WeightsType = data_type_weights<TensorDataType> |
The concrete weights type used by this object.
Definition at line 101 of file base_convolution.hpp.
| lbann::base_convolution_layer< TensorDataType, Device >::base_convolution_layer | ( | int | num_data_dims, |
| int | output_channels, | ||
| std::vector< int > | conv_dims, | ||
| std::vector< int > | pads, | ||
| std::vector< int > | strides, | ||
| std::vector< int > | dilations, | ||
| int | groups, | ||
| bool | has_bias | ||
| ) |
| lbann::base_convolution_layer< TensorDataType, Device >::base_convolution_layer | ( | const base_convolution_layer< TensorDataType, Device > & | other | ) |
| lbann::base_convolution_layer< TensorDataType, Device >::~base_convolution_layer | ( | ) |
|
protected |
|
protected |
|
protected |
Convolution with DNN library.
|
protected |
Convolution with im2col GEMM algorithm.
|
protected |
Transposed convolution with DNN library.
|
protected |
Transposed convolution with im2col GEMM algorithm.
|
protected |
|
protected |
|
inline |
Get convolutional layer parameters.
Definition at line 118 of file base_convolution.hpp.
|
overridevirtual |
Human-readable description.
Reimplemented from lbann::Layer.
|
inline |
Definition at line 121 of file base_convolution.hpp.
|
protectedpure virtual |
Dimensions of convolution kernel.
Implemented in lbann::convolution_layer< TensorDataType, Layout, Device >, and lbann::deconvolution_layer< TensorDataType, Layout, Device >.
|
inline |
Definition at line 119 of file base_convolution.hpp.
|
inline |
Definition at line 120 of file base_convolution.hpp.
| base_convolution_layer& lbann::base_convolution_layer< TensorDataType, Device >::operator= | ( | const base_convolution_layer< TensorDataType, Device > & | other | ) |
| void lbann::base_convolution_layer< TensorDataType, Device >::serialize | ( | ArchiveT & | ar | ) |
|
overridevirtual |
Setup layer data. The kernel weights are setup in the convolution and deconvolution classes.
Reimplemented from lbann::Layer.
|
overridevirtual |
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.
Reimplemented from lbann::Layer.
Reimplemented in lbann::convolution_layer< TensorDataType, Layout, Device >, and lbann::deconvolution_layer< TensorDataType, Layout, Device >.
|
overridevirtual |
Initialize GPU objects.
Reimplemented from lbann::Layer.
|
protected |
Scaling factor for bias term. If the scaling factor is zero, bias is not applied.
Definition at line 145 of file base_convolution.hpp.
|
protected |
Spatial dimensions for convolution kernel.
Excludes number of input and output channels.
Definition at line 128 of file base_convolution.hpp.
|
protected |
Convolution dilations.
Definition at line 134 of file base_convolution.hpp.
|
protected |
Convolution groups. The channels are split into this many independent groups when performing convolution. The default convolution operation has one group, and a depthwise convolution has as many groups as there are input channels.
Definition at line 140 of file base_convolution.hpp.
|
protected |
Definition at line 124 of file base_convolution.hpp.
|
protected |
Convolution padding.
Definition at line 130 of file base_convolution.hpp.
|
protected |
Convolution strides.
Definition at line 132 of file base_convolution.hpp.