Skip to content

Commit

Permalink
ONNX dump features
Browse files Browse the repository at this point in the history
  • Loading branch information
RaghulPS32 committed Feb 17, 2024
1 parent d03a012 commit 11c6f60
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions MLModelRunner/ONNXModelRunner/ONNXModelRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
//===----------------------------------------------------------------------===//

#include "MLModelRunner/ONNXModelRunner/ONNXModelRunner.h"
//#include "MLModelRunner/MLModelRunner.h"
#include "MLModelRunner/MLModelRunner.h"
#include "SerDes/baseSerDes.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;
namespace MLBridge {
Expand All @@ -34,14 +37,25 @@ void ONNXModelRunner::addAgent(Agent *agent, std::string name) {
}
}

void passAgentInfo(std::string mode, std::string agentName, int action) {
std::error_code EC;
llvm::raw_fd_ostream fileStream("test-raw.txt", EC, llvm::sys::fs::OF_Append);
fileStream << mode << ": " << agentName << ": " << action << "\n";
}

void ONNXModelRunner::computeAction(Observation &obs) {
//std::error_code EC;
//llvm::raw_fd_ostream fileStream("test-raw.txt", EC, llvm::sys::fs::OF_Append);
while (true) {
Action action;
// current agent
auto current_agent = this->agents[this->env->getNextAgent()];
action = current_agent->computeAction(obs);
passAgentInfo("input", this->env->getNextAgent(), action);
this->env->step(action);

if (this->env->checkDone()) {
passAgentInfo("output", this->env->getNextAgent(), action);
std::cout << "Done🎉\n";
break;
}
Expand Down

0 comments on commit 11c6f60

Please sign in to comment.