LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
debug_io.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.
25 //
26 // debug .hpp .cpp - Callback hooks to debug LBANN
28 
29 #ifndef LBANN_CALLBACKS_CALLBACK_DEBUG_IO_HPP_INCLUDED
30 #define LBANN_CALLBACKS_CALLBACK_DEBUG_IO_HPP_INCLUDED
31 
34 #include <chrono>
35 #include <vector>
36 
37 namespace lbann {
38 namespace callback {
39 
43 class debug_io : public callback_base
44 {
45 public:
52 
56  debug_io(execution_mode phase = execution_mode::invalid, int debug_lvl = 0)
57  : callback_base(1), m_debug_phase(phase), m_debug_lvl(debug_lvl)
58  {}
59  debug_io(const debug_io&) = default;
60  debug_io& operator=(const debug_io&) = default;
61  debug_io* copy() const override { return new debug_io(*this); }
63  void on_epoch_begin(model* m) override;
65  void on_forward_prop_begin(model* m, Layer* l) override;
66 
68  void on_validation_begin(model* m) override;
70  void on_evaluate_forward_prop_begin(model* m, Layer* l) override;
71 
73  void on_test_begin(model* m) override;
74 
78  void print_phase_start(model* m, execution_mode mode);
79 
80  std::string name() const override { return "debug_io"; }
81 
83 
86  template <class Archive>
87  void serialize(Archive& ar);
88 
90 
91 private:
93  void write_specific_proto(lbann_data::Callback& proto) const final;
94 
98 };
99 
100 // Builder function
101 std::unique_ptr<callback_base>
102 build_debug_io_callback_from_pbuf(const google::protobuf::Message&,
103  std::shared_ptr<lbann_summary> const&);
104 
105 } // namespace callback
106 } // namespace lbann
107 
108 #endif // LBANN_CALLBACKS_CALLBACK_DEBUG_IO_HPP_INCLUDED
debug_io(execution_mode phase=execution_mode::invalid, int debug_lvl=0)
Definition: debug_io.hpp:56
void on_forward_prop_begin(model *m, Layer *l) override
Interface with data reader.
virtual void on_evaluate_forward_prop_end(model *m)
Called when a model ends forward propagation for evaluation (validation / testing).
Definition: callback.hpp:183
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
debug_io * copy() const override
Definition: debug_io.hpp:61
void write_specific_proto(lbann_data::Callback &proto) const final
std::string name() const override
Return this callback&#39;s name.
Definition: debug_io.hpp:80
void print_fp_start(model *m, input_layer< DataType > *input)
Base class for callbacks during training/testing.
Definition: callback.hpp:76
std::unique_ptr< callback_base > build_debug_io_callback_from_pbuf(const google::protobuf::Message &, std::shared_ptr< lbann_summary > const &)
void on_evaluate_forward_prop_begin(model *m, Layer *l) override
Abstract base class for neural network models.
Definition: model.hpp:83
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
debug_io & operator=(const debug_io &)=default
execution_mode
Neural network execution mode.
Definition: base.hpp:229
void on_validation_begin(model *m) override
virtual void on_backward_prop_end(model *m)
Called when a model ends backward propagation.
Definition: callback.hpp:152
void on_epoch_begin(model *m) override
void serialize(Archive &ar)
Store state to archive for checkpoint and restart.
virtual void on_forward_prop_begin(model *m)
Called when a model begins forward propagation.
Definition: callback.hpp:140
void on_test_begin(model *m) override
void print_phase_start(model *m, execution_mode mode)
execution_mode m_debug_phase
Definition: debug_io.hpp:96