53#ifndef LLVM_ANALYSIS_UTILS_TRAININGLOGGER_H
54#define LLVM_ANALYSIS_UTILS_TRAININGLOGGER_H
56#include "llvm/Config/llvm-config.h"
92 std::unique_ptr<raw_ostream> OS;
93 const std::vector<TensorSpec> FeatureSpecs;
95 const bool IncludeReward;
97 std::string CurrentContext;
99 void writeHeader(std::optional<TensorSpec> AdviceSpec);
101 OS->write(RawData,
Spec.getTotalTensorBufferSize());
103 void logRewardImpl(
const char *RawData);
112 Logger(std::unique_ptr<raw_ostream>
OS,
113 const std::vector<TensorSpec> &FeatureSpecs,
114 const TensorSpec &RewardSpec,
bool IncludeReward,
115 std::optional<TensorSpec> AdviceSpec = std::nullopt);
131 return ObservationIDs.
contains(Ctx);
135 logRewardImpl(
reinterpret_cast<const char *
>(&
Value));
139 writeTensor(FeatureSpecs[FeatureID], RawData);
This file defines the StringMap class.
This file supports working with JSON data.
Logging utility - given an ordered specification of features, and assuming a scalar reward,...
bool hasAnyObservationForContext(StringRef Ctx) const
Check if there is at least an observation for the context Ctx.
bool hasObservationInProgress() const
Check if there is at least an observation for currentContext().
void switchContext(StringRef Name)
void logTensorValue(size_t FeatureID, const char *RawData)
const std::string & currentContext() const
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
bool contains(StringRef Key) const
contains - Return true if the element is in the map, false otherwise.
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.