ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
luci::PropagateQParamBackwardPass Struct Referencefinal

Class to propagate quantization parameters of an operator's output to input. More...

#include <PropagateQParamBackwardPass.h>

Collaboration diagram for luci::PropagateQParamBackwardPass:

Public Member Functions

 PropagateQParamBackwardPass (loco::DataType output)
 
const char * name (void) const final
 
bool run (loco::Graph *g) final
 Run the pass.
 
- Public Member Functions inherited from logo::Pass
virtual ~Pass ()=default
 

Detailed Description

Class to propagate quantization parameters of an operator's output to input.

Definition at line 28 of file PropagateQParamBackwardPass.h.

Constructor & Destructor Documentation

◆ PropagateQParamBackwardPass()

luci::PropagateQParamBackwardPass::PropagateQParamBackwardPass ( loco::DataType  output)
inline

Definition at line 30 of file PropagateQParamBackwardPass.h.

30: _output_model_dtype(output) {}

Member Function Documentation

◆ name()

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

Reimplemented from logo::Pass.

Definition at line 32 of file PropagateQParamBackwardPass.h.

32{ return "luci::PropagateQParamBackwardPass"; }

◆ run()

bool luci::PropagateQParamBackwardPass::run ( loco::Graph graph)
finalvirtual

Run the pass.

Returns
false if there was nothing changed

Implements logo::Pass.

Definition at line 512 of file PropagateQParamBackwardPass.cpp.

513{
514 LOGGER(l);
515
516 // We use reverse post-order traversal as qparam is propagated backward
518 std::reverse(nodes.begin(), nodes.end());
519 for (auto node : nodes)
520 {
521 auto circle_node = loco::must_cast<luci::CircleNode *>(node);
522 INFO(l) << "PropagateQParamBackwardPass visit node: " << circle_node->name() << std::endl;
523
524 // We can't propagate non-existent qparam
525 if (circle_node->quantparam() == nullptr)
526 continue;
527
528 PropagateQParamBackward pqb;
529 circle_node->accept(&pqb);
530 }
531
532 // This pass is only run once, so return false
533 // TODO Refactoring not to return meaningless value
534 return false;
535}
#define LOGGER(name)
Definition Log.h:65
#define INFO(name)
Definition Log.h:68
std::vector< loco::Node * > postorder_traversal(const std::vector< loco::Node * > &roots)
Generate postorder traversal sequence starting from "roots".
Definition Algorithm.cpp:53
std::vector< Node * > output_nodes(Graph *)
Definition Graph.cpp:101

References INFO, LOGGER, loco::output_nodes(), and loco::postorder_traversal().

Referenced by luci::QuantizeOnnxFakeQuantModelPass::run(), and luci::QuantizeWithMinMaxPass::run().


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