aboutsummaryrefslogtreecommitdiff
path: root/arm_compute
diff options
context:
space:
mode:
authorPablo Tello <pablo.tello@arm.com>2018-11-22 16:14:36 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2018-12-21 18:28:31 +0000
commit543036904d5324c4738cdc8b586c301471046c8e (patch)
tree680efe9d7d02b23a0453495c13f4ece5d0a0edbd /arm_compute
parent8b6b4a959a49127d64293f8b60265f0f5ed486d4 (diff)
downloadComputeLibrary-543036904d5324c4738cdc8b586c301471046c8e.tar.gz
COMPMID-1726: Implement CLUnstack.
Change-Id: I94b0707d19757c5f5d7ca66d9c47e378867126a3 Reviewed-on: https://review.mlplatform.org/325 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'arm_compute')
-rw-r--r--arm_compute/core/utils/misc/ShapeCalculator.h7
-rw-r--r--arm_compute/runtime/CL/CLFunctions.h1
-rw-r--r--arm_compute/runtime/CL/functions/CLUnstack.h76
3 files changed, 84 insertions, 0 deletions
diff --git a/arm_compute/core/utils/misc/ShapeCalculator.h b/arm_compute/core/utils/misc/ShapeCalculator.h
index adf5309ea5..4756ff4f97 100644
--- a/arm_compute/core/utils/misc/ShapeCalculator.h
+++ b/arm_compute/core/utils/misc/ShapeCalculator.h
@@ -803,6 +803,13 @@ inline TensorShape extract_shape(const TensorShape *data)
return *data;
}
+inline TensorShape calculate_unstack_shape(TensorShape input_shape, unsigned int axis)
+{
+ ARM_COMPUTE_ERROR_ON(axis > input_shape.num_dimensions());
+ input_shape.remove_dimension(axis);
+ return input_shape;
+}
+
template <typename T>
inline TensorShape calculate_depth_concatenate_shape(const std::vector<T *> &inputs_vector)
{
diff --git a/arm_compute/runtime/CL/CLFunctions.h b/arm_compute/runtime/CL/CLFunctions.h
index 303a8989a9..e0cf65b923 100644
--- a/arm_compute/runtime/CL/CLFunctions.h
+++ b/arm_compute/runtime/CL/CLFunctions.h
@@ -134,6 +134,7 @@
#include "arm_compute/runtime/CL/functions/CLThreshold.h"
#include "arm_compute/runtime/CL/functions/CLTile.h"
#include "arm_compute/runtime/CL/functions/CLTranspose.h"
+#include "arm_compute/runtime/CL/functions/CLUnstack.h"
#include "arm_compute/runtime/CL/functions/CLUpsampleLayer.h"
#include "arm_compute/runtime/CL/functions/CLWarpAffine.h"
#include "arm_compute/runtime/CL/functions/CLWarpPerspective.h"
diff --git a/arm_compute/runtime/CL/functions/CLUnstack.h b/arm_compute/runtime/CL/functions/CLUnstack.h
new file mode 100644
index 0000000000..feed430c58
--- /dev/null
+++ b/arm_compute/runtime/CL/functions/CLUnstack.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_CLUNSTACK_H__
+#define __ARM_COMPUTE_CLUNSTACK_H__
+
+#include "arm_compute/core/CL/OpenCL.h"
+#include "arm_compute/core/Types.h"
+#include "arm_compute/runtime/IFunction.h"
+
+#include "arm_compute/runtime/CL/functions/CLStridedSlice.h"
+
+#include <memory>
+
+namespace arm_compute
+{
+class ICLTensor;
+
+/** Basic function to unpack a rank-R tensor into rank-(R-1) tensors. This function calls the following functions:
+ *
+ * -# @ref CLStridedSlice
+ *
+ */
+class CLUnstack : public IFunction
+{
+public:
+ /** Default constructor */
+ CLUnstack();
+ /** Set the input, output and unstacking axis.
+ *
+ * @param[in] input A tensor to be unstacked. Data type supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32.
+ * @param[in,out] output_vector A vector of tensors. Data types supported: Same as @p input.
+ * Note: The number of elements of the vector will be used as the number of slices to be taken from the axis.
+ * @param[in] axis The axis to unstack along. Valid values are [-R,R) where R is the input's rank. Negative values wrap around.
+ *
+ */
+ void configure(const ICLTensor *input, const std::vector<ICLTensor *> &output_vector, int axis);
+ /** Static function to check if given info will lead to a valid configuration of @ref CLUnstack
+ *
+ * @param[in] input Input tensor info. Data type supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32
+ * @param[in] output_vector Vector of output tensors' info. Data types supported: Same as @p input.
+ * @param[in] axis The axis to unstack along. Valid values are [-R,R) where R is the input's rank. Negative values wrap around.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const std::vector<ITensorInfo *> &output_vector, int axis);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ unsigned int _num_slices;
+ std::unique_ptr<CLStridedSlice[]> _strided_slice_vector;
+};
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_CLUNSTACK_H__ */