MLCompilerBridge
Tools for streamlining communication with ML models for compiler optimizations.
|
This class is used to create the grpc model runner object. More...
#include <gRPCModelRunner.h>
Public Member Functions | |
gRPCModelRunner (std::string server_address, grpc::Service *s, llvm::LLVMContext *Ctx=nullptr) | |
For server mode. | |
gRPCModelRunner (std::string server_address, Request *request, Response *response, llvm::LLVMContext *Ctx=nullptr) | |
For client mode. | |
void | requestExit () override |
Public Member Functions inherited from MLBridge::MLModelRunner | |
MLModelRunner (const MLModelRunner &)=delete | |
MLModelRunner & | operator= (const MLModelRunner &)=delete |
virtual | ~MLModelRunner ()=default |
template<typename T > | |
std::enable_if< std::is_fundamental< T >::value, T >::type | evaluate () |
Main user-facing method for interacting with the ML models. | |
template<typename T > | |
std::enable_if< std::is_fundamental< typenamestd::remove_pointer< T >::type >::value, void >::type | evaluate (T &data, size_t &dataSize) |
Main user-facing method for interacting with the ML models. | |
Kind | getKind () const |
SerDesKind | getSerDesKind () const |
template<typename U , typename T , typename... Types> | |
void | populateFeatures (const std::pair< U, T > &var1, const std::pair< U, Types > &...var2) |
User-facing interface for setting the features to be sent to the model. | |
template<typename U , typename T , typename... Types> | |
void | populateFeatures (const std::pair< U, T > &&var1, const std::pair< U, Types > &&...var2) |
void | populateFeatures () |
void | setRequest (void *request) |
Mainly used in the case of gRPC where the request object is not known explicitly. | |
void | setResponse (void *response) |
Mainly used in the case of gRPC where the response object is not known explicitly. | |
Private Member Functions | |
bool | isPortAvailable (std::string addr) |
checks whether a port number is available or not | |
void * | evaluateUntyped () override |
This method is used to send the request to the model and get the result. | |
int | RunService (grpc::Service *s) |
This method is used to create the server and start listening. | |
int | SetStub () |
This method is used to create the stub. Used in client mode. | |
Request * | getRequest () |
Response * | getResponse () |
void | printMessage (const google::protobuf::Message *message) |
Private Attributes | |
std::promise< void > * | exit_requested |
Stub * | stub_ |
std::string | server_address |
Request * | request |
Response * | response |
bool | server_mode |
Additional Inherited Members | |
Public Types inherited from MLBridge::MLModelRunner | |
enum class | Kind : int { Unknown , Pipe , gRPC , ONNX , TFAOT } |
Type of the MLModelRunner. More... | |
Protected Member Functions inherited from MLBridge::MLModelRunner | |
MLModelRunner (Kind Type, SerDesKind SerDesType, llvm::LLVMContext *Ctx=nullptr) | |
MLModelRunner (Kind Type, llvm::LLVMContext *Ctx=nullptr) | |
Protected Attributes inherited from MLBridge::MLModelRunner | |
llvm::LLVMContext * | Ctx |
const Kind | Type |
const SerDesKind | SerDesType |
std::unique_ptr< BaseSerDes > | SerDes |
This class is used to create the grpc model runner object.
grpc model runner requires service, stub, request and response objects to communicate with the model.
Definition at line 80 of file gRPCModelRunner.h.
|
inline |
For server mode.
Definition at line 83 of file gRPCModelRunner.h.
|
inline |
For client mode.
Definition at line 92 of file gRPCModelRunner.h.
|
inlineoverrideprivatevirtual |
This method is used to send the request to the model and get the result.
Used in only client mode during inference.
Implements MLBridge::MLModelRunner.
Definition at line 154 of file gRPCModelRunner.h.
|
inlineprivate |
Definition at line 248 of file gRPCModelRunner.h.
|
inlineprivate |
Definition at line 250 of file gRPCModelRunner.h.
|
inlineprivate |
checks whether a port number is available or not
Definition at line 112 of file gRPCModelRunner.h.
|
inlineprivate |
Definition at line 252 of file gRPCModelRunner.h.
|
inlineoverridevirtual |
Implements MLBridge::MLModelRunner.
Definition at line 100 of file gRPCModelRunner.h.
|
inlineprivate |
This method is used to create the server and start listening.
Used in server mode.
Definition at line 220 of file gRPCModelRunner.h.
|
inlineprivate |
This method is used to create the stub. Used in client mode.
Definition at line 240 of file gRPCModelRunner.h.
|
private |
Definition at line 150 of file gRPCModelRunner.h.
|
private |
Definition at line 214 of file gRPCModelRunner.h.
|
private |
Definition at line 215 of file gRPCModelRunner.h.
|
private |
Definition at line 213 of file gRPCModelRunner.h.
|
private |
Definition at line 216 of file gRPCModelRunner.h.
|
private |
Definition at line 212 of file gRPCModelRunner.h.