23 cl::desc(
"The InteractiveModelRunner will echo back to stderr "
24 "the data received from the host (for debugging purposes)."));
30 InputSpecs(Inputs), OutputSpec(Advice),
31 InEC(
sys::
fs::openFileForRead(InboundName, Inbound)),
32 OutputBuffer(OutputSpec.getTotalTensorBufferSize()) {
34 Ctx.emitError(
"Cannot open inbound file: " + InEC.message());
38 auto OutStream = std::make_unique<raw_fd_ostream>(OutboundName, OutEC);
40 Ctx.emitError(
"Cannot open outbound file: " + OutEC.message());
43 Log = std::make_unique<Logger>(std::move(OutStream), InputSpecs, Advice,
48 for (
size_t I = 0;
I < InputSpecs.size(); ++
I)
59 Log->startObservation();
60 for (
size_t I = 0;
I < InputSpecs.size(); ++
I)
62 Log->endObservation();
68 while (InsPoint < Limit) {
72 if (ReadOrErr.takeError()) {
73 Ctx.emitError(
"Failed reading from inbound file");
76 InsPoint += *ReadOrErr;
79 dbgs() << OutputSpec.name() <<
": "
81 return OutputBuffer.data();
static cl::opt< bool > DebugReply("interactive-model-runner-echo-reply", cl::init(false), cl::Hidden, cl::desc("The InteractiveModelRunner will echo back to stderr " "the data received from the host (for debugging purposes)."))
InteractiveModelRunner(LLVMContext &Ctx, const std::vector< TensorSpec > &Inputs, const TensorSpec &Advice, StringRef OutboundName, StringRef InboundName)
virtual ~InteractiveModelRunner()
This is an important class for using LLVM in a threaded context.
virtual void * evaluateUntyped()=0
void * getTensorUntyped(size_t Index)
void setUpBufferForTensor(size_t Index, const TensorSpec &Spec, void *Buffer)
MLModelRunner(const MLModelRunner &)=delete
StringRef - Represent a constant reference to a string, i.e.
initializer< Ty > init(const Ty &Val)
LLVM_ABI std::error_code closeFile(file_t &F)
Close the file object.
LLVM_ABI Expected< size_t > readNativeFile(file_t FileHandle, MutableArrayRef< char > Buf)
Reads Buf.size() bytes from FileHandle into Buf.
LLVM_ABI file_t convertFDToNativeFile(int FD)
Converts from a Posix file descriptor number to a native file handle.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI std::string tensorValueToString(const char *Buffer, const TensorSpec &Spec)
For debugging.