ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::exec::JSON Class Reference

#include <JSONExecTime.h>

Public Member Functions

 JSON (const std::vector< const backend::Backend * > &backends, MeasurementData &measurements)
 
void storeOperationsExecTime () const
 Update _measurement_file with new data.
 

Detailed Description

Definition at line 43 of file JSONExecTime.h.

Constructor & Destructor Documentation

◆ JSON()

onert::exec::JSON::JSON ( const std::vector< const backend::Backend * > &  backends,
MeasurementData measurements 
)
inlineexplicit

Definition at line 46 of file JSONExecTime.h.

48 : _measurement_file("exec_time.json"), _backends(), _measurements(measurements)
49 {
50 for (const auto b : backends)
51 {
52 _backends.emplace(b->config()->id(), b);
53 }
54 loadOperationsExecTime();
55 };

Member Function Documentation

◆ storeOperationsExecTime()

void onert::exec::JSON::storeOperationsExecTime ( ) const

Update _measurement_file with new data.

Definition at line 139 of file JSONExecTime.cc.

140{
141 std::ofstream stream(_measurement_file);
142 if (!stream.is_open())
143 {
144 throw std::runtime_error("Failed to save backend config file");
145 }
146 else
147 {
148 stream << "{";
149 for (const auto &[backend, op_map] : _measurements)
150 {
151 printString(backend->config()->id(), stream);
152 stream << ": {";
153 for (const auto &[op_name, quant_map] : op_map)
154 {
155 printString(op_name, stream);
156 stream << ": {";
157 for (const auto &[is_quant, op_time_info_map] : quant_map)
158 {
159 printBool(is_quant, stream);
160 stream << ": [";
161 printOperation(op_time_info_map, stream);
162 stream << "], ";
163 }
164 stream.seekp(-2, std::ofstream::end);
165 stream << "}, ";
166 }
167 stream.seekp(-2, std::ofstream::end);
168 stream << "}, ";
169 }
170 stream.seekp(-2, std::ofstream::end);
171 stream << "}";
172 stream.close();
173 }
174}
void printString(const std::string &str, std::ofstream &stream)
void printBool(bool quant, std::ofstream &stream)

References onert::exec::printBool(), and onert::exec::printString().

Referenced by onert::exec::ExecTime::storeOperationsExecTime().


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