Add dynamic tensor support to CpuElementwise
The kernels and operators for binary and unary operations
are now capable of being configured with dynamic shapes and
computing windows at run-time.
Additionally, changing arguments' names is done
for consistency.
Partially Implements: COMPMID-4127
Change-Id: I48e5038692db667dec7cb2b2906fe5683214fe19
Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4973
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
diff --git a/arm_compute/core/IKernel.h b/arm_compute/core/IKernel.h
index 11132f2..98fd18c 100644
--- a/arm_compute/core/IKernel.h
+++ b/arm_compute/core/IKernel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2019 Arm Limited.
+ * Copyright (c) 2016-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -57,6 +57,11 @@
* @return The maximum window the kernel can be executed on.
*/
const Window &window() const;
+ /** Function to check if the embedded window of this kernel has been configured
+ *
+ * @return True if the windows has been configured
+ */
+ bool is_window_configured() const;
protected:
/** Configure the kernel's window
diff --git a/arm_compute/core/ITensorInfo.h b/arm_compute/core/ITensorInfo.h
index 9ddafce..0171e31 100644
--- a/arm_compute/core/ITensorInfo.h
+++ b/arm_compute/core/ITensorInfo.h
@@ -41,8 +41,24 @@
{
public:
using TensorDimsState = Coordinates;
-
-public:
+ /** Get the value representing dynamic dimension state
+ *
+ * @return Value representing dynamic dimension state
+ *
+ */
+ static constexpr int32_t get_dynamic_state_value()
+ {
+ return _dynamic_dimension;
+ }
+ /** Get the value representing static dimension state
+ *
+ * @return Value representing static dimension state
+ *
+ */
+ static constexpr int32_t get_static_state_value()
+ {
+ return _static_dimension;
+ }
/** Default virtual destructor */
virtual ~ITensorInfo() = default;
/** Set the data type to the specified value.
@@ -297,6 +313,10 @@
return std::pair<TensorShape, ValidRegion>(bc_shape, bc_valid_region);
}
+
+private:
+ static constexpr int32_t _dynamic_dimension = -1;
+ static constexpr int32_t _static_dimension = 0;
};
} // namespace arm_compute
#endif /*ARM_COMPUTE_TENSORINFO_H */
diff --git a/arm_compute/core/TensorInfo.h b/arm_compute/core/TensorInfo.h
index 42a969e..633daca 100644
--- a/arm_compute/core/TensorInfo.h
+++ b/arm_compute/core/TensorInfo.h
@@ -293,7 +293,7 @@
}
bool is_dynamic() const override
{
- return std::find(std::cbegin(_dims_state), std::cend(_dims_state), -1) != std::cend(_dims_state);
+ return std::find(std::cbegin(_dims_state), std::cend(_dims_state), get_dynamic_state_value()) != std::cend(_dims_state);
}
ITensorInfo &set_is_resizable(bool is_resizable) override
{
diff --git a/arm_compute/runtime/NEON/INEOperator.h b/arm_compute/runtime/NEON/INEOperator.h
index b21dc49..184a595 100644
--- a/arm_compute/runtime/NEON/INEOperator.h
+++ b/arm_compute/runtime/NEON/INEOperator.h
@@ -34,6 +34,8 @@
namespace arm_compute
{
class ICPPKernel;
+class Window;
+
using INEKernel = ICPPKernel;
namespace experimental
{
@@ -63,6 +65,8 @@
MemoryRequirements workspace() const override;
protected:
+ void run(ITensorPack &tensors, const Window &window);
+
std::unique_ptr<INEKernel> _kernel;
IRuntimeContext *_ctx;
MemoryRequirements _workspace;