Introduce dummy STRIDED_SLICE kernel to pure_arm_compute (#1497)
author최형규/동작제어Lab(SR)/Staff Engineer/삼성전자 <hk0110.choi@samsung.com>
Fri, 1 Jun 2018 08:11:19 +0000 (17:11 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 1 Jun 2018 08:11:19 +0000 (17:11 +0900)
- Introduce dummy STRIDED_SLICE kernel to pure_arm_compute

Signed-off-by: Hyung-Kyu Choi <hk0110.choi@samsung.com>
runtimes/pure_arm_compute/src/compilation.cc
runtimes/pure_arm_compute/src/internal/op/NodeVisitor.h
runtimes/pure_arm_compute/src/internal/op/StridedSlice.cc [new file with mode: 0644]
runtimes/pure_arm_compute/src/internal/op/StridedSlice.h [new file with mode: 0644]

index 6080463..bb47bfa 100644 (file)
@@ -11,6 +11,7 @@
 #include <arm_compute/runtime/CL/functions/CLActivationLayer.h>
 #include <arm_compute/runtime/CL/functions/CLScale.h>
 #include <arm_compute/runtime/CL/functions/CLReshapeLayer.h>
+#include <arm_compute/runtime/CL/functions/CLStridedSlice.h>
 #include <arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h>
 #include <arm_compute/runtime/CL/functions/CLSoftmaxLayer.h>
 
@@ -277,6 +278,7 @@ public:
   void visit(const ::internal::tflite::op::ResizeBilinear::Node &node) override;
   void visit(const ::internal::tflite::op::Reshape::Node &node) override;
   void visit(const ::internal::tflite::op::Softmax::Node &node) override;
+  void visit(const ::internal::tflite::op::StridedSlice::Node &node) override;
   void visit(const ::internal::tflite::op::Max::Node &node) override;
 
 private:
@@ -1063,6 +1065,13 @@ void Planner::visit(const ::internal::tflite::op::Softmax::Node &node)
   _builder.addStage(stage);
 }
 
+void Planner::visit(const ::internal::tflite::op::StridedSlice::Node &node)
+{
+  VERBOSE(StridedSlice) << "Configure STRIDED_SLICE operation" << std::endl;
+
+  throw std::runtime_error{"STRIDED_SLICE is not implemented yet"};
+}
+
 void Planner::visit(const ::internal::tflite::op::Max::Node &node)
 {
   VERBOSE(Max) << "Configure MAX operation" << std::endl;
index e547ea2..1faaf24 100644 (file)
@@ -9,6 +9,7 @@
 #include "internal/op/Concat.h"
 #include "internal/op/Reshape.h"
 #include "internal/op/ResizeBilinear.h"
+#include "internal/op/StridedSlice.h"
 #include "internal/op/FullyConnected.h"
 #include "internal/op/Softmax.h"
 #include "internal/op/Max.h"
@@ -32,6 +33,7 @@ struct NodeVisitor
   virtual void visit(const Concat::Node &) = 0;
   virtual void visit(const Reshape::Node &) = 0;
   virtual void visit(const ResizeBilinear::Node &) = 0;
+  virtual void visit(const StridedSlice::Node &) = 0;
   virtual void visit(const FullyConnected::Node &) = 0;
   virtual void visit(const Softmax::Node &) = 0;
   virtual void visit(const Max::Node &) = 0;
diff --git a/runtimes/pure_arm_compute/src/internal/op/StridedSlice.cc b/runtimes/pure_arm_compute/src/internal/op/StridedSlice.cc
new file mode 100644 (file)
index 0000000..fbfee4a
--- /dev/null
@@ -0,0 +1,72 @@
+#include "internal/op/StridedSlice.h"
+#include "internal/op/NodeVisitor.h"
+
+#include <cassert>
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace StridedSlice
+{
+
+void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
+
+} // namespace StridedSlice
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace StridedSlice
+{
+
+Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount,
+             const uint32_t *outputs)
+{
+  assert(inputCount == 2 && outputCount == 1);
+
+  outputData_index = outputs[0];
+
+  // Each input should be interpreted as follows:
+  //
+  //  0 -> An n-D tensor, specifying the tensor to be sliced.
+  //  1 -> A 1-D Tensor of {@link ANEURALNETWORKS_TENSOR_INT32}, the starts of
+  //       the dimensions of the input tensor to be sliced. The length must be
+  //       of rank(input0).
+  //  2 -> A 1-D Tensor of {@link ANEURALNETWORKS_TENSOR_INT32}, the ends of
+  //       the dimensions of the input tensor to be sliced. The length must be
+  //       of rank(input0).
+  //  3 -> A 1-D Tensor of {@link ANEURALNETWORKS_TENSOR_INT32}, the strides of
+  //       the dimensions of the input tensor to be sliced. The length must be
+  //       of rank(input0).
+  //  4 -> An {@link ANEURALNETWORKS_INT32} scalar, begin_mask. If the ith bit
+  //       of begin_mask is set, begin[i] is ignored and the fullest possible
+  //       range in that dimension is used instead.
+  //  5 -> An {@link ANEURALNETWORKS_INT32} scalar, end_mask. If the ith bit of
+  //       end_mask is set, end[i] is ignored and the fullest possible range in
+  //       that dimension is used instead.
+  //  6 -> An {@link ANEURALNETWORKS_INT32} scalar, shrink_axis_mask. An int32
+  //       mask. If the ith bit of shrink_axis_mask is set, it implies that the
+  //       ith specification shrinks the dimensionality by 1. A slice of size 1
+  //       starting from begin[i] in the dimension must be preserved.
+  inputData_index = inputs[0];
+  startData_index = inputs[1];
+  endData_index = inputs[2];
+  stridesData_index = inputs[3];
+  beginMask_index = inputs[4];
+  endMask_index_index = inputs[5];
+  shrinkAxisMask_index = inputs[6];
+}
+
+} // namespace StridedSlice
+} // namespace op
+} // namespace tflite
+} // namespace internal
diff --git a/runtimes/pure_arm_compute/src/internal/op/StridedSlice.h b/runtimes/pure_arm_compute/src/internal/op/StridedSlice.h
new file mode 100644 (file)
index 0000000..887bb5a
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef __INTERNAL_OP_STRIDEDSLICE_H__
+#define __INTERNAL_OP_STRIDEDSLICE_H__
+
+#include "internal/op/Node.h"
+
+#include <cstdint>
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace StridedSlice
+{
+
+struct Param
+{
+  int32_t outputData_index;
+
+  int32_t inputData_index;
+  int32_t startData_index;
+  int32_t endData_index;
+  int32_t stridesData_index;
+  int32_t beginMask_index;
+  int32_t endMask_index_index;
+  int32_t shrinkAxisMask_index;
+
+  Param() = default;
+  Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs);
+};
+
+class Node final : public op::Node
+{
+public:
+  Node(const Param &param) : _param(param)
+  {
+    // DO NOTHING
+  }
+
+public:
+  virtual ~Node() = default;
+
+public:
+  const Param &param(void) const { return _param; }
+
+public:
+  void accept(NodeVisitor &&) const override;
+
+private:
+  const Param _param;
+};
+
+} // namespace StridedSlice
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+#endif // __INTERNAL_OP_STRIDEDSLICE_H__