LLVM 20.0.0git
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::MLModelRunner Class Referenceabstract

MLModelRunner interface: abstraction of a mechanism for evaluating a ML model. More...

#include "llvm/Analysis/MLModelRunner.h"

Inheritance diagram for llvm::MLModelRunner:
Inheritance graph
[legend]

Public Types

enum class  Kind : int {
  Unknown , Release , Development , NoOp ,
  Interactive
}
 

Public Member Functions

 MLModelRunner (const MLModelRunner &)=delete
 
MLModelRunneroperator= (const MLModelRunner &)=delete
 
virtual ~MLModelRunner ()=default
 
template<typename T >
T evaluate ()
 
template<typename T , typename I >
TgetTensor (I FeatureID)
 
template<typename T , typename I >
const TgetTensor (I FeatureID) const
 
void * getTensorUntyped (size_t Index)
 
const void * getTensorUntyped (size_t Index) const
 
Kind getKind () const
 
virtual void switchContext (StringRef Name)
 

Protected Member Functions

 MLModelRunner (LLVMContext &Ctx, Kind Type, size_t NrInputs)
 
virtual void * evaluateUntyped ()=0
 
void setUpBufferForTensor (size_t Index, const TensorSpec &Spec, void *Buffer)
 

Protected Attributes

LLVMContextCtx
 
const Kind Type
 

Detailed Description

MLModelRunner interface: abstraction of a mechanism for evaluating a ML model.

More abstractly, evaluating a function that has as tensors as arguments, described via TensorSpecs, and returns a tensor. Currently, the latter is assumed to be a scalar, in absence of more elaborate scenarios. NOTE: feature indices are expected to be consistent all accross MLModelRunners (pertaining to the same model), and also Loggers (see TFUtils.h)

Definition at line 26 of file MLModelRunner.h.

Member Enumeration Documentation

◆ Kind

enum class llvm::MLModelRunner::Kind : int
strong
Enumerator
Unknown 
Release 
Development 
NoOp 
Interactive 

Definition at line 52 of file MLModelRunner.h.

Constructor & Destructor Documentation

◆ MLModelRunner() [1/2]

llvm::MLModelRunner::MLModelRunner ( const MLModelRunner )
delete

◆ ~MLModelRunner()

virtual llvm::MLModelRunner::~MLModelRunner ( )
virtualdefault

◆ MLModelRunner() [2/2]

llvm::MLModelRunner::MLModelRunner ( LLVMContext Ctx,
Kind  Type,
size_t  NrInputs 
)
inlineprotected

Definition at line 57 of file MLModelRunner.h.

References assert(), and Unknown.

Member Function Documentation

◆ evaluate()

template<typename T >
T llvm::MLModelRunner::evaluate ( )
inline

Definition at line 33 of file MLModelRunner.h.

References evaluateUntyped().

Referenced by llvm::MLPriorityAdvisor::getPriorityImpl().

◆ evaluateUntyped()

virtual void * llvm::MLModelRunner::evaluateUntyped ( )
protectedpure virtual

Referenced by evaluate().

◆ getKind()

Kind llvm::MLModelRunner::getKind ( ) const
inline

Definition at line 53 of file MLModelRunner.h.

References Type.

◆ getTensor() [1/2]

template<typename T , typename I >
T * llvm::MLModelRunner::getTensor ( I  FeatureID)
inline

◆ getTensor() [2/2]

template<typename T , typename I >
const T * llvm::MLModelRunner::getTensor ( I  FeatureID) const
inline

Definition at line 42 of file MLModelRunner.h.

References getTensorUntyped().

◆ getTensorUntyped() [1/2]

void * llvm::MLModelRunner::getTensorUntyped ( size_t  Index)
inline

Definition at line 47 of file MLModelRunner.h.

Referenced by getTensor().

◆ getTensorUntyped() [2/2]

const void * llvm::MLModelRunner::getTensorUntyped ( size_t  Index) const
inline

Definition at line 48 of file MLModelRunner.h.

◆ operator=()

MLModelRunner & llvm::MLModelRunner::operator= ( const MLModelRunner )
delete

◆ setUpBufferForTensor()

void llvm::MLModelRunner::setUpBufferForTensor ( size_t  Index,
const TensorSpec Spec,
void *  Buffer 
)
inlineprotected

◆ switchContext()

virtual void llvm::MLModelRunner::switchContext ( StringRef  Name)
inlinevirtual

Reimplemented in llvm::InteractiveModelRunner.

Definition at line 54 of file MLModelRunner.h.

Referenced by llvm::MLPriorityAdvisor::MLPriorityAdvisor().

Member Data Documentation

◆ Ctx

LLVMContext& llvm::MLModelRunner::Ctx
protected

◆ Type

const Kind llvm::MLModelRunner::Type
protected

Definition at line 73 of file MLModelRunner.h.

Referenced by getKind().


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