27 #ifndef LBANN_LAYER_IN_TOP_K_HPP_INCLUDED 28 #define LBANN_LAYER_IN_TOP_K_HPP_INCLUDED 35 #include "lbann/proto/layers.pb.h" 46 template <
typename TensorDataType,
65 template <
typename ArchiveT>
70 std::string
get_type()
const override {
return "in_top_k"; }
106 template <
typename T, data_layout L, El::Device D>
108 lbann_data::Layer& proto)
const 110 proto.set_datatype(proto::ProtoDataType<T>);
111 auto* msg = proto.mutable_in_top_k();
115 #ifndef LBANN_IN_TOP_K_LAYER_INSTANTIATE 116 #define PROTO_DEVICE(T, Device) \ 117 extern template class in_top_k_layer<T, data_layout::DATA_PARALLEL, Device>; \ 118 extern template class in_top_k_layer<T, data_layout::MODEL_PARALLEL, Device> 122 #endif // LBANN_IN_TOP_K_LAYER_INSTANTIATE 126 #endif // LBANN_LAYER_IN_TOP_K_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.
One-hot vector indicating top-k entries.
friend class cereal::access
void serialize(ArchiveT &ar)
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::vector< int > get_input_dims(size_t input_index=0) const
Get input tensor dimensions.
Generates nicely formatted description messages.
virtual description get_description() const
Human-readable description.
std::string get_type() const override
Get the layer type's name.
constexpr El::Device Device
void set_output_dims(std::vector< int > dims, size_t output_index=0)
Set output tensor dimensions.
data_layout get_data_layout() const override
Get data layout of the data tensors. We assume that the data layouts of the previous activations...
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
in_top_k_layer * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...
void write_specific_proto(lbann_data::Layer &proto) const final
data_layout
Data layout that is optimized for different modes of parallelism.
description get_description() const override
Human-readable description.
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::Device get_device_allocation() const override
Get the device allocation for the data tensors. We assume that the decice allocation of the previous ...
in_top_k_layer(lbann_comm *comm, El::Int k)
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...