LBANN
0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
execution_context.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_EXECUTION_ALGORITHMS_EXECUTION_CONTEXT_HPP_INCLUDED
28
#define LBANN_EXECUTION_ALGORITHMS_EXECUTION_CONTEXT_HPP_INCLUDED
29
30
#include "
lbann/base.hpp
"
31
32
#include <memory>
33
#include <string>
34
35
// Forward declaration
36
namespace
cereal
{
37
class
access;
38
}
39
40
namespace
lbann
{
41
42
// Forward-declare this.
43
class
persist;
44
class
trainer;
45
class
TrainingAlgorithm;
46
47
class
ExecutionContext
48
{
49
public
:
51
ExecutionContext
();
52
54
virtual
~
ExecutionContext
() =
default
;
55
57
virtual
std::unique_ptr<ExecutionContext> get_new()
const
= 0;
58
63
virtual
std::string get_type()
const
= 0;
64
66
virtual
std::string get_state_string()
const
noexcept = 0;
67
68
virtual
execution_mode
get_execution_mode
() const noexcept
69
{
70
return
execution_mode::invalid;
71
}
72
77
size_t
get_step
() const noexcept {
return
m_step; }
78
83
void
inc_step
() noexcept { ++m_step; }
84
86
89
template
<
class
Archive>
90
void
serialize
(Archive& ar);
91
93
virtual
void
save_to_checkpoint_shared(
persist
& p) = 0;
95
virtual
void
load_from_checkpoint_shared(
persist
& p) = 0;
97
virtual
void
save_to_checkpoint_distributed(
persist
& p) = 0;
99
virtual
void
load_from_checkpoint_distributed(
persist
& p) = 0;
101
102
protected
:
103
friend
class
cereal::access;
105
ExecutionContext
(
const
ExecutionContext
& other) =
delete
;
107
ExecutionContext
& operator=(
const
ExecutionContext
& other) =
delete
;
109
ExecutionContext
(
ExecutionContext
&& other) =
default
;
111
ExecutionContext
& operator=(
ExecutionContext
&& other) =
default
;
112
113
private
:
118
size_t
m_step = 0UL;
119
};
120
127
class
TerminationCriteria
128
{
129
public
:
130
TerminationCriteria
() =
default
;
131
virtual
~
TerminationCriteria
() =
default
;
132
virtual
bool
operator()(
ExecutionContext
const
& c)
const
= 0;
133
};
134
135
}
// namespace lbann
136
137
#endif // LBANN_EXECUTION_ALGORITHMS_EXECUTION_CONTEXT_HPP_INCLUDED
lbann::ExecutionContext::get_execution_mode
virtual execution_mode get_execution_mode() const noexcept
Definition:
execution_context.hpp:68
lbann::ExecutionContext::inc_step
void inc_step() noexcept
Increment the current step in the training algorithm.
Definition:
execution_context.hpp:83
lbann::protobuf::serialize
void serialize(std::ostream &os, google::protobuf::Message const &msg)
Serialize the protobuf message to a stream.
lbann::TerminationCriteria
Specifies when to stop a training algorithm.
Definition:
execution_context.hpp:127
cereal
Definition:
callback.hpp:56
base.hpp
lbann::execution_mode
execution_mode
Neural network execution mode.
Definition:
base.hpp:229
lbann::ExecutionContext
Definition:
execution_context.hpp:47
lbann::ExecutionContext::get_step
size_t get_step() const noexcept
Current step in the training algorithm.
Definition:
execution_context.hpp:77
lbann
Definition:
callback_helpers.hpp:32
lbann::persist
Definition:
persist.hpp:72
include
lbann
execution_algorithms
execution_context.hpp
Generated on Wed Oct 11 2023 20:49:37 for LBANN by
1.8.13