Utility for logging MLGO feature values and scalar rewards.
Declared in <llvm/Analysis/Utils/TrainingLogger.h>
class Logger final
Given an ordered specification of features, and assuming a scalar reward, allow logging feature values and rewards. The assumption is that, for an event to be logged (i.e. a set of feature values and a reward), the user calls the log* API for each feature exactly once, providing the index matching the position in the feature spec list provided at construction. The example assumes the first feature's element type is float, the second is int64, and the reward is float:
event 0: logFloatValue(0, ...) logInt64Value(1, ...) ... logFloatReward(...) event 1: logFloatValue(0, ...) logInt64Value(1, ...) ... logFloatReward(...)
At the end, call print to generate the log. Alternatively, don't call logReward at the end of each event, just log{Float|Int32|Int64}FinalReward at the end.
| Name | Description |
|---|---|
Logger [constructor] | Construct a Logger for streaming feature and reward values. |
currentContext | Return the name of the current logging context. |
endObservation | Finish the current observation. |
flush | Flush the underlying output stream. |
hasAnyObservationForContext | Check if there is at least an observation for the context Ctx. |
hasObservationInProgress | Check if there is at least an observation for currentContext(). |
logReward | Log a scalar reward value for the current observation. |
logTensorValue | Log the raw bytes of a feature tensor for the current observation. |
startObservation | Begin a new observation in the current context. |
switchContext | Switch the active logging context to Name. |