MLCompilerBridge
Tools for streamlining communication with ML models for compiler optimizations.
Loading...
Searching...
No Matches
environment.h
Go to the documentation of this file.
1//=== MLModelRunner/ONNXModelRunner/environment.h - ONNX Environment 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//===---------------------------------------------------------------------===//
45//===----------------------------------------------------------------------===//
46
47#ifndef ONNX_MODELRUNNER_ENVIRONMENT_H
48#define ONNX_MODELRUNNER_ENVIRONMENT_H
49
51#include <map>
52
53typedef signed Action;
54
55namespace MLBridge {
57 bool done = false;
58 std::string nextAgent = "";
59
60protected:
61 std::map<std::string, Observation &> obsMap;
62
63public:
66 bool checkDone() { return done == true; };
67
69 void setDone() { done = true; }
70 void resetDone() { done = false; }
71
73 std::string getNextAgent() { return nextAgent; };
74
76 void setNextAgent(std::string name) { nextAgent = name; }
77
83 virtual Observation &step(Action action) = 0;
84
88 virtual Observation &reset() = 0;
89};
90} // namespace MLBridge
91#endif // ONNX_MODELRUNNER_ENVIRONMENT_H
signed Action
Agent class to support ML/RL model inference via ONNX.
std::map< std::string, Observation & > obsMap
Definition environment.h:61
void setDone()
SetDone sets the termination condition to true.
Definition environment.h:69
bool checkDone()
CheckDone returns true if the termination condition is met at the end of the episode.
Definition environment.h:66
void setNextAgent(std::string name)
SetNextAgent sets the name of the next agent to interact with.
Definition environment.h:76
virtual Observation & step(Action action)=0
Step function takes an action as input and returns the observation corresponding to the next state.
virtual Observation & reset()=0
Reset function returns the initial observation.
std::string nextAgent
Definition environment.h:58
std::string getNextAgent()
GetNextAgent returns the name/ID of the next agent to interact with.
Definition environment.h:73
signed Action
Definition environment.h:53
llvm::SmallVector< float, 300 > Observation
Definition utils.h:15