ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::odc::QuantizeManager Class Reference

#include <QuantizeManager.h>

Public Member Functions

 QuantizeManager ()=default
 
 QuantizeManager (QuantizeManager const &)=delete
 
QuantizeManageroperator= (QuantizeManager const &)=delete
 
void exportModelPath (const std::string &model_path)
 Set model path to export quantized model.
 
std::string & exportModelPath ()
 Get model path to export quantized model.
 
void quantizeType (QuantizeType qtype)
 Set quantize type.
 
bool quantize (const std::string &model_path)
 Quantize model.
 
bool setMinMaxRecordsThreshold (uint32_t value)
 Set the number of minmax records enough for quantization.
 
bool readyForQuantize ()
 checking minmax recording count and threshold for quantization
 
bool deleteMinMaxFile ()
 Delete MinMax File of on-device compiler.
 

Detailed Description

Definition at line 33 of file QuantizeManager.h.

Constructor & Destructor Documentation

◆ QuantizeManager() [1/2]

onert::odc::QuantizeManager::QuantizeManager ( )
default

◆ QuantizeManager() [2/2]

onert::odc::QuantizeManager::QuantizeManager ( QuantizeManager const &  )
delete

Member Function Documentation

◆ deleteMinMaxFile()

bool onert::odc::QuantizeManager::deleteMinMaxFile ( )

Delete MinMax File of on-device compiler.

Returns
Return true if file removed successfully

Definition at line 73 of file QuantizeManager.cc.

74{
75 auto &quantize_loader = QuantizerLoader::instance();
76 if (quantize_loader.loadLibrary() != 0)
77 return false;
78
79 auto quantizer = quantize_loader.get();
80 bool result = quantizer->deleteMinMaxFile();
81
82 return result;
83}
static QuantizerLoader & instance()
Get singleton instance of QuantizerLoader.
result
Definition infer.py:103

References onert::odc::QuantizerLoader::instance().

◆ exportModelPath() [1/2]

std::string & onert::odc::QuantizeManager::exportModelPath ( )
inline

Get model path to export quantized model.

Returns
Model path to export quantized model

Definition at line 54 of file QuantizeManager.h.

54{ return _export_model_path; }

◆ exportModelPath() [2/2]

void onert::odc::QuantizeManager::exportModelPath ( const std::string &  model_path)
inline

Set model path to export quantized model.

Parameters
model_pathModel path to export quantized model

Definition at line 47 of file QuantizeManager.h.

47{ _export_model_path = model_path; }

◆ operator=()

QuantizeManager & onert::odc::QuantizeManager::operator= ( QuantizeManager const &  )
delete

◆ quantize()

bool onert::odc::QuantizeManager::quantize ( const std::string &  model_path)

Quantize model.

Parameters
[in]model_pathModel path to quantize
Returns
true if success, otherwise false

Definition at line 28 of file QuantizeManager.cc.

29{
30 if (model_path.empty() || _export_model_path.empty())
31 return false;
32
33 // Compile function is thread-unsafe
34 static std::mutex lock;
35 std::lock_guard<std::mutex> guard(lock);
36
37 auto &quantize_loader = QuantizerLoader::instance();
38 if (quantize_loader.loadLibrary() != 0)
39 return false;
40
41 auto quantizer = quantize_loader.get();
42 auto result = quantizer->quantize(model_path.c_str(), _export_model_path.c_str(), _qtype);
43
44 // TODO Unload quantize library to reduce memory usage
45
46 return (result == 0);
47}

References onert::odc::QuantizerLoader::instance().

◆ quantizeType()

void onert::odc::QuantizeManager::quantizeType ( QuantizeType  qtype)
inline

Set quantize type.

Parameters
qtypequantization type

Definition at line 63 of file QuantizeManager.h.

63{ _qtype = qtype; }

◆ readyForQuantize()

bool onert::odc::QuantizeManager::readyForQuantize ( )

checking minmax recording count and threshold for quantization

Returns
true if ready, otherwise false

Definition at line 61 of file QuantizeManager.cc.

62{
63 auto &quantize_loader = QuantizerLoader::instance();
64 if (quantize_loader.loadLibrary() != 0)
65 return false;
66
67 auto quantizer = quantize_loader.get();
68 bool result = quantizer->readyForQuantize();
69
70 return result;
71}

References onert::odc::QuantizerLoader::instance().

◆ setMinMaxRecordsThreshold()

bool onert::odc::QuantizeManager::setMinMaxRecordsThreshold ( uint32_t  value)

Set the number of minmax records enough for quantization.

Returns
true if success, otherwise false

Definition at line 49 of file QuantizeManager.cc.

50{
51 auto &quantize_loader = QuantizerLoader::instance();
52 if (quantize_loader.loadLibrary() != 0)
53 return false;
54
55 auto quantizer = quantize_loader.get();
56 quantizer->setMinMaxRecordsThreshold(value);
57
58 return true;
59}

References onert::odc::QuantizerLoader::instance().


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