Add Conv2D operation desсription class (#280)
authorVladimir Plazun/AI Tools Lab/Engineer/삼성전자 <v.plazun@partner.samsung.com>
Fri, 1 Jun 2018 14:11:48 +0000 (18:11 +0400)
committerSergey Vostokov/AI Tools Lab/Staff Engineer/삼성전자 <s.vostokov@samsung.com>
Fri, 1 Jun 2018 14:11:48 +0000 (17:11 +0300)
Add Conv2D operation desription class

This class is used to represent 2d convolution operation in computation graph

Signed-off-by: Vladimir Plazun <v.plazun@partner.samsung.com>
contrib/nnc/libs/core/include/nnc/core/IR/model/operations/common.h [new file with mode: 0644]
contrib/nnc/libs/core/include/nnc/core/IR/model/operations/conv_2d_op.h [new file with mode: 0644]

diff --git a/contrib/nnc/libs/core/include/nnc/core/IR/model/operations/common.h b/contrib/nnc/libs/core/include/nnc/core/IR/model/operations/common.h
new file mode 100644 (file)
index 0000000..5dd17ba
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef _NNC_CORE_IR_MODEL_COMMON_H_
+#define _NNC_CORE_IR_MODEL_COMMON_H_
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace IR
+{
+namespace model
+{
+namespace ops
+{
+
+enum class PaddingType {
+  Same,
+  Valid //no padding
+};
+
+} // namespace ops
+} // namespace model
+} // namespace IR
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif //_NNC_CORE_IR_MODEL_COMMOND_H_
diff --git a/contrib/nnc/libs/core/include/nnc/core/IR/model/operations/conv_2d_op.h b/contrib/nnc/libs/core/include/nnc/core/IR/model/operations/conv_2d_op.h
new file mode 100644 (file)
index 0000000..9a086a9
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef _NNC_CORE_IR_MODEL_CONV_2D_H_
+#define _NNC_CORE_IR_MODEL_CONV_2D_H_
+
+#include <vector>
+
+#include "nnc/core/IR/model/operations/operation.h"
+#include "nnc/core/IR/model/operations/common.h"
+#include "nnc/core/linalg/TensorVariant.h"
+
+#include "nncc/core/ADT/tensor/Shape.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace core
+{
+namespace IR
+{
+namespace model
+{
+namespace ops
+{
+
+using nncc::core::ADT::tensor::Shape;
+
+class Conv2DOp : public OpDescription
+{
+public:
+  Conv2DOp(const ADT::TensorVariant &kernel, const Shape &strides, PaddingType padding)
+      : OpDescription(1, 1), _kernel(kernel), _strides(strides),
+        _padding(padding)
+  {
+    _pads.resize(3);
+  }
+
+  const ADT::TensorVariant &getKernel() const { return _kernel; }
+
+  const Shape &getStrides() const { return _strides; }
+
+  PaddingType getPaddingType() const { return _padding; }
+
+  int getPadding(int dim) const { return _pads[dim]; }
+
+  void setPadding(int dim, int pad) { _pads[dim] = pad; }
+
+private:
+  const ADT::TensorVariant _kernel;
+  Shape _strides;
+  PaddingType _padding;
+  std::vector<int> _pads;
+};
+
+} // namespace ops
+} // namespace model
+} // namespace IR
+} // namespace core
+} // namespace contrib
+} // namespace nncc
+
+#endif //_NNC_CORE_IR_MODEL_CONV_2D_H_