27 #ifndef LBANN_LAYERS_MISC_ONE_HOT_HPP_INCLUDED 28 #define LBANN_LAYERS_MISC_ONE_HOT_HPP_INCLUDED 33 #include "lbann/proto/layers.pb.h" 44 template <
typename TensorDataType, data_layout Layout, El::Device Device>
57 template <
typename ArchiveT>
62 std::string
get_type()
const override {
return "one-hot"; }
80 template <
typename T, data_layout L, El::Device D>
82 lbann_data::Layer& proto)
const 84 proto.set_datatype(proto::ProtoDataType<T>);
85 auto* msg = proto.mutable_one_hot();
89 #ifndef LBANN_ONE_HOT_LAYER_INSTANTIATE 90 #define PROTO_DEVICE(T, Device) \ 91 extern template class one_hot_layer<T, data_layout::DATA_PARALLEL, Device>; \ 92 extern template class one_hot_layer<T, data_layout::MODEL_PARALLEL, Device> 95 #endif // LBANN_ONE_HOT_LAYER_INSTANTIATE 99 #endif // LBANN_LAYERS_MISC_ONE_HOT_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...
void serialize(ArchiveT &ar)
void write_specific_proto(lbann_data::Layer &proto) const final
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
constexpr El::Device Device
one_hot_layer(size_t size)
Convert index to a one-hot vector.
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 ...
friend class cereal::access
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_compute() override
Apply layer operation. Called by the 'forward_prop' function. Given the input tensors, the output tensors are populated with computed values.
std::string get_type() const override
Get the layer type's name.
std::vector< int > get_output_dims(size_t output_index=0) const
Get output tensor dimensions.
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...
one_hot_layer * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...