ONE - On-device Neural Engine
Loading...
Searching...
No Matches
record_minmax::MovingAvgComputer Class Reference

#include <MinMaxComputer.h>

Collaboration diagram for record_minmax::MovingAvgComputer:

Public Member Functions

 MovingAvgComputer (uint32_t batch_size, float update_const)
 
virtual void update_qparam (const std::unordered_map< const luci::CircleNode *, MinMaxVectors > *minmax_map)
 
- Public Member Functions inherited from record_minmax::MinMaxComputer
 MinMaxComputer ()
 
virtual ~MinMaxComputer ()=default
 

Detailed Description

Definition at line 61 of file MinMaxComputer.h.

Constructor & Destructor Documentation

◆ MovingAvgComputer()

record_minmax::MovingAvgComputer::MovingAvgComputer ( uint32_t  batch_size,
float  update_const 
)
inline

Definition at line 64 of file MinMaxComputer.h.

65 : _batch_size(batch_size), _update_const(update_const)
66 {
67 }

Member Function Documentation

◆ update_qparam()

void record_minmax::MovingAvgComputer::update_qparam ( const std::unordered_map< const luci::CircleNode *, MinMaxVectors > *  minmax_map)
virtual

Implements record_minmax::MinMaxComputer.

Definition at line 50 of file MinMaxComputer.cpp.

52{
53 if (minmax_map == nullptr)
54 throw std::invalid_argument("minmax_map is nullptr");
55
56 for (auto iter = minmax_map->begin(); iter != minmax_map->end(); ++iter)
57 {
58 auto node = iter->first;
59 auto minmax = iter->second;
60
61 auto min = getMovingAverage(minmax.min_vector, 1 - _update_const, _batch_size, true);
62 auto max = getMovingAverage(minmax.max_vector, 1 - _update_const, _batch_size, false);
63
64 auto quantparam = std::make_unique<luci::CircleQuantParam>();
65 quantparam->min.push_back(min);
66 quantparam->max.push_back(max);
67
68 assert(node->quantparam() == nullptr);
69
70 auto mutable_node = const_cast<luci::CircleNode *>(node);
71 mutable_node->quantparam(std::move(quantparam));
72 }
73}
float getMovingAverage(const std::vector< float > &vector, const float alpha, const uint8_t batch_size, bool is_min)
getMovingAverage calculates the weighted moving average of input vector The initial value is the mini...
CircleQuantParam * quantparam(void) const

References record_minmax::getMovingAverage(), and luci::CircleNode::quantparam().


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