Move Shape and Index classes to nnc (#1104)
authorEfimov Alexander/AI Tools Lab/./Samsung Electronics <a.efimov@samsung.com>
Tue, 21 Aug 2018 14:09:40 +0000 (17:09 +0300)
committerSergey Vostokov/AI Tools Lab /SRR/Staff Engineer/삼성전자 <s.vostokov@samsung.com>
Tue, 21 Aug 2018 14:09:40 +0000 (17:09 +0300)
Move Shape, Index and all related support classes to nnc

Signed-off-by: Efimov Alexander <a.efimov@samsung.com>
47 files changed:
contrib/nnc/libs/backend/interpreter/core/include/interpreter/ops/OperationImpl.h
contrib/nnc/libs/backend/interpreter/core/include/interpreter/ops/Reduce.h
contrib/nnc/libs/backend/interpreter/core/include/interpreter/ops/common.h
contrib/nnc/libs/backend/interpreter/core/src/ops/conv_2D.cpp
contrib/nnc/libs/backend/interpreter/core/src/ops/conv_FFT.cpp
contrib/nnc/libs/backend/interpreter/plugin/include/interpreter_plugin.h
contrib/nnc/libs/backend/interpreter/plugin/src/interpreter_plugin.cpp
contrib/nnc/libs/backend/interpreter/test/src/op_info_util.cpp
contrib/nnc/libs/backend/soft/include/model_analyzer.h
contrib/nnc/libs/backend/soft/include/serializer.h
contrib/nnc/libs/backend/soft/src/model_analyzer.cpp
contrib/nnc/libs/backend/soft/src/serializer.cpp
contrib/nnc/libs/core/include/nnc/core/IR/model/operations/conv_2d_op.h
contrib/nnc/libs/core/include/nnc/core/IR/model/operations/depthwise_conv2d_op.h
contrib/nnc/libs/core/include/nnc/core/IR/model/operations/operation.h
contrib/nnc/libs/core/include/nnc/core/IR/model/operations/pool_op.h
contrib/nnc/libs/core/include/nnc/core/linalg/Accessor.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/linalg/ExternalRegion.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/linalg/Index.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/linalg/IndexEnumerator.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/linalg/IndexRange.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/linalg/Iterable.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/linalg/Reader.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/linalg/Region.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/linalg/Shape.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/linalg/ShapeRange.h
contrib/nnc/libs/core/include/nnc/core/linalg/Tensor.h
contrib/nnc/libs/core/include/nnc/core/linalg/TensorUtil.h
contrib/nnc/libs/core/include/nnc/core/linalg/TensorVariant.h
contrib/nnc/libs/core/src/core/IR/model/actions/ShapeInference.cpp
contrib/nnc/libs/core/src/core/IR/model/operations/operation.cpp
contrib/nnc/libs/core/src/core/linalg/Index.cpp [new file with mode: 0644]
contrib/nnc/libs/core/src/core/linalg/IndexEnumerator.cpp [new file with mode: 0644]
contrib/nnc/libs/core/src/core/linalg/IndexRange.cpp [new file with mode: 0644]
contrib/nnc/libs/core/src/core/linalg/Reader.cpp [new file with mode: 0644]
contrib/nnc/libs/core/src/core/linalg/Shape.cpp [new file with mode: 0644]
contrib/nnc/libs/frontend/caffe/include/caffe_model_visitor.h
contrib/nnc/libs/frontend/caffe/include/caffe_op_creator.h
contrib/nnc/libs/frontend/caffe/src/caffe_model_visitor.cpp
contrib/nnc/libs/frontend/include/shape_helper.h
contrib/nnc/libs/frontend/tflite/include/tflite_op_creator.h
contrib/nnc/libs/frontend/tflite/src/tflite_ir_visitor.cpp
contrib/nnc/unittests/core/ShapeInference.cpp
contrib/nnc/unittests/core/TensorVariant.cpp
contrib/nnc/unittests/core/ir_node.cpp
contrib/nnc/unittests/core/operation.cpp
contrib/nnc/unittests/soft_backend/cpp_operations.cpp

index d489037..84b6743 100644 (file)
@@ -6,7 +6,7 @@
 #include "nnc/core/linalg/Tensor.h"
 #include "nnc/core/linalg/TensorVariant.h"
 
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 namespace nncc
 {
@@ -22,7 +22,7 @@ namespace impl
 using namespace nncc::contrib::core::data;
 using nncc::contrib::core::ADT::TensorVariant;
 
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 template <typename T> class OperationImpl
 {
index 3ea7208..0c6e17c 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <functional>
 
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 #include "nnc/core/linalg/Tensor.h"
 
 #include "interpreter/ops/OperationImpl.h"
index fc44ddb..549a5dd 100644 (file)
@@ -1,7 +1,7 @@
 #pragma once
 
-#include "nncc/core/ADT/tensor/Index.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Index.h"
+#include "nnc/core/linalg/Shape.h"
 
 namespace nncc
 {
@@ -14,8 +14,8 @@ namespace interpreter
 namespace impl
 {
 
-using nncc::core::ADT::tensor::Index;
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Index;
+using nncc::contrib::core::data::Shape;
 
 
 ///
index 21bfa02..d3c222f 100644 (file)
@@ -16,7 +16,7 @@ namespace interpreter
 namespace impl
 {
 
-using namespace nncc::core::ADT::tensor;
+using namespace nncc::contrib::core::data;
 
 Index reduce(const Index &idx)
 {
index 137e40f..7d6718b 100644 (file)
@@ -16,7 +16,7 @@ namespace interpreter
 namespace impl
 {
 
-using namespace nncc::core::ADT::tensor;
+using namespace nncc::contrib::core::data;
 
 // Mostly compatible with tensorflow implementation
 // Assuming input is in NHWC format with batch omitted( [in_height, in_width, in_channels] )
index b65184e..3c1437e 100644 (file)
@@ -8,7 +8,7 @@
 #include "ConfigException.h"
 
 #include "nnc/core/linalg/TensorVariant.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 namespace nncc
 {
@@ -32,7 +32,7 @@ class InterpreterPlugin : public BackendPlugin {
   virtual ~InterpreterPlugin();
 
 private:
-  nncc::contrib::core::ADT::TensorVariant loadInput(const nncc::core::ADT::tensor::Shape &);
+  nncc::contrib::core::ADT::TensorVariant loadInput(const nncc::contrib::core::data::Shape &);
   nncc::contrib::core::ADT::TensorVariant *_out;
 };
 
index 12bacee..b69aa57 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "PluginInstance.h"
 
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 #include "interpreter/core/Interpreter.h"
 
@@ -30,7 +30,7 @@ namespace plugin
 {
 
 using namespace nncc::contrib;
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 using namespace nncc::contrib::core::IR::model;
 using nncc::contrib::backend::interpreter::core::NNInterpreter;
 using nncc::contrib::plugin::BackendPlugin;
index d504483..2a8756d 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "nnc/core/linalg/Tensor.h"
 #include "nnc/core/linalg/ShapeRange.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 #include "op_info_util.h"
 
 std::shared_ptr<TensorVariant> getTensor(const opinfo::Tensor* t)
index 77461f2..5848e3f 100644 (file)
@@ -2,7 +2,7 @@
 #define _NNC_SOFT_BACKEND_MODEL_ANALYZER_H_
 
 #include "nnc/core/IR/model/visitor/visitor.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 #include "nnc/core/linalg/TensorVariant.h"
 
 #include <vector>
index 7891524..8384787 100644 (file)
@@ -2,7 +2,7 @@
 #define _NNC_SOFT_BACKEND_SERIALIZER_H_
 
 #include "nnc/core/IR/model/visitor/visitor.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 #include "nnc/core/linalg/TensorVariant.h"
 #include "model_analyzer.h"
 
@@ -58,7 +58,7 @@ private:
   void packData(const void *data, size_t size);
   template <typename T>
   void serializeT(const T &obj);
-  void serializeShape(const nncc::core::ADT::tensor::Shape &s);
+  void serializeShape(const nncc::contrib::core::data::Shape &s);
   void serializeTensor(const contrib::core::ADT::TensorVariant &t);
   template <class Op>
   void serializePads(const Op &op, int32_t padsRank);
index 6abf348..323a8f1 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "model_analyzer.h"
 #include "nnc/core/IR/model/graph/ir_node.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 #include "nnc/core/linalg/ShapeRange.h"
 
 #include "nnc/core/IR/model/operations/concat_op.h"
@@ -28,8 +28,8 @@ namespace backend
 namespace soft
 {
 
-using nncc::core::ADT::tensor::Shape;
-using nncc::core::ADT::tensor::Index;
+using nncc::contrib::core::data::Shape;
+using nncc::contrib::core::data::Index;
 using nncc::contrib::core::data::ShapeRange;
 using nncc::contrib::core::ADT::TensorVariant;
 
index 2adb062..4c1c05f 100644 (file)
@@ -29,8 +29,8 @@ static_assert(std::numeric_limits<float>::is_iec559, "Unsupported float type");
 
 using namespace std;
 
-using nncc::core::ADT::tensor::Shape;
-using nncc::core::ADT::tensor::Index;
+using nncc::contrib::core::data::Shape;
+using nncc::contrib::core::data::Index;
 using nncc::contrib::core::data::ShapeRange;
 using nncc::contrib::core::data::util::transposeTensor;
 using nncc::contrib::core::ADT::TensorVariant;
index ad35439..870c8d8 100644 (file)
@@ -7,7 +7,7 @@
 #include "nnc/core/IR/model/operations/common.h"
 #include "nnc/core/linalg/TensorVariant.h"
 
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 namespace nncc
 {
@@ -22,7 +22,7 @@ namespace model
 namespace ops
 {
 
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 class Conv2DOp : public OpDescription
 {
index 172f9dd..6894da4 100644 (file)
@@ -7,7 +7,7 @@
 #include "nnc/core/linalg/TensorVariant.h"
 #include "nnc/core/IR/model/operations/common.h"
 
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 namespace nncc
 {
@@ -22,7 +22,7 @@ namespace model
 namespace ops
 {
 
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 class DepthwiseConv2DOp : public OpDescription
 {
index 55426bd..482333a 100644 (file)
@@ -5,7 +5,7 @@
 #include <map>
 #include <nnc/core/linalg/TensorVariant.h>
 
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 namespace nncc
 {
@@ -28,18 +28,18 @@ class OpDescription {
   size_t getNumInputs() const;
   size_t getNumOutputs() const;
 
-  const nncc::core::ADT::tensor::Shape &getInputShape(const size_t index) const;
-  virtual void setInputShape(const size_t index, const nncc::core::ADT::tensor::Shape &shape);
+  const nncc::contrib::core::data::Shape &getInputShape(const size_t index) const;
+  virtual void setInputShape(const size_t index, const nncc::contrib::core::data::Shape &shape);
 
-  virtual const nncc::core::ADT::tensor::Shape &getOutputShape(const size_t index) const;
-  void setOutputShape(const size_t index, const nncc::core::ADT::tensor::Shape &shape);
+  virtual const nncc::contrib::core::data::Shape &getOutputShape(const size_t index) const;
+  void setOutputShape(const size_t index, const nncc::contrib::core::data::Shape &shape);
 
  private:
   size_t _max_inputs;
   size_t _max_outputs;
 
-  std::map<size_t, nncc::core::ADT::tensor::Shape> _inputShapes;
-  std::map<size_t, nncc::core::ADT::tensor::Shape> _outputShapes;
+  std::map<size_t, nncc::contrib::core::data::Shape> _inputShapes;
+  std::map<size_t, nncc::contrib::core::data::Shape> _outputShapes;
 };
 
 } // namespace model
index 8e2f242..e1e3e16 100644 (file)
@@ -6,7 +6,7 @@
 #include "nnc/core/IR/model/operations/operation.h"
 #include "nnc/core/IR/model/operations/common.h"
 
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 namespace nncc
 {
@@ -21,7 +21,7 @@ namespace model
 namespace ops
 {
 
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 class PoolOp : public OpDescription
 {
diff --git a/contrib/nnc/libs/core/include/nnc/core/linalg/Accessor.h b/contrib/nnc/libs/core/include/nnc/core/linalg/Accessor.h
new file mode 100644 (file)
index 0000000..68993e6
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef _NNC_CORE_LINALG_ACCESSOR_H_
+#define _NNC_CORE_LINALG_ACCESSOR_H_
+
+#include "nnc/core/linalg/Index.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+template <typename T> struct Accessor
+{
+  virtual ~Accessor() = default;
+
+  virtual T &at(const Index &) = 0;
+};
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif // _NNC_CORE_LINALG_ACCESSOR_H__
diff --git a/contrib/nnc/libs/core/include/nnc/core/linalg/ExternalRegion.h b/contrib/nnc/libs/core/include/nnc/core/linalg/ExternalRegion.h
new file mode 100644 (file)
index 0000000..15b0534
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _NNC_CORE_LINALG_EXTERNAL_REGION_H_
+#define _NNC_CORE_LINALG_EXTERNAL_REGION_H_
+
+#include "nnc/core/linalg/Region.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+template <typename T> class ExternalRegion final : public Region<T>
+{
+public:
+  ExternalRegion(T *base, uint32_t size) : _base{base}, _size{size}
+  {
+    // DO NOTHING
+  }
+
+public:
+  T *base(void) override { return _base; }
+  uint32_t size(void) const override { return _size; }
+
+private:
+  T *const _base;
+  uint32_t const _size;
+};
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif // _NNC_CORE_LINALG_EXTERNAL_REGION_H_
diff --git a/contrib/nnc/libs/core/include/nnc/core/linalg/Index.h b/contrib/nnc/libs/core/include/nnc/core/linalg/Index.h
new file mode 100644 (file)
index 0000000..0e329e6
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef _NNC_CORE_LINALG_INDEX_H_
+#define _NNC_CORE_LINALG_INDEX_H_
+
+#include <initializer_list>
+#include <vector>
+#include <cstdint>
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+class Index
+{
+public:
+  Index() = default;
+  Index(std::initializer_list<uint32_t> &&l);
+
+public:
+  uint32_t rank(void) const;
+
+public:
+  Index &resize(uint32_t size);
+
+public:
+  Index &fill(uint32_t index);
+
+public:
+  uint32_t &at(uint32_t axis);
+  uint32_t at(uint32_t axis) const;
+
+private:
+  std::vector<uint32_t> _indices;
+};
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif // _NNC_CORE_LINALG_INDEX_H_
diff --git a/contrib/nnc/libs/core/include/nnc/core/linalg/IndexEnumerator.h b/contrib/nnc/libs/core/include/nnc/core/linalg/IndexEnumerator.h
new file mode 100644 (file)
index 0000000..1f33bb0
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef _NNC_CORE_LINALG_INDEX_ENUMERATE_H_
+#define _NNC_CORE_LINALG_INDEX_ENUMERATE_H_
+
+#include "nnc/core/linalg/Index.h"
+#include "nnc/core/linalg/Shape.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+class IndexEnumerator
+{
+public:
+  explicit IndexEnumerator(const Shape &shape);
+
+public:
+  IndexEnumerator(IndexEnumerator &&) = delete;
+  IndexEnumerator(const IndexEnumerator &) = delete;
+
+public:
+  bool valid(void) const { return _cursor < _shape.rank(); }
+
+public:
+  const Index &current(void) const { return _index; }
+
+public:
+  void advance(void);
+
+private:
+  const Shape _shape;
+  Index _index;
+
+private:
+  uint32_t _cursor;
+};
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif // _NNC_CORE_LINALG_INDEX_ENUMERATE_H_
diff --git a/contrib/nnc/libs/core/include/nnc/core/linalg/IndexRange.h b/contrib/nnc/libs/core/include/nnc/core/linalg/IndexRange.h
new file mode 100644 (file)
index 0000000..21be71e
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef _NNC_CORE_LINALG_INDEX_RANGE_H_
+#define _NNC_CORE_LINALG_INDEX_RANGE_H_
+
+#include "nnc/core/linalg/Index.h"
+#include "nnc/core/linalg/Shape.h"
+
+#include "nnc/core/linalg/Iterable.h"
+
+#include <functional>
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+class IndexRange
+{
+public:
+  explicit IndexRange(const Shape &shape);
+
+public:
+  bool member(const Index &index) const;
+
+public:
+  void iterate(const std::function<void(const Index &)> &) const;
+
+public:
+  Iterable<IndexRange> iterate(void) const { return Iterable<IndexRange>{this}; }
+
+private:
+  const Shape _shape;
+};
+
+IndexRange range(const Shape &shape);
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif // _NNC_CORE_LINALG_INDEX_RANGE_H_
diff --git a/contrib/nnc/libs/core/include/nnc/core/linalg/Iterable.h b/contrib/nnc/libs/core/include/nnc/core/linalg/Iterable.h
new file mode 100644 (file)
index 0000000..3722308
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef _NNC_CORE_LINALG_ITERABLE_H_
+#define _NNC_CORE_LINALG_ITERABLE_H_
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+template<typename T>
+class Iterable
+{
+public:
+  Iterable(const T *ptr) : _ptr{ptr}
+  {
+    // DO NOTHING
+  }
+
+public:
+  const T &get(void) const
+  { return *_ptr; }
+
+private:
+  const T *const _ptr;
+};
+
+template<typename T, typename Callable>
+const Iterable<T> &operator<<(const Iterable<T> &it, Callable cb)
+{
+  it.get().iterate(cb);
+  return it;
+}
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif // _NNC_CORE_LINALG_ITERABLE_H_
diff --git a/contrib/nnc/libs/core/include/nnc/core/linalg/Reader.h b/contrib/nnc/libs/core/include/nnc/core/linalg/Reader.h
new file mode 100644 (file)
index 0000000..bd2547f
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef _NNC_CORE_LINALG_READER_H_
+#define _NNC_CORE_LINALG_READER_H_
+
+#include "nnc/core/linalg/Index.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+template <typename T> struct Reader
+{
+  virtual ~Reader() = default;
+
+  virtual T at(const Index &) const = 0;
+};
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif // _NNC_CORE_LINALG_READER_H_
diff --git a/contrib/nnc/libs/core/include/nnc/core/linalg/Region.h b/contrib/nnc/libs/core/include/nnc/core/linalg/Region.h
new file mode 100644 (file)
index 0000000..75e4c7f
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef _NNC_CORE_LINALG_REGION_H_
+#define _NNC_CORE_LINALG_REGION_H_
+
+#include <cstdint>
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+template<typename T>
+struct Region
+{
+  virtual ~Region() = default;
+
+  virtual T *base(void) = 0;
+
+  virtual uint32_t size(void) const = 0;
+};
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif // _NNC_CORE_LINALG_REGION_H_
diff --git a/contrib/nnc/libs/core/include/nnc/core/linalg/Shape.h b/contrib/nnc/libs/core/include/nnc/core/linalg/Shape.h
new file mode 100644 (file)
index 0000000..14e474a
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef _NNC_CORE_LINALG_SHAPE_H_
+#define _NNC_CORE_LINALG_SHAPE_H_
+
+#include <initializer_list>
+#include <vector>
+#include <cstdint>
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+class Shape
+{
+public:
+  Shape() = default;
+  Shape(std::initializer_list<uint32_t> &&l);
+
+public:
+  uint32_t rank(void) const;
+
+public:
+  Shape &resize(uint32_t size);
+
+public:
+  uint32_t &dim(uint32_t axis);
+  uint32_t dim(uint32_t axis) const;
+
+public:
+  Shape &squeeze(void);
+
+private:
+  std::vector<uint32_t> _dims;
+};
+
+uint64_t num_elements(const Shape &);
+
+Shape squeeze(const Shape &);
+
+bool operator==(const Shape &, const Shape &);
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif // _NNC_CORE_LINALG_SHAPE_H_
index f2c232a..cd43dd8 100644 (file)
@@ -3,8 +3,8 @@
 
 #include <cassert>
 
-#include "nncc/core/ADT/tensor/Shape.h"
-#include "nncc/core/ADT/tensor/Index.h"
+#include "nnc/core/linalg/Shape.h"
+#include "nnc/core/linalg/Index.h"
 
 namespace nncc
 {
@@ -15,8 +15,8 @@ namespace core
 namespace data
 {
 
-using nncc::core::ADT::tensor::Shape;
-using nncc::core::ADT::tensor::Index;
+using nncc::contrib::core::data::Shape;
+using nncc::contrib::core::data::Index;
 
 class ShapeIter :
     public std::iterator<std::forward_iterator_tag, Index, std::size_t, Index*, Index&> {
index a211428..b6e717d 100644 (file)
@@ -1,10 +1,10 @@
 #pragma once
 
-#include "nncc/core/ADT/tensor/Shape.h"
-#include "nncc/core/ADT/tensor/Accessor.h"
-#include "nncc/core/ADT/tensor/Reader.h"
+#include "nnc/core/linalg/Shape.h"
+#include "nnc/core/linalg/Accessor.h"
+#include "nnc/core/linalg/Reader.h"
 
-#include "nncc/foundation/ExternalRegion.h"
+#include "nnc/core/linalg/ExternalRegion.h"
 
 #include "nnc/core/linalg/TensorVariant.h"
 
@@ -17,12 +17,6 @@ namespace core
 namespace data
 {
 
-using nncc::core::ADT::tensor::Shape;
-using nncc::core::ADT::tensor::Index;
-using nncc::foundation::ExternalRegion;
-using nncc::core::ADT::tensor::Accessor;
-using nncc::core::ADT::tensor::Reader;
-
 template<typename T>
 class Tensor final : public Accessor<T>, public Reader<T> {
  public:
index 82889f1..b3d2aa1 100644 (file)
@@ -5,9 +5,9 @@
 #include <memory>
 
 #include "nnc/core/linalg/TensorVariant.h"
-#include "nncc/core/ADT/tensor/Shape.h"
-#include "nncc/core/ADT/tensor/Index.h"
-#include "nncc/core/ADT/tensor/IndexRange.h"
+#include "nnc/core/linalg/Shape.h"
+#include "nnc/core/linalg/Index.h"
+#include "nnc/core/linalg/IndexRange.h"
 
 namespace nncc
 {
@@ -20,7 +20,7 @@ namespace data
 namespace util
 {
 
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 using namespace nncc::contrib::core::ADT;
 using namespace nncc::contrib::core::data;
 
@@ -28,8 +28,8 @@ template<unsigned int... Ints>
 static std::shared_ptr <TensorVariant>
 transposeTensor(std::shared_ptr <TensorVariant> tensor)
 {
-  using nncc::core::ADT::tensor::Index;
-  using nncc::core::ADT::tensor::IndexRange;
+  using nncc::contrib::core::data::Index;
+  using nncc::contrib::core::data::IndexRange;
 
   const Shape &inShape = tensor->getShape();
   Shape targetShape{inShape.dim(Ints)...};
index d955f79..d927d2d 100644 (file)
@@ -5,16 +5,16 @@
 #include <memory>
 #include <cassert>
 
-#include "nncc/core/ADT/tensor/Index.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Index.h"
+#include "nnc/core/linalg/Shape.h"
 
 namespace nncc {
 namespace contrib {
 namespace core {
 namespace ADT {
 
-using nncc::core::ADT::tensor::Shape;
-using nncc::core::ADT::tensor::Index;
+using nncc::contrib::core::data::Shape;
+using nncc::contrib::core::data::Index;
 
 constexpr int MAX_DIMENSIONS = 32;
 
index 5cb15b8..1665e4c 100644 (file)
@@ -25,7 +25,7 @@ namespace IR
 namespace model
 {
 
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 std::vector<int> calculate2DPaddings(ops::PaddingType paddingType, const Shape& inShape,
     const Shape& windowShape, const Shape& strides, Shape& outShape)
index 493ec21..82d0c74 100644 (file)
@@ -8,24 +8,24 @@ namespace core {
 namespace IR {
 namespace model {
 
-using namespace nncc::core::ADT;
+using namespace nncc::contrib::core::data;
 
-const tensor::Shape &OpDescription::getInputShape(const size_t index) const {
+const Shape &OpDescription::getInputShape(const size_t index) const {
   assert(index < getNumInputs());
   return _inputShapes.at(index);
 }
 
-void OpDescription::setInputShape(const size_t index, const tensor::Shape &shape) {
+void OpDescription::setInputShape(const size_t index, const Shape &shape) {
   assert(index < getNumInputs());
   _inputShapes[index] = shape;
 }
 
-const tensor::Shape &OpDescription::getOutputShape(const size_t index) const {
+const Shape &OpDescription::getOutputShape(const size_t index) const {
   assert(index < getNumOutputs());
   return _outputShapes.at(index);
 }
 
-void OpDescription::setOutputShape(const size_t index, const tensor::Shape &shape) {
+void OpDescription::setOutputShape(const size_t index, const Shape &shape) {
   assert(index < getNumOutputs());
   _outputShapes[index] = shape;
 }
diff --git a/contrib/nnc/libs/core/src/core/linalg/Index.cpp b/contrib/nnc/libs/core/src/core/linalg/Index.cpp
new file mode 100644 (file)
index 0000000..102006c
--- /dev/null
@@ -0,0 +1,38 @@
+#include "nnc/core/linalg/Index.h"
+
+#include <algorithm>
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+Index::Index(std::initializer_list<uint32_t> &&l) : _indices{l}
+{
+  // DO NOTHING
+}
+
+uint32_t Index::rank(void) const { return _indices.size(); }
+Index &Index::resize(uint32_t size)
+{
+  _indices.resize(size);
+  return *this;
+}
+
+Index &Index::fill(uint32_t index)
+{
+  std::fill(_indices.begin(), _indices.end(), index);
+  return (*this);
+}
+
+uint32_t &Index::at(uint32_t axis) { return _indices.at(axis); }
+uint32_t Index::at(uint32_t axis) const { return _indices.at(axis); }
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
diff --git a/contrib/nnc/libs/core/src/core/linalg/IndexEnumerator.cpp b/contrib/nnc/libs/core/src/core/linalg/IndexEnumerator.cpp
new file mode 100644 (file)
index 0000000..3953f5b
--- /dev/null
@@ -0,0 +1,84 @@
+#include "nnc/core/linalg/IndexEnumerator.h"
+
+#include <cassert>
+
+using nncc::contrib::core::data::Shape;
+
+inline uint32_t axis_of(const Shape &shape, uint32_t cursor)
+{
+  const uint32_t rank = shape.rank();
+  assert(cursor < rank);
+  return rank - cursor - 1;
+}
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+IndexEnumerator::IndexEnumerator(const Shape &shape) : _shape{shape}, _cursor(0)
+{
+  const uint32_t rank = _shape.rank();
+
+  // Initialize _index
+  _index.resize(rank);
+  for (uint32_t axis = 0; axis < rank; ++axis)
+  {
+    _index.at(axis) = 0;
+  }
+
+  // Initialize _cursor
+  for (_cursor = 0; _cursor < rank; ++_cursor)
+  {
+    const auto axis = axis_of(_shape, _cursor);
+
+    if (_index.at(axis) < _shape.dim(axis))
+    {
+      break;
+    }
+  }
+}
+
+void IndexEnumerator::advance(void)
+{
+  const uint32_t rank = _shape.rank();
+
+  // Find axis to be updated
+  while (_cursor < rank)
+  {
+    const auto axis = axis_of(_shape, _cursor);
+
+    if ((_index.at(axis)) + 1 < _shape.dim(axis))
+    {
+      break;
+    }
+
+    ++_cursor;
+  }
+
+  if (_cursor == rank)
+  {
+    return;
+  }
+
+  // Update index
+  _index.at(axis_of(_shape, _cursor)) += 1;
+
+  for (uint32_t pos = 0; pos < _cursor; ++pos)
+  {
+    const auto axis = axis_of(_shape, pos);
+    _index.at(axis) = 0;
+  }
+
+  // Reset cursor
+  _cursor = 0;
+}
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
diff --git a/contrib/nnc/libs/core/src/core/linalg/IndexRange.cpp b/contrib/nnc/libs/core/src/core/linalg/IndexRange.cpp
new file mode 100644 (file)
index 0000000..59e4cfe
--- /dev/null
@@ -0,0 +1,53 @@
+#include "nnc/core/linalg/IndexRange.h"
+#include "nnc/core/linalg/IndexEnumerator.h"
+
+#include <cassert>
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+IndexRange::IndexRange(const Shape &shape) : _shape(shape)
+{
+  // DO NOTHING
+}
+
+bool IndexRange::member(const Index &index) const
+{
+  if (index.rank() != _shape.rank())
+  {
+    return false;
+  }
+
+  const auto rank = _shape.rank();
+
+  for (uint32_t axis = 0; axis < rank; ++axis)
+  {
+    if (!(index.at(axis) < _shape.dim(axis)))
+    {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+void IndexRange::iterate(const std::function<void(const Index &)> &f) const
+{
+  for (IndexEnumerator e{_shape}; e.valid(); e.advance())
+  {
+    f(e.current());
+  }
+}
+
+IndexRange range(const Shape &shape) { return IndexRange{shape}; }
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
diff --git a/contrib/nnc/libs/core/src/core/linalg/Reader.cpp b/contrib/nnc/libs/core/src/core/linalg/Reader.cpp
new file mode 100644 (file)
index 0000000..3200830
--- /dev/null
@@ -0,0 +1,5 @@
+#include "nnc/core/linalg/Reader.h"
+
+// DO NOT REMOVE THIS FILE
+//
+// This file is introduced to check the self-completeness of 'Reader.h'
diff --git a/contrib/nnc/libs/core/src/core/linalg/Shape.cpp b/contrib/nnc/libs/core/src/core/linalg/Shape.cpp
new file mode 100644 (file)
index 0000000..abf2f14
--- /dev/null
@@ -0,0 +1,80 @@
+#include "nnc/core/linalg/Shape.h"
+
+#include <algorithm>
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace data
+{
+
+Shape::Shape(std::initializer_list<uint32_t> &&l) : _dims{l}
+{
+  // DO NOTHING
+}
+
+uint32_t Shape::rank(void) const { return _dims.size(); }
+Shape &Shape::resize(uint32_t size)
+{
+  _dims.resize(size);
+  return *this;
+}
+
+uint32_t &Shape::dim(uint32_t axis) { return _dims.at(axis); }
+uint32_t Shape::dim(uint32_t axis) const { return _dims.at(axis); }
+
+Shape &Shape::squeeze(void)
+{
+  _dims.erase(std::remove(_dims.begin(), _dims.end(), 1), _dims.end());
+  return *this;
+}
+
+uint64_t num_elements(const Shape &shape)
+{
+  if (shape.rank() == 0)
+  {
+    return 0;
+  }
+
+  uint64_t res = 1;
+
+  for (uint32_t axis = 0; axis < shape.rank(); ++axis)
+  {
+    res *= shape.dim(axis);
+  }
+
+  return res;
+}
+
+Shape squeeze(const Shape &shape)
+{
+  Shape res{shape};
+  res.squeeze();
+  return res;
+}
+
+bool operator==(const Shape &lhs, const Shape &rhs)
+{
+  if (lhs.rank() != rhs.rank())
+  {
+    return false;
+  }
+
+  for (uint32_t axis = 0; axis < lhs.rank(); ++axis)
+  {
+    if (lhs.dim(axis) != rhs.dim(axis))
+    {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+} // namespace data
+} // namespace core
+} // namespace contrib
+} // namespace nncc
index d594f9a..8ffb0fd 100644 (file)
@@ -25,7 +25,7 @@ using namespace ::caffe;
 using IrTensor = nncc::contrib::core::ADT::TensorVariant;
 using nncc::contrib::core::IR::model::Graph;
 using nncc::contrib::core::IR::model::ADT::INode;
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 class ModelVisitor : public Visitor
 {
index 61d9a3a..30e5f59 100644 (file)
@@ -10,7 +10,7 @@
 #include "nnc/core/IR/model/graph/ir_node.h"
 #include "nnc/core/linalg/TensorVariant.h"
 #include "nnc/core/IR/model/operations/common.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 #include "caffe/proto/caffe.pb.h"
 
@@ -29,7 +29,7 @@ namespace ops = nncc::contrib::core::IR::model::ops;
 using nncc::contrib::core::IR::model::Graph;
 using nncc::contrib::core::IR::model::ADT::INode;
 using IrTensor = nncc::contrib::core::ADT::TensorVariant;
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 class OpCreator
 {
index 878e09d..69442c4 100644 (file)
@@ -1,7 +1,7 @@
 #include <vector>
 #include <cassert>
 
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 #include "nnc/core/IR/model/operations/variable_op.h"
 #include "nnc/core/linalg/TensorUtil.h"
 #include "PluginException.h"
@@ -19,7 +19,7 @@ namespace caffe
 {
 
 using VariableOp = nncc::contrib::core::IR::model::ops::VariableOp;
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 using nncc::contrib::core::data::util::transposeTensor;
 
 void ModelVisitor::visit(const NetParameter& np)
index edd5210..e4a1c0a 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef NNCC_SHAPE_HELPER_H
 #define NNCC_SHAPE_HELPER_H
 
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 namespace nncc
 {
@@ -12,7 +12,7 @@ namespace frontend
 namespace common
 {
 
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 class ShapeHelper
 {
index c671a27..89b37b5 100644 (file)
@@ -10,7 +10,7 @@
 #include "nnc/core/IR/model/graph/graph.h"
 #include "nnc/core/IR/model/graph/ir_node.h"
 #include "nnc/core/linalg/TensorVariant.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 #include "nnc/core/IR/model/operations/common.h"
 
@@ -32,7 +32,7 @@ namespace ops = nncc::contrib::core::IR::model::ops;
 using nncc::contrib::core::IR::model::Graph;
 using nncc::contrib::core::IR::model::ADT::INode;
 using IrTensor = nncc::contrib::core::ADT::TensorVariant;
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 class OpCreator
 {
index 5da0232..471a1e2 100644 (file)
@@ -3,9 +3,9 @@
 
 #include "schema_v3.h"
 #include "PluginException.h"
-#include "nncc/core/ADT/tensor/Shape.h"
-#include "nncc/core/ADT/tensor/Index.h"
-#include "nncc/core/ADT/tensor/IndexRange.h"
+#include "nnc/core/linalg/Shape.h"
+#include "nnc/core/linalg/Index.h"
+#include "nnc/core/linalg/IndexRange.h"
 #include "nnc/core/linalg/TensorUtil.h"
 #include "nnc/core/IR/model/operations/variable_op.h"
 
@@ -22,10 +22,10 @@ namespace frontend
 namespace tflite
 {
 
-using nncc::core::ADT::tensor::Index;
-using nncc::core::ADT::tensor::IndexRange;
+using nncc::contrib::core::data::Index;
+using nncc::contrib::core::data::IndexRange;
 using VariableOp = nncc::contrib::core::IR::model::ops::VariableOp;
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 using nncc::contrib::core::data::util::transposeTensor;
 
 IrVisitor::IrVisitor()
index 714443c..2b118b1 100644 (file)
@@ -1,12 +1,12 @@
 #include "nnc/core/IR/model/graph/graph.h"
 #include "nnc/core/IR/model/actions/ShapeInference.h"
 #include "nnc/core/IR/model/operations/reshape_op.h"
-#include "nncc/core/ADT/tensor/Shape.h"
+#include "nnc/core/linalg/Shape.h"
 
 #include "gtest/gtest.h"
 
 using namespace nncc::contrib::core::IR::model;
-using nncc::core::ADT::tensor::Shape;
+using nncc::contrib::core::data::Shape;
 
 TEST(ShapeInferenceTest, ReshapeAutoDimension) {
   Graph g;
index 96e3282..1d94a9f 100644 (file)
@@ -1,10 +1,9 @@
 #include "nnc/core/linalg/TensorVariant.h"
-#include "nncc/core/ADT/feature/Shape.h"
 
 #include <gtest/gtest.h>
 
 using namespace nncc::contrib::core::ADT;
-using namespace nncc::core::ADT::tensor;
+using namespace nncc::contrib::core::data;
 
 TEST(TensorVariant, BasicTest) {
   Shape shape{2,2};
index ec52cd5..a4dbc8f 100644 (file)
@@ -1,7 +1,6 @@
 #include "nnc/core/IR/model/operations/operation.h"
 #include "nnc/core/IR/model/operations/reshape_op.h"
 #include "nnc/core/IR/model/graph/ir_node.h"
-#include "nncc/core/ADT/feature/Shape.h"
 
 #include <gtest/gtest.h>
 
index a11e3fc..35f34e5 100644 (file)
@@ -1,10 +1,9 @@
 #include "nnc/core/IR/model/operations/operation.h"
-#include "nncc/core/ADT/feature/Shape.h"
 
 #include <gtest/gtest.h>
 
 using namespace nncc::contrib::core::IR::model;
-using namespace nncc::core::ADT::tensor;
+using namespace nncc::contrib::core::data;
 
 TEST(OpDescription, InputOutputShapeTest) {
   Shape inShape{1,2,3};
index 2ad466b..685536e 100644 (file)
@@ -54,8 +54,7 @@
 using namespace std;
 using namespace nncc::contrib::backend::soft;
 using namespace nncc::contrib::core::IR::model; //  ShapeInference and Graph
-using namespace nncc::contrib::core; // data namespace for Tensor
-using namespace nncc::core::ADT; // for INode and TensorVariant tensor namespace for Index and Shape
+using namespace nncc::contrib::core; // data namespace for TensorVariant, Tensor, Index and Shape
 using namespace nncc::contrib::backend::interpreter;
 
 /*
@@ -99,7 +98,7 @@ INode *fillGraph(Graph &g, function<INode *(Graph &g)> opGen,
 }
 
 /** Fills NNC Shape object with data from src container*/
-void fillNShape(tensor::Shape &nshape, const vector<int> &rawShapeData)
+void fillNShape(data::Shape &nshape, const vector<int> &rawShapeData)
 {
   int shapeRank = rawShapeData.size();
   nshape.resize(shapeRank);
@@ -110,7 +109,7 @@ void fillNShape(tensor::Shape &nshape, const vector<int> &rawShapeData)
 }
 
 /** Converts NNC Shape to artifact Shape*/
-void copyAShapeFromNShape(Shape &ashape, const tensor::Shape &src)
+void copyAShapeFromNShape(Shape &ashape, const data::Shape &src)
 {
   int shapeRank = src.rank();
   ashape.setDims(shapeRank);
@@ -121,7 +120,7 @@ void copyAShapeFromNShape(Shape &ashape, const tensor::Shape &src)
 }
 
 /** Fills NNC and artifact Shape objects with data from rawShapeData*/
-void fillShapes(tensor::Shape &nshape, Shape &ashape, const vector<int> &rawShapeData)
+void fillShapes(data::Shape &nshape, Shape &ashape, const vector<int> &rawShapeData)
 {
   fillNShape(nshape, rawShapeData);
   copyAShapeFromNShape(ashape, nshape);
@@ -132,17 +131,17 @@ void fillNTensor(TensorVariant &dst, float start)
 {
   float t = start;
   data::Tensor<float> wrapper(dst);
-  for (tensor::Index idx: data::ShapeRange(dst.getShape()))
+  for (data::Index idx: data::ShapeRange(dst.getShape()))
   {
     wrapper.at(idx) = sin(t) * 2.0f;
     t += 1.0f;
   }
 }
 
-TensorVariant createNTensor(tensor::Shape &shape, float start)
+TensorVariant createNTensor(data::Shape &shape, float start)
 {
   shared_ptr<char> dataBuf(
-          new char[sizeof(float)*tensor::num_elements(shape)], default_delete<char[]>());
+          new char[sizeof(float)*data::num_elements(shape)], default_delete<char[]>());
   TensorVariant tensor(shape, dataBuf, TensorVariant::DTYPE::FLOAT, sizeof(float));
   fillNTensor(tensor, start);
   return tensor;
@@ -155,7 +154,7 @@ void copyATensorFromNTensor(Tensor &dst, TensorVariant &src)
   Index artIdx;
   int rank = src.getShape().rank();
   artIdx.setDims(rank);
-  for (tensor::Index idx: data::ShapeRange(src.getShape()))
+  for (data::Index idx: data::ShapeRange(src.getShape()))
   {
     for (int i = 0; i < rank; ++i)
     {
@@ -169,11 +168,11 @@ void copyATensorFromNTensor(Tensor &dst, TensorVariant &src)
 void fillTensors(unique_ptr<TensorVariant> &nTensor, Tensor &aTensor, const vector<int> &shape, float start)
 {
   Shape aShape;
-  tensor::Shape nShape;
+  data::Shape nShape;
   fillShapes(nShape, aShape, shape);
   aTensor.reShape(aShape);
   shared_ptr<char> dataBuf(
-          new char[sizeof(float)*tensor::num_elements(nShape)], default_delete<char[]>());
+          new char[sizeof(float)*data::num_elements(nShape)], default_delete<char[]>());
   nTensor.reset(new TensorVariant(nShape, dataBuf, TensorVariant::DTYPE::FLOAT, sizeof(float)));
   fillNTensor(*nTensor, start);
   copyATensorFromNTensor(aTensor, *nTensor);
@@ -203,7 +202,7 @@ Tensor run(Operation op, const Args &...args)
 /** Compares nnc TensorVariant and artifact Tensor objects*/
 void compareResults(const TensorVariant &refNTensor, const Tensor &testATensor)
 {
-  const tensor::Shape &tvShape = refNTensor.getShape();
+  const data::Shape &tvShape = refNTensor.getShape();
   const Shape &atShape = testATensor.getShape();
   ASSERT_EQ(tvShape.rank(), atShape.getDims());
   int rank = tvShape.rank();
@@ -213,7 +212,7 @@ void compareResults(const TensorVariant &refNTensor, const Tensor &testATensor)
   }
   Index artifactIdx;
   artifactIdx.setDims(rank);
-  for (tensor::Index tvIdx: data::ShapeRange(tvShape))
+  for (data::Index tvIdx: data::ShapeRange(tvShape))
   {
     for (int i = 0; i < rank; ++i)
     {
@@ -255,7 +254,7 @@ void createAndRunTestGraph(function<INode *(Graph &)> opGenerator, TestFunc arti
 TEST(cpp_operations_test, bias)
 {
   vector<int> inputShapeData{2, 3, 4, 5};
-  tensor::Shape weightsShape{5};
+  data::Shape weightsShape{5};
   vector<unique_ptr<TensorVariant>> inputNTensors(1);
   Tensor aInputTensor;
   fillTensors(inputNTensors[0], aInputTensor, inputShapeData, 1.0f);
@@ -314,8 +313,8 @@ TEST(cpp_operations_test, conv2d)
             for (iT strideW = 1; strideW <= 3; ++strideW)
             {
               vector<int> inputShapeData{5, 7, static_cast<int>(inputC)};  // HWC
-              tensor::Shape kernelShape{kernelH, kernelW, inputC, outputC}; // HWCN
-              tensor::Shape strides{strideH, strideW, 1};
+              data::Shape kernelShape{kernelH, kernelW, inputC, outputC}; // HWCN
+              data::Shape strides{strideH, strideW, 1};
               vector<unique_ptr<TensorVariant>> inputNTensors(1);
               Tensor aInputTensor;
               fillTensors(inputNTensors[0], aInputTensor, inputShapeData, 1.0f);
@@ -346,8 +345,8 @@ TEST(cpp_operations_tests, depthwise_conv)
             for (iT multiplier = 1; multiplier <= 2; ++multiplier)
             {
               vector<int> inputShapeData{5, 7, static_cast<int>(channels)};  // HWC
-              tensor::Shape kernelShape{kernelH, kernelW, channels, multiplier}; // HWCN
-              tensor::Shape strides{strideH, strideW, 1};
+              data::Shape kernelShape{kernelH, kernelW, channels, multiplier}; // HWCN
+              data::Shape strides{strideH, strideW, 1};
               vector<unique_ptr<TensorVariant>> inputNTensors(1);
               Tensor aInputTensor;
               fillTensors(inputNTensors[0], aInputTensor, inputShapeData, 1.0f);
@@ -364,7 +363,7 @@ TEST(cpp_operations_tests, depthwise_conv)
 TEST(cpp_operations_test, fully_connected)
 {
   vector<int> inputShapeData{1, 13};
-  tensor::Shape weightsShape{13, 7};
+  data::Shape weightsShape{13, 7};
   vector<unique_ptr<TensorVariant>> inputNTensors(1);
   Tensor aInputTensor;
   fillTensors(inputNTensors[0], aInputTensor, inputShapeData, 1.0f);
@@ -389,8 +388,8 @@ static void genericPoolTest(Func testFunc)
           for (iT strideW = 1; strideW <= 3; ++strideW)
           {
             vector<int> shapeData{5, 7, static_cast<int>(channels)};
-            tensor::Shape windowShape{windowH, windowW, 1};
-            tensor::Shape strides{strideH, strideW, 1};
+            data::Shape windowShape{windowH, windowW, 1};
+            data::Shape strides{strideH, strideW, 1};
             auto padT = IR::model::ops::PaddingType::Valid;
             Tensor aInputTensor;
             vector<unique_ptr<TensorVariant>> inputNTensors(1);
@@ -443,7 +442,7 @@ TEST(cpp_operations_test, reshape)
   // test prerequisites
   vector<int> inputShapeData{2,3,4,5};
   vector<int> outputShapeData{1,1,1,120};
-  tensor::Shape nOutputShape;
+  data::Shape nOutputShape;
   fillNShape(nOutputShape, outputShapeData);
   Tensor aInputTensor;
   vector<unique_ptr<TensorVariant>> inputNTensors(1);