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

#include <MinMaxComputer.h>

Collaboration diagram for record_minmax::PercentileComputer:

Public Member Functions

 PercentileComputer (float min_percentile, float max_percentile)
 
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 45 of file MinMaxComputer.h.

Constructor & Destructor Documentation

◆ PercentileComputer()

record_minmax::PercentileComputer::PercentileComputer ( float  min_percentile,
float  max_percentile 
)
inline

Definition at line 48 of file MinMaxComputer.h.

49 : _min_percentile(min_percentile), _max_percentile(max_percentile)
50 {
51 }

Member Function Documentation

◆ update_qparam()

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

Implements record_minmax::MinMaxComputer.

Definition at line 25 of file MinMaxComputer.cpp.

27{
28 if (minmax_map == nullptr)
29 throw std::invalid_argument("minmax_map is nullptr");
30
31 for (auto iter = minmax_map->begin(); iter != minmax_map->end(); ++iter)
32 {
33 auto node = iter->first;
34 auto minmax = iter->second;
35
36 auto min = getNthPercentile(minmax.min_vector, _min_percentile);
37 auto max = getNthPercentile(minmax.max_vector, _max_percentile);
38
39 auto quantparam = std::make_unique<luci::CircleQuantParam>();
40 quantparam->min.push_back(min);
41 quantparam->max.push_back(max);
42
43 assert(node->quantparam() == nullptr);
44
45 auto mutable_node = const_cast<luci::CircleNode *>(node);
46 mutable_node->quantparam(std::move(quantparam));
47 }
48}
float getNthPercentile(std::vector< float > &vector, float percentile)
getNthPercentile calculates the n-th percentile of input vector (0.0 <= n <= 100.0) linear interpolat...
CircleQuantParam * quantparam(void) const

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


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