[nuerun] Introduce checking padding of the tensor. (#4647)
author장지섭/On-Device Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Mon, 11 Mar 2019 10:49:27 +0000 (19:49 +0900)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 11 Mar 2019 10:49:27 +0000 (19:49 +0900)
This commit introduce checking padding of the tensor.

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
runtimes/neurun/src/backend/acl_cl/operand/ICLTensor.cc
runtimes/neurun/src/backend/acl_cl/operand/ICLTensor.h
runtimes/neurun/src/backend/cpu/operand/Tensor.h
runtimes/neurun/src/backend/interface/operand/ITensor.h
runtimes/neurun/src/exec/Sink.h
runtimes/neurun/src/exec/Source.h

index 23d723d..7c30078 100644 (file)
@@ -26,6 +26,8 @@ size_t ICLTensor::calcOffset(const neurun::util::feature::Coordinate4D &coords)
   return info()->offset_element_in_bytes(coordinates);
 }
 
+bool ICLTensor::has_padding() const { return info()->has_padding(); }
+
 arm_compute::DataType ICLTensor::data_type() const { return info()->data_type(); }
 
 uint8_t *ICLTensor::buffer() const { return handle()->buffer(); }
index 226fbf8..e8abfc4 100644 (file)
@@ -50,6 +50,7 @@ public:
   size_t dimension(size_t index) const override;
   size_t num_dimensions() const override;
   size_t calcOffset(const neurun::util::feature::Coordinate4D &coords) override;
+  bool has_padding() const override;
 
 public:
   arm_compute::DataType data_type() const;
index 7500f89..a45ed1f 100644 (file)
@@ -60,6 +60,7 @@ public:
   size_t num_dimensions() const override { return _info.shape().dims().size(); }
   size_t total_size() const override { return _info.total_size(); }
   size_t calcOffset(const neurun::util::feature::Coordinate4D &coords) override;
+  bool has_padding() const override { return false; }
 
 private:
   compiler::TensorInfo _info;
index 8bc3ff4..a5db68c 100644 (file)
@@ -40,6 +40,7 @@ public:
   virtual size_t dimension(size_t index) const = 0;
   virtual size_t num_dimensions() const = 0;
   virtual size_t calcOffset(const neurun::util::feature::Coordinate4D &coords) = 0;
+  virtual bool has_padding() const = 0;
 };
 
 } // namespace operand
index 029e926..6f35a34 100644 (file)
@@ -68,6 +68,12 @@ public:
     auto input_buffer = tensor.buffer();
     auto rank = _shape.rank();
 
+    if (!tensor.has_padding() && rank < 4)
+    {
+      memcpy(_output_buffer, input_buffer, _output_size);
+      return;
+    }
+
     switch (rank)
     {
       case 0:
index 1a3588d..fcd09ca 100644 (file)
@@ -71,6 +71,12 @@ public:
     auto output_buffer = tensor.buffer();
     auto rank = _shape.rank();
 
+    if (!tensor.has_padding() && rank < 4)
+    {
+      memcpy(output_buffer, _input_buffer, _input_size);
+      return;
+    }
+
     switch (rank)
     {
       case 0: