27 #ifndef LBANN_LAYER_DISCRETE_RANDOM_HPP_INCLUDED 28 #define LBANN_LAYER_DISCRETE_RANDOM_HPP_INCLUDED 44 template <
typename TensorDataType,
49 static_assert(Dev == El::Device::CPU,
50 "discrete random layer currently only supports CPU");
52 "discrete random layer currently only supports DATA_PARALLEL");
60 std::vector<DataType> values,
61 std::vector<int> dims)
74 template <
typename ArchiveT>
79 std::string
get_type()
const override {
return "discrete random"; }
96 LBANN_ERROR(
"input tensor dimensions don't match number of " 97 "values in discrete distribution");
104 #ifndef LBANN_DISCRETE_RANDOM_LAYER_INSTANTIATE 106 extern template class discrete_random_layer<T, \ 107 data_layout::DATA_PARALLEL, \ 110 #define LBANN_INSTANTIATE_CPU_HALF 113 #undef LBANN_INSTANTIATE_CPU_HALF 114 #endif // LBANN_DISCRETE_RANDOM_LAYER_INSTANTIATE 117 #endif // LBANN_LAYER_DISCRETE_RANDOM_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.
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.
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...
friend class cereal::access
discrete_random_layer(lbann_comm *comm, std::vector< DataType > values, std::vector< int > dims)
void serialize(ArchiveT &ar)
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
constexpr El::Device Device
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.
int get_input_size(size_t input_index=0) const
Get input tensor size.
void set_output_dims(std::vector< int > dims, size_t output_index=0)
Set output tensor dimensions.
El::Device get_device_allocation() const override
Get the device allocation for the data tensors. We assume that the decice allocation of the previous ...
std::vector< DataType > m_values
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.
data_layout
Data layout that is optimized for different modes of parallelism.
void write_specific_proto(lbann_data::Layer &proto) const final
discrete_random_layer * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...
Random output from discrete distribution.