[neurun] [nnapi] Meaningful exception message (#5603)
authorVladimir Plazun/AI Tools Lab /SRR/Engineer/삼성전자 <v.plazun@samsung.com>
Wed, 10 Jul 2019 02:09:27 +0000 (05:09 +0300)
committer이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Wed, 10 Jul 2019 02:09:27 +0000 (11:09 +0900)
* [neurun] [nnapi] Meaningful exception message

Throw exception with meaningful description in case of unsupported operation

Signed-off-by: Vladimir Plazun <v.plazun@samsung.com>
* Format fix

Signed-off-by: Vladimir Plazun <v.plazun@samsung.com>
runtimes/neurun/frontend/nnapi/wrapper/OperationFactory.cc

index 483b595..3ea0f1d 100644 (file)
@@ -1514,5 +1514,10 @@ neurun::model::Operation *OperationFactory::create(ANeuralNetworksOperationType
                                                    const OperationFactory::Param &param,
                                                    neurun::model::Operands &operands)
 {
-  return _map.at(type)(param, operands);
+  auto it = _map.find(type);
+  if (it == _map.end())
+  {
+    throw std::runtime_error("Unsupported operation type: " + std::to_string(type));
+  }
+  return it->second(param, operands);
 }