From dde8b26626ea1f872774975235272367df8cf643 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Fri, 31 Aug 2018 15:21:49 +0900 Subject: [PATCH] [neurun] Define use & def in operand (#2541) - Define use & def in operand - Define base methods to append & remove Signed-off-by: Hyeongseok Oh --- runtimes/neurun/src/graph/operand/Object.cc | 32 +++++++++++++++++++++++++++++ runtimes/neurun/src/graph/operand/Object.h | 11 ++++++++++ 2 files changed, 43 insertions(+) diff --git a/runtimes/neurun/src/graph/operand/Object.cc b/runtimes/neurun/src/graph/operand/Object.cc index cc054a7..625cb78 100644 --- a/runtimes/neurun/src/graph/operand/Object.cc +++ b/runtimes/neurun/src/graph/operand/Object.cc @@ -57,6 +57,38 @@ bool Object::setUsage(const OperandUsage usage) return true; } +void Object::appendUse(const ::neurun::graph::operation::Index &idx) +{ + assert(_usage != OperandUsage::NOT_DEFINED); + assert(!_uses.contains(idx)); + + _uses.append(idx); +} + +void Object::removeUse(const ::neurun::graph::operation::Index &idx) +{ + assert(_usage != OperandUsage::NOT_DEFINED); + assert(_uses.contains(idx)); + + _uses.remove(idx); +} + +void Object::appendDef(const ::neurun::graph::operation::Index &idx) +{ + assert(_usage != OperandUsage::NOT_DEFINED && _usage != OperandUsage::CONSTANT); + assert(_def.size() == 0); + + _def.append(idx); +} + +void Object::removeDef(const ::neurun::graph::operation::Index &idx) +{ + assert(_usage != OperandUsage::NOT_DEFINED); + assert(_def.contains(idx)); + + _def.remove(idx); +} + } // namespace operand } // namespace graph } // namespace neurun diff --git a/runtimes/neurun/src/graph/operand/Object.h b/runtimes/neurun/src/graph/operand/Object.h index fc5bd01..59110fd 100644 --- a/runtimes/neurun/src/graph/operand/Object.h +++ b/runtimes/neurun/src/graph/operand/Object.h @@ -9,6 +9,7 @@ #include "Shape.h" #include "Data.h" #include "TypeInfo.h" +#include "graph/operation/IndexList.h" namespace neurun { @@ -45,6 +46,13 @@ public: bool usageIsDefined(void) const { return _usage != OperandUsage::NOT_DEFINED; } bool isModelInput(void) const { return _usage == OperandUsage::MODEL_INPUT; } + const operation::IndexList &getUses() const { return _uses; } + const operation::IndexList &getDef() const { return _def; } + void appendUse(const operation::Index &idx); + void removeUse(const operation::Index &idx); + void appendDef(const operation::Index &idx); + void removeDef(const operation::Index &idx); + private: bool setUsage(OperandUsage usage); @@ -73,6 +81,9 @@ private: const TypeInfo _type; std::unique_ptr _data; OperandUsage _usage; + + operation::IndexList _uses; + operation::IndexList _def; // size is 0 (constant) or 1 (from def operation) }; } // namespace operand -- 2.7.4