53#ifndef LLVM_ANALYSIS_UTILS_TRAININGLOGGER_H
54#define LLVM_ANALYSIS_UTILS_TRAININGLOGGER_H
56#include "llvm/Config/llvm-config.h"
94 std::unique_ptr<raw_ostream> OS;
95 const std::vector<TensorSpec> FeatureSpecs;
97 const bool IncludeReward;
99 std::string CurrentContext;
101 void writeHeader(std::optional<TensorSpec> AdviceSpec);
103 OS->write(RawData,
Spec.getTotalTensorBufferSize());
105 LLVM_ABI void logRewardImpl(
const char *RawData);
115 const std::vector<TensorSpec> &FeatureSpecs,
116 const TensorSpec &RewardSpec,
bool IncludeReward,
117 std::optional<TensorSpec> AdviceSpec = std::nullopt);
133 return ObservationIDs.contains(Ctx);
137 logRewardImpl(
reinterpret_cast<const char *
>(&
Value));
141 writeTensor(FeatureSpecs[FeatureID], RawData);
150 return (
"{__unnamed_" +
Twine(
Number) +
"}").str();
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.
LLVM_ABI void startObservation()
bool hasObservationInProgress() const
Check if there is at least an observation for currentContext().
LLVM_ABI void switchContext(StringRef Name)
LLVM_ABI void endObservation()
void logTensorValue(size_t FeatureID, const char *RawData)
const std::string & currentContext() const
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",...
Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
std::string getLoggerContextName(StringRef Name, unsigned Number)
Context name for Name.