LLVM 20.0.0git
|
A MLModelRunner that asks for advice from an external agent, or host. More...
#include "llvm/Analysis/InteractiveModelRunner.h"
Public Member Functions | |
InteractiveModelRunner (LLVMContext &Ctx, const std::vector< TensorSpec > &Inputs, const TensorSpec &Advice, StringRef OutboundName, StringRef InboundName) | |
void | switchContext (StringRef Name) override |
virtual | ~InteractiveModelRunner () |
Public Member Functions inherited from llvm::MLModelRunner | |
MLModelRunner (const MLModelRunner &)=delete | |
MLModelRunner & | operator= (const MLModelRunner &)=delete |
virtual | ~MLModelRunner ()=default |
template<typename T > | |
T | evaluate () |
template<typename T , typename I > | |
T * | getTensor (I FeatureID) |
template<typename T , typename I > | |
const T * | getTensor (I FeatureID) const |
void * | getTensorUntyped (size_t Index) |
const void * | getTensorUntyped (size_t Index) const |
Kind | getKind () const |
virtual void | switchContext (StringRef Name) |
Static Public Member Functions | |
static bool | classof (const MLModelRunner *R) |
Additional Inherited Members | |
Public Types inherited from llvm::MLModelRunner | |
enum class | Kind : int { Unknown , Release , Development , NoOp , Interactive } |
Protected Member Functions inherited from llvm::MLModelRunner | |
MLModelRunner (LLVMContext &Ctx, Kind Type, size_t NumInputs) | |
virtual void * | evaluateUntyped ()=0 |
void | setUpBufferForTensor (size_t Index, const TensorSpec &Spec, void *Buffer) |
Protected Attributes inherited from llvm::MLModelRunner | |
LLVMContext & | Ctx |
const Kind | Type |
A MLModelRunner that asks for advice from an external agent, or host.
It uses 2 files - ideally named pipes - one to send data to that agent, and one to receive advice. The data exchange uses the training logger (Utils/TrainingLogger.h) format. Specifically, the compiler will send the log header, set the context, and send observations; the host is expected to reply with a tensor value after each observation as a binary buffer that's conforming to the shape of the advice. Interleaved, the data closely resembles the training log for a log where we don't capture the reward signal.
Note that the correctness of the received data is the responsibility of the host. In particular, if insufficient data were sent, the compiler will block when waiting for an advice.
Note that the host can either open the pipes RW, or open first the pipe to the compiler - i.e. the "Inbound" - and then the "Outbound", to avoid deadlock. This is because the compiler first tries to open the inbound (which will hang until there's a writer on the other end).
Definition at line 38 of file InteractiveModelRunner.h.
InteractiveModelRunner::InteractiveModelRunner | ( | LLVMContext & | Ctx, |
const std::vector< TensorSpec > & | Inputs, | ||
const TensorSpec & | Advice, | ||
StringRef | OutboundName, | ||
StringRef | InboundName | ||
) |
Definition at line 26 of file InteractiveModelRunner.cpp.
References llvm::MLModelRunner::Ctx, llvm::LLVMContext::emitError(), I, llvm::MLModelRunner::setUpBufferForTensor(), and llvm::size().
|
virtual |
Definition at line 53 of file InteractiveModelRunner.cpp.
References llvm::sys::fs::closeFile(), and llvm::sys::fs::convertFDToNativeFile().
|
inlinestatic |
Definition at line 45 of file InteractiveModelRunner.h.
References llvm::MLModelRunner::Interactive.
|
inlineoverridevirtual |
Reimplemented from llvm::MLModelRunner.
Definition at line 48 of file InteractiveModelRunner.h.
References Name.