LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
debug.hpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2023, Lawrence Livermore National Security, LLC.
3 // Produced at the Lawrence Livermore National Laboratory.
4 // Written by the LBANN Research Team (B. Van Essen, et al.) listed in
5 // the CONTRIBUTORS file. <lbann-dev@llnl.gov>
6 //
7 // LLNL-CODE-697807.
8 // All rights reserved.
9 //
10 // This file is part of LBANN: Livermore Big Artificial Neural Network
11 // Toolkit. For details, see http://software.llnl.gov/LBANN or
12 // https://github.com/LLNL/LBANN.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "Licensee"); you
15 // may not use this file except in compliance with the License. You may
16 // obtain a copy of the License at:
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
23 // implied. See the License for the specific language governing
24 // permissions and limitations under the license.
26 
27 #ifndef LBANN_CALLBACKS_CALLBACK_DEBUG_HPP_INCLUDED
28 #define LBANN_CALLBACKS_CALLBACK_DEBUG_HPP_INCLUDED
29 
31 
32 #include <set>
33 
34 namespace lbann {
35 namespace callback {
36 
47 class debug : public callback_base
48 {
49 public:
55  debug(std::set<execution_mode> modes = {}) : m_modes(std::move(modes)) {}
56  debug(const debug&) = default;
57  debug& operator=(const debug&) = default;
58  debug* copy() const override { return new debug(*this); }
59  std::string name() const override { return "debug"; }
60 
62  void on_batch_begin(model* m) override;
64  void on_batch_end(model* m) override;
66  void on_batch_evaluate_begin(model* m) override;
68  void on_batch_evaluate_end(model* m) override;
69 
76 
78  void on_forward_prop_begin(model* m, Layer* l) override;
80  void on_forward_prop_end(model* m, Layer* l) override;
82  void on_backward_prop_begin(model* m, Layer* l) override;
84  void on_backward_prop_end(model* m, Layer* l) override;
86  void on_evaluate_forward_prop_begin(model* m, Layer* l) override;
88  void on_evaluate_forward_prop_end(model* m, Layer* l) override;
89 
91  void on_optimize_begin(model* m, weights* w) override;
93  void on_optimize_end(model* m, weights* w) override;
94 
96 
99  template <class Archive>
100  void serialize(Archive& ar);
101 
103 
104 private:
106  void write_specific_proto(lbann_data::Callback& proto) const final;
107 
112  std::set<execution_mode> m_modes;
113 };
114 
115 // Builder function
116 std::unique_ptr<callback_base>
117 build_debug_callback_from_pbuf(const google::protobuf::Message&,
118  std::shared_ptr<lbann_summary> const&);
119 
120 } // namespace callback
121 } // namespace lbann
122 
123 #endif // LBANN_CALLBACKS_CALLBACK_DEBUG_HPP_INCLUDED
virtual void on_evaluate_forward_prop_end(model *m)
Called when a model ends forward propagation for evaluation (validation / testing).
Definition: callback.hpp:183
void write_specific_proto(lbann_data::Callback &proto) const final
std::string name() const override
Return this callback&#39;s name.
Definition: debug.hpp:59
void on_backward_prop_end(model *m, Layer *l) override
Print that a layer&#39;s backward prop is ending.
Phase specific "printf debugging".
Definition: debug.hpp:47
Neural network tensor operation.
Definition: layer.hpp:285
virtual void on_backward_prop_begin(model *m)
Called when a model begins backward propagation.
Definition: callback.hpp:148
void on_batch_evaluate_end(model *m) override
Print that a layer&#39;s forward prop is ending.
void on_optimize_end(model *m, weights *w) override
Print that a weights&#39; optimization step is ending.
debug * copy() const override
Definition: debug.hpp:58
Base class for callbacks during training/testing.
Definition: callback.hpp:76
void on_batch_evaluate_begin(model *m) override
Print that a layer&#39;s forward prop is beginning.
Abstract base class for neural network models.
Definition: model.hpp:83
void serialize(Archive &ar)
Store state to archive for checkpoint and restart.
void on_forward_prop_end(model *m, Layer *l) override
Print that a layer&#39;s forward prop is ending.
virtual void on_evaluate_forward_prop_begin(model *m)
Called when a model begins forward propagation for evaluation (validation / testing).
Definition: callback.hpp:175
virtual void on_forward_prop_end(model *m)
Called when a model ends forward propagation.
Definition: callback.hpp:144
void on_evaluate_forward_prop_begin(model *m, Layer *l) override
Print that a layer&#39;s backward prop is beginning.
void on_backward_prop_begin(model *m, Layer *l) override
Print that a layer&#39;s backward prop is beginning.
debug(std::set< execution_mode > modes={})
Constructor.
Definition: debug.hpp:55
void on_batch_end(model *m) override
Print that a batch is ending.
void on_evaluate_forward_prop_end(model *m, Layer *l) override
Print that a layer&#39;s backward prop is ending.
std::set< execution_mode > m_modes
Execution modes for which status updates will be printed.
Definition: debug.hpp:112
std::unique_ptr< callback_base > build_debug_callback_from_pbuf(const google::protobuf::Message &, std::shared_ptr< lbann_summary > const &)
virtual void on_backward_prop_end(model *m)
Called when a model ends backward propagation.
Definition: callback.hpp:152
debug & operator=(const debug &)=default
void on_forward_prop_begin(model *m, Layer *l) override
Print that a layer&#39;s forward prop is beginning.
virtual void on_forward_prop_begin(model *m)
Called when a model begins forward propagation.
Definition: callback.hpp:140
void on_batch_begin(model *m) override
Print that a batch is beginning.
void on_optimize_begin(model *m, weights *w) override
Print that a weights&#39; optimization step is beginning.