LLVM: include/llvm/Analysis/Utils/TrainingLogger.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53#ifndef LLVM_ANALYSIS_UTILS_TRAININGLOGGER_H
54#define LLVM_ANALYSIS_UTILS_TRAININGLOGGER_H
55
56#include "llvm/Config/llvm-config.h"
58
63
64#include
65#include
66#include
67
68namespace llvm {
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
93 std::unique_ptr<raw_ostream> OS;
94 const std::vector FeatureSpecs;
96 const bool IncludeReward;
98 std::string CurrentContext;
99
100 void writeHeader(std::optional AdviceSpec);
101 void writeTensor(const TensorSpec &Spec, const char *RawData) {
102 OS->write(RawData, Spec.getTotalTensorBufferSize());
103 }
104 LLVM_ABI void logRewardImpl(const char *RawData);
105
106public:
107
108
109
110
111
112
114 const std::vector &FeatureSpecs,
115 const TensorSpec &RewardSpec, bool IncludeReward,
116 std::optional AdviceSpec = std::nullopt);
117
121 void flush() { OS->flush(); }
122
123 const std::string ¤tContext() const { return CurrentContext; }
124
125
129
130
132 return ObservationIDs.contains(Ctx);
133 }
134
136 logRewardImpl(reinterpret_cast<const char *>(&Value));
137 }
138
140 writeTensor(FeatureSpecs[FeatureID], RawData);
141 }
142};
143
144}
145#endif
This file defines the StringMap class.
This file supports working with JSON data.
bool hasAnyObservationForContext(StringRef Ctx) const
Check if there is at least an observation for the context Ctx.
Definition TrainingLogger.h:131
LLVM_ABI void startObservation()
bool hasObservationInProgress() const
Check if there is at least an observation for currentContext().
Definition TrainingLogger.h:126
LLVM_ABI void switchContext(StringRef Name)
void logReward(T Value)
Definition TrainingLogger.h:135
LLVM_ABI void endObservation()
void logTensorValue(size_t FeatureID, const char *RawData)
Definition TrainingLogger.h:139
const std::string & currentContext() const
Definition TrainingLogger.h:123
void flush()
Definition TrainingLogger.h:121
LLVM_ABI Logger(std::unique_ptr< raw_ostream > OS, const std::vector< TensorSpec > &FeatureSpecs, const TensorSpec &RewardSpec, bool IncludeReward, std::optional< TensorSpec > AdviceSpec=std::nullopt)
Construct a Logger.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.