76{
77 if (module == nullptr)
78 throw std::runtime_error{"Input module is nullptr"};
79
80 MinMaxReader mmr{minmax_path};
81
82 for (size_t idx = 0; idx < module->size(); ++idx)
83 {
84 auto graph =
module->graph(idx);
85
86
89 for (size_t input_idx = 0; input_idx < n_inputs; ++input_idx)
90 {
91 const auto *circle_input = loco::must_cast<const luci::CircleInput *>(input_nodes[input_idx]);
92 if (circle_input->index() != input_idx)
93 throw std::runtime_error("Input order in minmax recording does not match to circle");
94
95 auto minmax = mmr.readInput(0, idx, input_idx);
98 auto quantparam = std::make_unique<luci::CircleQuantParam>();
99 quantparam->min.push_back(min);
100 quantparam->max.push_back(max);
101 const auto *circle_node = loco::must_cast<const luci::CircleNode *>(input_nodes[input_idx]);
103 mutable_node->
quantparam(std::move(quantparam));
104 }
105
106
107 uint32_t n_nodes =
graph->nodes()->size();
108 for (uint32_t i = 0; i < n_nodes; ++i)
109 {
110 auto node = loco::must_cast<luci::CircleNode *>(
graph->nodes()->at(i));
112 continue;
114 auto minmax = mmr.readOP(0, idx, op_idx);
117 auto quantparam = std::make_unique<luci::CircleQuantParam>();
118 quantparam->min.push_back(min);
119 quantparam->max.push_back(max);
121 mutable_node->
quantparam(std::move(quantparam));
122 }
123
125 throw std::runtime_error{"Circle after embedding minmax is invalid"};
126 }
127}
std::vector< Node * > input_nodes(const Graph *)
CircleNodeID get_node_id(const luci::CircleNode *circle_node)
bool validate(luci::PartitionTable &partition)
bool has_node_id(const luci::CircleNode *circle_node)
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