MLCompilerBridge
Tools for streamlining communication with ML models for compiler optimizations.
Loading...
Searching...
No Matches
PipeModelRunner.h
Go to the documentation of this file.
1//===- PipeModelRunner.h ---- PipeModelRunner ------*- C++ -*-------------===//
2//
3// Part of the MLCompilerBridge Project, under the Apache License v2.0 with LLVM
4// Exceptions. See the LICENSE file for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7// (Preliminary version adopted from InteractiveModelRunner.h of LLVM 17.X)
8//
9//===----------------------------------------------------------------------===//
24//===----------------------------------------------------------------------===//
25
26#ifndef PipeModelRunner_H
27#define PipeModelRunner_H
28
30#include "SerDes/TensorSpec.h"
31#include "SerDes/baseSerDes.h"
32#include "llvm/Support/FileSystem.h"
33#include <fstream>
34#include <memory>
35#include <system_error>
36
37namespace MLBridge {
38
56public:
57 PipeModelRunner(llvm::StringRef OutboundName, llvm::StringRef InboundName,
58 SerDesKind Kind, llvm::LLVMContext *Ctx = nullptr);
59
60 static bool classof(const MLModelRunner *R) {
62 }
63
64 void requestExit() override {}
65 virtual ~PipeModelRunner();
66
67private:
68 void send(void *data);
69 void *receive();
70 void *evaluateUntyped() override;
71 std::string readNBytes(size_t N);
72 // This must be declared before InEC if we want to initialize it in the
73 // ctor initializer list.
74 std::string InboundName;
75 int Inbound = -1;
76 std::error_code OutEC;
77 std::error_code InEC;
78 std::unique_ptr<llvm::raw_fd_ostream> OutStream;
79};
80} // namespace MLBridge
81#endif // PipeModelRunner_H
The MLModelRunner class is the main interface for interacting with the ML models.
Supporting new SerDes:
MLModelRunner - The main interface for interacting with the ML models.
Kind
Type of the MLModelRunner.
llvm::LLVMContext * Ctx
A MLModelRunner that asks for advice from an external agent, or host.
std::string readNBytes(size_t N)
std::unique_ptr< llvm::raw_fd_ostream > OutStream
PipeModelRunner(llvm::StringRef OutboundName, llvm::StringRef InboundName, SerDesKind Kind, llvm::LLVMContext *Ctx=nullptr)
static bool classof(const MLModelRunner *R)
void * evaluateUntyped() override
Should be implemented by the derived class to call the model and get the result.
SerDesKind
This is the base class for SerDes.
Definition baseSerDes.h:46