ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci::QuantizeOnnxQDQPass Struct Referencefinal

Class to quantize ONNX QuantizeLinear-DequantizeLinear operator. More...

#include <QuantizeOnnxQDQPass.h>

Collaboration diagram for luci::QuantizeOnnxQDQPass:

Public Member Functions

const char * name (void) const final
 
bool run (loco::Graph *g) final
 
- Public Member Functions inherited from logo::Pass
virtual ~Pass ()=default
 

Detailed Description

Class to quantize ONNX QuantizeLinear-DequantizeLinear operator.

Definition at line 29 of file QuantizeOnnxQDQPass.h.

Member Function Documentation

◆ name()

const char * luci::QuantizeOnnxQDQPass::name ( void  ) const
inlinefinalvirtual

Reimplemented from logo::Pass.

Definition at line 31 of file QuantizeOnnxQDQPass.h.

31{ return "luci::QuantizeOnnxQDQ"; }

◆ run()

bool luci::QuantizeOnnxQDQPass::run ( loco::Graph g)
finalvirtual

Quantize pattern

[Before]

   [CircleNode(fp32)]
           |

[CircleCustom(OnnxQuantizeLinear)] | [CircleCustom(OnnxDequantizeLinear)] | [CircleNode]

[After]

   [CircleNode(quantized)]
           |
      [CircleNode]

Implements logo::Pass.

Definition at line 270 of file QuantizeOnnxQDQPass.cpp.

271{
272 bool changed = false;
273
274 for (auto node : loco::active_nodes(loco::output_nodes(g)))
275 {
276 if (auto circle_custom_out = dynamic_cast<luci::CircleCustomOut *>(node))
277 {
278 OnnxQDQPattern p(circle_custom_out);
279 if (p.matched())
280 {
281 QuantizeOnnxQDQ quantize(p);
282 quantize.apply();
283 changed = true;
284 }
285 }
286 }
287
288 return changed;
289}
Virtual CIRCLECUSTOMOUT in Circle.
std::set< loco::Node * > active_nodes(const std::vector< loco::Node * > &roots)
Enumerate all the nodes required to compute "roots".
std::vector< Node * > output_nodes(Graph *)
Definition Graph.cpp:101
std::vector< T > quantize(const float *data, size_t num_elements, float scale, int32_t zero_point)
Definition TestUtils.h:174

References loco::active_nodes(), and loco::output_nodes().

Referenced by package.infer.session::inference(), and luci::QuantizeOnnxFakeQuantModelPass::run().


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