Fix Operands::exist to be able to remove operands (#5146)
authorДилшоджон Умронхонович Пошшоев/AI Tools Lab /SRR/Engineer/삼성전자 <d.poshshoev@samsung.com>
Tue, 7 May 2019 03:33:10 +0000 (06:33 +0300)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Tue, 7 May 2019 03:33:10 +0000 (12:33 +0900)
If we remove operands after building a graph, existing method doesn't
work. Moreover, complexity of std::unordered_map::find is O(1), so we
don't loose much in time

Signed-off-by: Poshshoev Dilshodzhon <d.poshshoev@samsung.com>
runtimes/neurun/core/src/model/Operands.cc

index 5cf2a43..0c64312 100644 (file)
@@ -48,7 +48,8 @@ Operand &Operands::at(const OperandIndex &OperandIndex) { return *(_objects.at(O
 
 bool Operands::exist(const OperandIndex &OperandIndex) const
 {
-  return OperandIndex.value() < _objects.size();
+  auto it = _objects.find(OperandIndex);
+  return it != _objects.end();
 }
 
 void Operands::iterate(const std::function<void(const OperandIndex &, const Operand &)> &fn) const