| 267 | } // namespace |
| 268 | |
| 269 | std::map<luci::CircleNode *, LayerParam> |
| 270 | Q8LayerNormWithQ16VarianceResolver::resolve(const luci::Module *module) |
| 271 | { |
| 272 | if (!module) |
| 273 | { |
| 274 | throw std::runtime_error("No module for pattern resolving"); |
| 275 | } |
| 276 | |
| 277 | std::map<luci::CircleNode *, LayerParam> nodes_params; |
| 278 | for (size_t idx = 0; idx < module->size(); ++idx) |
| 279 | { |
| 280 | auto graph = module->graph(idx); |
| 281 | |
| 282 | for (auto node : loco::active_nodes(loco::output_nodes(graph))) |
| 283 | { |
| 284 | auto const mul = dynamic_cast<luci::CircleMul *>(node); |
| 285 | if (!mul) |
| 286 | continue; |
| 287 | |
| 288 | LayerNormPattern pattern(mul); |
| 289 | if (!pattern.matched()) |
| 290 | continue; |
| 291 | |
| 292 | // set quantization parameters of recognized pattern |
| 293 | for (auto q16_node : pattern.get_q16_nodes()) |
| 294 | { |
| 295 | LayerParam param = {q16_node->name(), "int16", "channel"}; |
| 296 | nodes_params[q16_node] = param; |
| 297 | } |
| 298 | |
| 299 | for (auto q8_node : pattern.get_q8_nodes()) |
| 300 | { |
| 301 | LayerParam param = {q8_node->name(), "uint8", "channel"}; |
| 302 | nodes_params[q8_node] = param; |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | return nodes_params; |
| 308 | } |
| 309 | |
| 310 | std::map<luci::CircleNode *, LayerParam> |
| 311 | Q8SoftmaxWithQ16SubExpResolver::resolve(const luci::Module *module) |