MLCompilerBridge
Tools for streamlining communication with ML models for compiler optimizations.
Loading...
Searching...
No Matches
Typedefs | Functions
ONNXModelRunner.h File Reference

This file defines the C APIs for ONNXModelRunner. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct ONNXModelRunner ONNXModelRunner
 
typedef struct Environment Environment
 
typedef signed Action
 

Functions

EnvironmentcreateEnvironment ()
 
void env_setDone (Environment *env)
 
void env_resetDone (Environment *env)
 
bool env_checkDone (Environment *env)
 
void env_setNumFeatures (Environment *env, int numFeatures)
 
void env_setStepFunc (Environment *env, float *(*stepFunc)(Action action))
 
void env_setResetFunc (Environment *env, float *(*resetFunc)())
 
void env_setNextAgent (Environment *env, char *agentName)
 
ONNXModelRunnercreateONNXModelRunner (Environment *env, int numAgents,...)
 
ONNXModelRunnercreateSingleAgentOMR (char *agent_path)
 
void evaluate (ONNXModelRunner *obj)
 
int singleAgentEvaluate (ONNXModelRunner *obj, float *inp, int inp_size)
 
void destroyEnvironment (Environment *env)
 
void destroyONNXModelRunner (ONNXModelRunner *obj)
 

Detailed Description

This file defines the C APIs for ONNXModelRunner.

This is a wrapper around the ONNXModelRunner class that provides an interface for the MLCompilerBridge to interact with the ONNX models during inference.

Usage for single agent:

  1. Create an ONNXModelRunner object using createSingleAgentOMR
  2. Evaluate the features using singleAgentEvaluate
  3. Destroy the instance of ONNXModelRunner using destroyONNXModelRunner

Usage for multiple agents:

  1. Create an Environment object using createEnvironment
  2. Set the number of features using env_setNumFeatures
  3. Set the step function using env_setStepFunc
  4. Set the reset function using env_setResetFunc
  5. Set the next agent using env_setNextAgent
  6. Create an ONNXModelRunner object using createONNXModelRunner
  7. Evaluate the features using evaluate
  8. Destroy the instance of ONNXModelRunner using destroyONNXModelRunner
  9. Destroy the instance of Environment using destroyEnvironment

Using Environment:

  1. Create an Environment object using createEnvironment
  2. Set the number of features using env_setNumFeatures
  3. Set the step function using env_setStepFunc
  4. Set the reset function using env_setResetFunc
  5. Set the next agent using env_setNextAgent
  6. Destroy the instance of Environment using destroyEnvironment after calling destroyONNXModelRunner.

Internally, the ONNXModelRunner will call the step function to get the next action and the reset function to reset the environment. The step function should return a pointer to an array of floats. The reset function should return a pointer to an array of floats.

Definition in file ONNXModelRunner.h.

Typedef Documentation

◆ Action

typedef signed Action

Definition at line 53 of file ONNXModelRunner.h.

◆ Environment

typedef struct Environment Environment

Definition at line 52 of file ONNXModelRunner.h.

◆ ONNXModelRunner

typedef struct ONNXModelRunner ONNXModelRunner

Definition at line 51 of file ONNXModelRunner.h.

Function Documentation

◆ createEnvironment()

Environment * createEnvironment ( )

Definition at line 81 of file ONNXModelRunnerCWrapper.cpp.

◆ createONNXModelRunner()

ONNXModelRunner * createONNXModelRunner ( Environment * env,
int numAgents,
... )

◆ createSingleAgentOMR()

ONNXModelRunner * createSingleAgentOMR ( char * agent_path)

Definition at line 124 of file ONNXModelRunnerCWrapper.cpp.

◆ destroyEnvironment()

void destroyEnvironment ( Environment * env)

◆ destroyONNXModelRunner()

void destroyONNXModelRunner ( ONNXModelRunner * obj)

◆ env_checkDone()

bool env_checkDone ( Environment * env)

◆ env_resetDone()

void env_resetDone ( Environment * env)

◆ env_setDone()

void env_setDone ( Environment * env)

◆ env_setNextAgent()

void env_setNextAgent ( Environment * env,
char * agentName )

◆ env_setNumFeatures()

void env_setNumFeatures ( Environment * env,
int numFeatures )

◆ env_setResetFunc()

void env_setResetFunc ( Environment * env,
float *(*)() resetFunc )

◆ env_setStepFunc()

void env_setStepFunc ( Environment * env,
float *(*)(Action action) stepFunc )

◆ evaluate()

void evaluate ( ONNXModelRunner * obj)

◆ singleAgentEvaluate()

int singleAgentEvaluate ( ONNXModelRunner * obj,
float * inp,
int inp_size )