Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onert] Create minmax dump file in handleSubgraphEnd #13170

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions runtime/onert/core/src/exec/MinMaxRecorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/

#include "MinMaxRecorder.h"

#if MINMAX_H5DUMPER
#include "../dumper/h5/MinMaxDumper.h"
#else
#include "MinMaxData.h"
#endif
#include "backend/ITensor.h"

#include <cassert>
Expand All @@ -28,12 +32,9 @@ namespace exec

MinMaxRecorder::MinMaxRecorder(const std::string &workspace_dir, const ir::Graph &graph,
const backend::BackendContexts &backend_contexts)
#if MINMAX_H5DUMPER
: _graph{graph}, _backend_contexts{backend_contexts}, _h5dumper(workspace_dir + "/minmax.h5")
#else
: _graph{graph}, _backend_contexts{backend_contexts}, _raw_dumper(workspace_dir + "/minmax.bin")
#endif
: _graph{graph}, _backend_contexts{backend_contexts}, _workspace_dir(workspace_dir)
{
// DO NOTHING
}

std::pair<float, float> minmaxFrom(const backend::ITensor *tensor)
Expand Down Expand Up @@ -148,9 +149,11 @@ void MinMaxRecorder::handleSubgraphEnd(ir::SubgraphIndex)
// It would be better to dump at the end of model execution, not subgraph
// But it requires more changes than subgraph.
#if MINMAX_H5DUMPER
_h5dumper.dump(_input_minmax, _op_minmax);
auto h5dumper = dumper::h5::MinMaxDumper(_workspace_dir + "/minmax.h5");
h5dumper.dump(_input_minmax, _op_minmax);
#else
_raw_dumper.dump(_input_minmax, _op_minmax);
auto raw_dumper = RawMinMaxDumper(_workspace_dir + "/minmax.bin");
raw_dumper.dump(_input_minmax, _op_minmax);
#endif
}

Expand Down
13 changes: 2 additions & 11 deletions runtime/onert/core/src/exec/MinMaxRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@
#include "ExecutionObservers.h"
#include "ir/Index.h"
#include "exec/MinMaxMap.h"
#if MINMAX_H5DUMPER
#include "../dumper/h5/MinMaxDumper.h"
#else
#include "MinMaxData.h"
#endif

#include <memory>
#include <string>

namespace onert
{
Expand All @@ -51,11 +46,7 @@ class MinMaxRecorder : public IExecutionObserver
private:
const ir::Graph &_graph;
const backend::BackendContexts &_backend_contexts;
#if MINMAX_H5DUMPER
dumper::h5::MinMaxDumper _h5dumper;
#else
RawMinMaxDumper _raw_dumper;
#endif
std::string _workspace_dir;
OpMinMaxMap _op_minmax;
IOMinMaxMap _input_minmax;
};
Expand Down
Loading