From 42b7b4f51395d7cc7c61b51933d5efd5584d422a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=94=D0=B8=D0=BB=D1=88=D0=BE=D0=B4=D0=B6=D0=BE=D0=BD=20?= =?utf8?q?=D0=A3=D0=BC=D1=80=D0=BE=D0=BD=D1=85=D0=BE=D0=BD=D0=BE=D0=B2?= =?utf8?q?=D0=B8=D1=87=20=D0=9F=D0=BE=D1=88=D1=88=D0=BE=D0=B5=D0=B2/AI=20T?= =?utf8?q?ools=20Lab=20/SRR/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 7 May 2019 06:33:10 +0300 Subject: [PATCH] Fix Operands::exist to be able to remove operands (#5146) 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 --- runtimes/neurun/core/src/model/Operands.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtimes/neurun/core/src/model/Operands.cc b/runtimes/neurun/core/src/model/Operands.cc index 5cf2a43..0c64312 100644 --- a/runtimes/neurun/core/src/model/Operands.cc +++ b/runtimes/neurun/core/src/model/Operands.cc @@ -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 &fn) const -- 2.7.4