#ifndef __INTERNAL_MODEL_H__
#define __INTERNAL_MODEL_H__
-#include "graph/operand/Index.h"
-#include "internal/operand/Data.h"
-#include "internal/operand/Shape.h"
-
-#include <vector>
#include <cstdint>
-
-#include "util/feature/Shape.h"
-#include "util/kernel/Shape.h"
#include <algorithm>
#include <memory>
-#include <cassert>
-
-namespace internal
-{
-namespace tflite
-{
-namespace operand
-{
-
-// Operand usage should be exact one of these
-enum class OperandUsage
-{
- NOT_DEFINED,
- MODEL_INPUT,
- CONSTANT,
- OPERATION_OUTPUT,
-};
-
-class Object
-{
-public:
- explicit Object(const Shape &shape) : _shape{shape}, _usage{OperandUsage::NOT_DEFINED}
- {
- // DO NOTHING
- }
-
-public:
- const Shape &shape(void) const { return _shape; }
- size_t operandSize(void) const;
- bool setAsConstant() { return setUsage(OperandUsage::CONSTANT); }
- bool setAsModelInput() { return setUsage(OperandUsage::MODEL_INPUT); }
- bool setAsOperationOutput() { return setUsage(OperandUsage::OPERATION_OUTPUT); }
- bool usageIsDefined(void) const { return _usage != OperandUsage::NOT_DEFINED; }
- bool isModelInput(void) const { return _usage == OperandUsage::MODEL_INPUT; }
-
-private:
- bool setUsage(OperandUsage usage);
-
-public:
- void data(std::unique_ptr<Data> &&data) { _data = std::move(data); }
- const Data &data(void) const { return *_data; }
-
-public:
- template <typename T, typename... Args> void data(Args &&... args)
- {
- data(std::unique_ptr<T>(new T{std::forward<Args>(args)...}));
- }
-
-public:
- template <typename T> T asScalar(void) const
- {
- assert((_shape.rank() == 0) || ((_shape.rank() == 1) && (_shape.dim(0) == 1)));
- assert(_data != nullptr);
- assert((_data->base() != nullptr) && (_data->size() == sizeof(T)));
-
- return *(reinterpret_cast<const T *>(_data->base()));
- }
-
-private:
- const Shape _shape;
- std::unique_ptr<Data> _data;
- OperandUsage _usage;
-};
-
-} // namespace operand
-} // namespace tflite
-} // namespace internal
+#include <vector>
+#include "internal/operand/Object.h"
#include "internal/op/NodeVisitor.h"
namespace internal
--- /dev/null
+#ifndef __NEURUN_INTERNAL_OPERAND_OBJECT_H__
+#define __NEURUN_INTERNAL_OPERAND_OBJECT_H__
+
+#include <cassert>
+#include <cstdint>
+#include <memory>
+#include <algorithm>
+
+#include "Shape.h"
+#include "Data.h"
+
+namespace internal
+{
+namespace tflite
+{
+namespace operand
+{
+
+// Operand usage should be exact one of these
+enum class OperandUsage
+{
+ NOT_DEFINED,
+ MODEL_INPUT,
+ CONSTANT,
+ OPERATION_OUTPUT,
+};
+
+class Object
+{
+public:
+ explicit Object(const Shape &shape) : _shape{shape}, _usage{OperandUsage::NOT_DEFINED}
+ {
+ // DO NOTHING
+ }
+
+public:
+ const Shape &shape(void) const { return _shape; }
+ size_t operandSize(void) const;
+ bool setAsConstant() { return setUsage(OperandUsage::CONSTANT); }
+ bool setAsModelInput() { return setUsage(OperandUsage::MODEL_INPUT); }
+ bool setAsOperationOutput() { return setUsage(OperandUsage::OPERATION_OUTPUT); }
+ bool usageIsDefined(void) const { return _usage != OperandUsage::NOT_DEFINED; }
+ bool isModelInput(void) const { return _usage == OperandUsage::MODEL_INPUT; }
+
+private:
+ bool setUsage(OperandUsage usage);
+
+public:
+ void data(std::unique_ptr<Data> &&data) { _data = std::move(data); }
+ const Data &data(void) const { return *_data; }
+
+public:
+ template <typename T, typename... Args> void data(Args &&... args)
+ {
+ data(std::unique_ptr<T>(new T{std::forward<Args>(args)...}));
+ }
+
+public:
+ template <typename T> T asScalar(void) const
+ {
+ assert((_shape.rank() == 0) || ((_shape.rank() == 1) && (_shape.dim(0) == 1)));
+ assert(_data != nullptr);
+ assert((_data->base() != nullptr) && (_data->size() == sizeof(T)));
+
+ return *(reinterpret_cast<const T *>(_data->base()));
+ }
+
+private:
+ const Shape _shape;
+ std::unique_ptr<Data> _data;
+ OperandUsage _usage;
+};
+
+} // namespace operand
+} // namespace tflite
+} // namespace internal
+
+#endif // __NEURUN_INTERNAL_OPERAND_OBJECT_H__