53#ifndef LLVM_ANALYSIS_UTILS_TRAININGLOGGER_H
54#define LLVM_ANALYSIS_UTILS_TRAININGLOGGER_H
56#include "llvm/Config/llvm-config.h"
93 std::unique_ptr<raw_ostream> OS;
94 const std::vector<TensorSpec> FeatureSpecs;
96 const bool IncludeReward;
98 std::string CurrentContext;
100 void writeHeader(std::optional<TensorSpec> AdviceSpec);
102 OS->write(RawData,
Spec.getTotalTensorBufferSize());
104 LLVM_ABI void logRewardImpl(
const char *RawData);
114 const std::vector<TensorSpec> &FeatureSpecs,
115 const TensorSpec &RewardSpec,
bool IncludeReward,
116 std::optional<TensorSpec> AdviceSpec = std::nullopt);
132 return ObservationIDs.
contains(Ctx);
136 logRewardImpl(
reinterpret_cast<const char *
>(&
Value));
140 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.
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
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.