ONE - On-device Neural Engine
Loading...
Searching...
No Matches
mpqsolver::core::DumpingHooks Class Referencefinal

DumpingHooks is intended to save intermediate results. More...

#include <DumpingHooks.h>

Collaboration diagram for mpqsolver::core::DumpingHooks:

Public Member Functions

 DumpingHooks (const std::string &save_path, const Quantizer::Context &ctx)
 DumpingHooks constructor.
 
virtual void onQuantized (luci::Module *module) const override
 called on successfull quantization
 
virtual void onBeginSolver (const std::string &model_path, float q8error, float q16error) override
 called on the start of mpq search
 
virtual void onBeginIteration () override
 called on the start of current iteration
 
virtual void onEndIteration (const LayerParams &layers, const std::string &def_dtype, float error) override
 called at the end of current iteration
 
virtual void onEndSolver (const LayerParams &layers, const std::string &def_dtype, float qerror) override
 called at the end of mpq search
 

Detailed Description

DumpingHooks is intended to save intermediate results.

Definition at line 36 of file DumpingHooks.h.

Constructor & Destructor Documentation

◆ DumpingHooks()

DumpingHooks::DumpingHooks ( const std::string &  save_path,
const Quantizer::Context ctx 
)

DumpingHooks constructor.

Parameters
save_pathdirectory where all intermediate data will be saved

Definition at line 22 of file DumpingHooks.cpp.

23 : _save_path(save_path), _dumper(_save_path), _ctx(ctx)
24{
25}

Member Function Documentation

◆ onBeginIteration()

void DumpingHooks::onBeginIteration ( )
overridevirtual

called on the start of current iteration

Implements mpqsolver::core::SolverHooks.

Definition at line 45 of file DumpingHooks.cpp.

46{
47 _in_iterations = true;
48 _num_of_iterations += 1;
49}

◆ onBeginSolver()

void DumpingHooks::onBeginSolver ( const std::string &  model_path,
float  q8error,
float  q16error 
)
overridevirtual

called on the start of mpq search

Implements mpqsolver::core::SolverHooks.

Definition at line 27 of file DumpingHooks.cpp.

28{
29 _model_path = model_path;
30 _dumper.setModelPath(_model_path);
31 if (!std::isnan(q8error) || !std::isnan(q16error))
32 {
33 _dumper.prepareForErrorDumping();
34 }
35 if (!std::isnan(q8error))
36 {
37 _dumper.dumpQ8Error(q8error);
38 }
39 if (!std::isnan(q16error))
40 {
41 _dumper.dumpQ16Error(q16error);
42 }
43}
void dumpQ16Error(float error) const
append error of Q16 quantization
Definition Dumper.cpp:145
void setModelPath(const std::string &model_path)
sets model path for further usage
Definition Dumper.cpp:43
void dumpQ8Error(float error) const
append error of Q8 quantization
Definition Dumper.cpp:139
void prepareForErrorDumping() const
create file for error dumping
Definition Dumper.cpp:130

References mpqsolver::core::Dumper::dumpQ16Error(), mpqsolver::core::Dumper::dumpQ8Error(), mpqsolver::core::Dumper::prepareForErrorDumping(), and mpqsolver::core::Dumper::setModelPath().

◆ onEndIteration()

void DumpingHooks::onEndIteration ( const LayerParams layers,
const std::string &  def_dtype,
float  error 
)
overridevirtual

called at the end of current iteration

Implements mpqsolver::core::SolverHooks.

Definition at line 51 of file DumpingHooks.cpp.

53{
54 _dumper.dumpMPQConfiguration(layers, def_type, _ctx.granularity, _num_of_iterations);
55 _dumper.dumpMPQError(error, _num_of_iterations);
56 _in_iterations = false;
57}
void dumpMPQConfiguration(const LayerParams &layers, const std::string &def_dtype, const std::string &def_granularity, int step) const
dumps mpq configuration
Definition Dumper.cpp:82
void dumpMPQError(float error, uint32_t step) const
append error of mpq quantization
Definition Dumper.cpp:151

References mpqsolver::core::Dumper::dumpMPQConfiguration(), mpqsolver::core::Dumper::dumpMPQError(), and mpqsolver::core::Quantizer::Context::granularity.

◆ onEndSolver()

void DumpingHooks::onEndSolver ( const LayerParams layers,
const std::string &  def_dtype,
float  qerror 
)
overridevirtual

called at the end of mpq search

Implements mpqsolver::core::SolverHooks.

Definition at line 59 of file DumpingHooks.cpp.

61{
62 _dumper.dumpFinalMPQ(layers, def_dtype, _ctx.granularity);
63 if (!std::isnan(qerror))
64 {
65 _dumper.dumpMPQError(qerror);
66 }
67}
void dumpFinalMPQ(const LayerParams &layers, const std::string &def_dtype, const std::string &def_granularity) const
dumps final mpq configuration
Definition Dumper.cpp:90

References mpqsolver::core::Dumper::dumpFinalMPQ(), mpqsolver::core::Dumper::dumpMPQError(), and mpqsolver::core::Quantizer::Context::granularity.

◆ onQuantized()

void DumpingHooks::onQuantized ( luci::Module module) const
overridevirtual

called on successfull quantization

Implements mpqsolver::core::QuantizerHook.

Definition at line 69 of file DumpingHooks.cpp.

70{
71 if (_in_iterations)
72 {
73 _dumper.dumpQuantized(module, _num_of_iterations);
74 }
75}
void dumpQuantized(luci::Module *module, uint32_t step) const
dumps quantized module
Definition Dumper.cpp:116

References mpqsolver::core::Dumper::dumpQuantized().


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