ONE - On-device Neural Engine
Loading...
Searching...
No Matches
mpqsolver::pattern::PatternSolver Class Referencefinal

#include <PatternSolver.h>

Collaboration diagram for mpqsolver::pattern::PatternSolver:

Public Member Functions

 PatternSolver (const mpqsolver::core::Quantizer::Context &ctx, const std::vector< QuantizationPattern > &patterns)
 construct PatternSolver using qunatization context and patterns to apply
 
std::unique_ptr< luci::Modulerun (const std::string &module_path) override
 run solver for recorded float module at module_path
 
- Public Member Functions inherited from mpqsolver::MPQSolver
 MPQSolver (const core::Quantizer::Context &ctx)
 
virtual ~MPQSolver ()=default
 
void setSaveIntermediate (const std::string &save_path)
 set all intermediate artifacts to be saved
 

Additional Inherited Members

- Protected Member Functions inherited from mpqsolver::MPQSolver
std::unique_ptr< luci::ModulereadModule (const std::string &path)
 
- Protected Attributes inherited from mpqsolver::MPQSolver
std::string _input_quantization
 
std::string _output_quantization
 
std::unique_ptr< core::Quantizer_quantizer
 
std::unique_ptr< core::DumpingHooks_hooks
 

Detailed Description

Definition at line 48 of file PatternSolver.h.

Constructor & Destructor Documentation

◆ PatternSolver()

PatternSolver::PatternSolver ( const mpqsolver::core::Quantizer::Context ctx,
const std::vector< QuantizationPattern > &  patterns 
)

construct PatternSolver using qunatization context and patterns to apply

Definition at line 29 of file PatternSolver.cpp.

31 : MPQSolver(ctx)
32{
33 MPQOptions options{patterns};
34 setMPQOptions(options);
35}
MPQSolver(const core::Quantizer::Context &ctx)
Definition MPQSolver.cpp:24

Member Function Documentation

◆ run()

std::unique_ptr< luci::Module > PatternSolver::run ( const std::string &  module_path)
overridevirtual

run solver for recorded float module at module_path

Implements mpqsolver::MPQSolver.

Definition at line 37 of file PatternSolver.cpp.

38{
39 auto module = readModule(module_path);
40 assert(module != nullptr);
41
42 _quantizer->setHook(_hooks.get());
43 if (_hooks)
44 {
45 _hooks->onBeginSolver(module_path, NAN, NAN);
46 }
47
48 resolvePatterns(module.get());
49
50 auto layer_params = getFrozenParams();
51
52 if (_hooks)
53 {
54 _hooks->onEndSolver(layer_params, _quantizer->getContext().output_model_dtype, NAN);
55 }
56
57 if (!_quantizer->quantize(module.get(), layer_params))
58 {
59 throw std::runtime_error("Failed to quantize model");
60 }
61
62 return module;
63}
std::unique_ptr< core::Quantizer > _quantizer
Definition MPQSolver.h:54
std::unique_ptr< core::DumpingHooks > _hooks
Definition MPQSolver.h:55

References mpqsolver::MPQSolver::_hooks, and mpqsolver::MPQSolver::_quantizer.

Referenced by package.infer.session::inference().


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