27 #ifndef LBANN_LAYER_EVALUATION_HPP_INCLUDED 28 #define LBANN_LAYER_EVALUATION_HPP_INCLUDED 35 template <
typename TensorDataType>
39 #ifdef LBANN_DETERMINISTIC 44 using CPUMatType = El::Matrix<EvalDataType, El::Device::CPU>;
65 template <
typename ArchiveT>
74 void setup_data(
size_t max_mini_batch_size)
override;
89 gpu_lib::event_wrapper m_copy_event;
90 #endif // LBANN_HAS_GPU 97 template <
typename TensorDataType,
114 template <
typename ArchiveT>
119 std::string
get_type()
const override {
return "evaluation"; }
125 #ifdef LBANN_HAS_ONNX 126 void fill_onnx_node(onnx::GraphProto& graph)
const override;
127 #endif // LBANN_HAS_ONNX 133 friend class cereal::access;
137 #ifdef LBANN_HAS_ONNX 138 template <
typename T, data_layout L, El::Device D>
141 auto* eval = graph.add_node();
148 eval->set_op_type(
"Identity");
149 eval->set_domain(
"");
150 eval->set_doc_string(this->
get_type());
153 auto graph_output = graph.add_output();
154 graph_output->set_name(eval->output(0));
155 auto* graph_output_type = graph_output->mutable_type();
156 graph_output_type->mutable_tensor_type()->set_elem_type(
157 onnx::AttributeProto::FLOAT);
160 graph_output_type->mutable_tensor_type()->mutable_shape()->add_dim();
161 dims->set_dim_param(
"batch");
162 dims = graph_output_type->mutable_tensor_type()->mutable_shape()->add_dim();
163 dims->set_dim_value(1);
165 #endif // LBANN_HAS_ONNX 167 #ifndef LBANN_EVALUATION_LAYER_INSTANTIATE 168 #define PROTO(T) extern template class abstract_evaluation_layer<T> 170 #define LBANN_INSTANTIATE_CPU_HALF 171 #define LBANN_INSTANTIATE_GPU_HALF 174 #undef LBANN_INSTANTIATE_CPU_HALF 175 #undef LBANN_INSTANTIATE_GPU_HALF 177 #define PROTO_DEVICE(T, Device) \ 178 extern template class evaluation_layer<T, \ 179 data_layout::DATA_PARALLEL, \ 181 extern template class evaluation_layer<T, data_layout::MODEL_PARALLEL, Device> 185 #endif // LBANN_EVALUATION_LAYER_INSTANTIATE 189 #endif // LBANN_LAYER_EVALUATION_HPP_INCLUDED void set_scale(EvalType scale)
static abstract_evaluation_layer * construct(lbann_comm *comm, data_layout layout, El::Device device)
void setup_data(size_t max_mini_batch_size) override
Setup layer data. Called by the 'setup' function. Memory is allocated for distributed matrices...
data_layout get_data_layout() const override
Get data layout of the data tensors. We assume that the data layouts of the previous activations...
EvalType get_scale() const
abstract_evaluation_layer()
EvalType get_value(bool scaled=true)
void serialize(ArchiveT &ar)
Interface with objective function and metrics.
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
virtual void write_specific_proto(lbann_data::Layer &proto) const =0
Add layer specific data to prototext.
virtual std::string get_type() const =0
Get the layer type's name.
constexpr El::Device Device
std::string to_string(El::Device const &d)
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_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< const Layer * > get_parent_layers() const
std::string get_name() const
Get the layer instance's name.
Al::request m_allreduce_req
friend class cereal::access
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...
data_layout
Data layout that is optimized for different modes of parallelism.
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.
evaluation_layer * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...
size_t find_child_layer_index(const Layer &l) const
void bp_compute() override
Compute objective funciton gradients. Called by the 'back_prop' function. Given the input...
evaluation_layer(lbann_comm *comm)
TensorDataType EvalDataType
El::Matrix< EvalDataType, El::Device::CPU > CPUMatType
std::string get_type() const override
Get the layer type's name.