MLCompilerBridge
Tools for streamlining communication with ML models for compiler optimizations.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
MLBridge::TFModelRunner< TGen > Class Template Referencefinal

TFModelRunner - TF Compiled model implementation of the MLModelRunner. More...

#include <TFModelRunner.h>

Inheritance diagram for MLBridge::TFModelRunner< TGen >:
Inheritance graph
[legend]
Collaboration diagram for MLBridge::TFModelRunner< TGen >:
Collaboration graph
[legend]

Public Member Functions

 TFModelRunner (llvm::StringRef DecisionName, llvm::LLVMContext &Ctx, llvm::StringRef FeedPrefix="feed_", llvm::StringRef FetchPrefix="fetch_")
 FeatureNames' type should be an indexed collection of std::string, like std::array or std::vector, that has a size() method.
 
 TFModelRunner (llvm::StringRef DecisionName, llvm::StringRef FeedPrefix="feed_", llvm::StringRef FetchPrefix="fetch_")
 
virtual ~TFModelRunner ()=default
 
virtual void requestExit () override
 
- Public Member Functions inherited from MLBridge::MLModelRunner
 MLModelRunner (const MLModelRunner &)=delete
 
MLModelRunneroperator= (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.
 

Static Public Member Functions

static bool classof (const MLModelRunner *R)
 

Private Member Functions

void * evaluateUntyped () override
 Should be implemented by the derived class to call the model and get the result.
 

Private Attributes

int32_t ResultIndex = -1
 
std::unique_ptr< TGen > CompiledModel
 

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< BaseSerDesSerDes
 

Detailed Description

template<class TGen>
class MLBridge::TFModelRunner< TGen >

TFModelRunner - TF Compiled model implementation of the MLModelRunner.

It uses an AOT-compiled SavedModel for efficient execution.

Definition at line 30 of file TFModelRunner.h.

Constructor & Destructor Documentation

◆ TFModelRunner() [1/2]

template<class TGen >
MLBridge::TFModelRunner< TGen >::TFModelRunner ( llvm::StringRef DecisionName,
llvm::LLVMContext & Ctx,
llvm::StringRef FeedPrefix = "feed_",
llvm::StringRef FetchPrefix = "fetch_" )
inline

FeatureNames' type should be an indexed collection of std::string, like std::array or std::vector, that has a size() method.

Definition at line 34 of file TFModelRunner.h.

◆ TFModelRunner() [2/2]

template<class TGen >
MLBridge::TFModelRunner< TGen >::TFModelRunner ( llvm::StringRef DecisionName,
llvm::StringRef FeedPrefix = "feed_",
llvm::StringRef FetchPrefix = "fetch_" )
inline

Definition at line 48 of file TFModelRunner.h.

◆ ~TFModelRunner()

template<class TGen >
virtual MLBridge::TFModelRunner< TGen >::~TFModelRunner ( )
virtualdefault

Member Function Documentation

◆ classof()

template<class TGen >
static bool MLBridge::TFModelRunner< TGen >::classof ( const MLModelRunner * R)
inlinestatic

Definition at line 68 of file TFModelRunner.h.

◆ evaluateUntyped()

template<class TGen >
void * MLBridge::TFModelRunner< TGen >::evaluateUntyped ( )
inlineoverrideprivatevirtual

Should be implemented by the derived class to call the model and get the result.

Implements MLBridge::MLModelRunner.

Definition at line 73 of file TFModelRunner.h.

◆ requestExit()

template<class TGen >
virtual void MLBridge::TFModelRunner< TGen >::requestExit ( )
inlineoverridevirtual

Implements MLBridge::MLModelRunner.

Definition at line 64 of file TFModelRunner.h.

Member Data Documentation

◆ CompiledModel

template<class TGen >
std::unique_ptr<TGen> MLBridge::TFModelRunner< TGen >::CompiledModel
private

Definition at line 79 of file TFModelRunner.h.

◆ ResultIndex

template<class TGen >
int32_t MLBridge::TFModelRunner< TGen >::ResultIndex = -1
private

Definition at line 78 of file TFModelRunner.h.


The documentation for this class was generated from the following file: