aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIsabella Gottardi <isabella.gottardi@arm.com>2018-02-21 11:51:23 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:47:40 +0000
commitaad9f2c976ff9bb7022751f4ee8c659194d2b3a6 (patch)
treee2425aa0e7c8c982610b9917e464a1c3e37bc9b6 /src
parent2d0ce77a3415ef12fd2f74aefd3fc9851b5b5da8 (diff)
downloadComputeLibrary-aad9f2c976ff9bb7022751f4ee8c659194d2b3a6.tar.gz
COMPMID-754: Add CLPermute validation method
Change-Id: I77ed920a43738effd55b086e3138f497057a72c5 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/121618 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/CL/kernels/CLPermuteKernel.cpp21
-rw-r--r--src/core/NEON/kernels/NEPermuteKernel.cpp5
-rw-r--r--src/runtime/CL/functions/CLPermute.cpp7
3 files changed, 23 insertions, 10 deletions
diff --git a/src/core/CL/kernels/CLPermuteKernel.cpp b/src/core/CL/kernels/CLPermuteKernel.cpp
index 983754335e..12c2d58ef6 100644
--- a/src/core/CL/kernels/CLPermuteKernel.cpp
+++ b/src/core/CL/kernels/CLPermuteKernel.cpp
@@ -30,6 +30,7 @@
#include "arm_compute/core/Error.h"
#include "arm_compute/core/Helpers.h"
#include "arm_compute/core/Types.h"
+#include "arm_compute/core/utils/misc/ShapeCalculator.h"
#include "support/ToolchainSupport.h"
using namespace arm_compute;
@@ -54,13 +55,19 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, c
DataType::U32, DataType::S32,
DataType::F16, DataType::F32);
ARM_COMPUTE_RETURN_ERROR_ON_MSG((input->num_dimensions() < 3), "Invalid input size!");
- ARM_COMPUTE_RETURN_ERROR_ON_MSG(
- (perm.num_dimensions() != 3 && ((perm[0] != 2 && perm[1] != 0 && perm[2] != 1) || (perm[0] != 1 && perm[1] != 2 && perm[2] != 0))) && (perm.num_dimensions() != 4 && ((perm[0] != 2 && perm[1] != 0
- && perm[2] != 1)
- || (perm[0] != 1 && perm[1] != 2 && perm[2] != 0))),
- "Only [2, 0, 1],[1, 2, 0] and [3, 2, 0, 1] permutation is supported");
+ ARM_COMPUTE_RETURN_ERROR_ON_MSG(((perm.num_dimensions() == 3 && !(perm[0] == 2 && perm[1] == 0 && perm[2] == 1) && !(perm[0] == 1 && perm[1] == 2 && perm[2] == 0)) || (perm.num_dimensions() == 4
+ && !(perm[0] == 3 && perm[1] == 2 && perm[2] == 0 && perm[3] == 1))),
+ "Only [2, 0, 1],[1, 2, 0] and [3, 2, 0, 1] permutation is supported");
- ARM_COMPUTE_UNUSED(output);
+ const TensorShape output_shape = misc::shape_calculator::compute_permutation_output_shape(*input, perm);
+
+ // Validate configured output
+ if(output->total_size() != 0)
+ {
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), output_shape);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_FIXED_POINT(input, output);
+ }
return Status{};
}
} // namespace
@@ -112,7 +119,7 @@ void CLPermuteKernel::configure(const ICLTensor *input, ICLTensor *output, const
Status CLPermuteKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm)
{
- ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
ARM_COMPUTE_RETURN_ERROR_ON(validate_arguments(input, output, perm));
return Status{};
diff --git a/src/core/NEON/kernels/NEPermuteKernel.cpp b/src/core/NEON/kernels/NEPermuteKernel.cpp
index 87e5e7487a..ae1d48cc69 100644
--- a/src/core/NEON/kernels/NEPermuteKernel.cpp
+++ b/src/core/NEON/kernels/NEPermuteKernel.cpp
@@ -49,9 +49,8 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, c
DataType::U16, DataType::S16, DataType::QS16,
DataType::U32, DataType::S32,
DataType::F16, DataType::F32);
- ARM_COMPUTE_RETURN_ERROR_ON_MSG(
- (perm.num_dimensions() != 3 && ((perm[0] != 2 && perm[1] != 0 && perm[2] != 1) || (perm[0] != 1 && perm[1] != 2 && perm[2] != 0))),
- "Only [2, 0, 1] and [1, 2, 0] permutation is supported");
+ ARM_COMPUTE_RETURN_ERROR_ON_MSG((perm.num_dimensions() == 3 && !(perm[0] == 2 && perm[1] == 0 && perm[2] == 1) && !(perm[0] == 1 && perm[1] == 2 && perm[2] == 0)),
+ "Only [2, 0, 1] and [1, 2, 0] permutation is supported");
const TensorShape output_shape = misc::shape_calculator::compute_permutation_output_shape(*input, perm);
diff --git a/src/runtime/CL/functions/CLPermute.cpp b/src/runtime/CL/functions/CLPermute.cpp
index f23e231e9e..146856cd77 100644
--- a/src/runtime/CL/functions/CLPermute.cpp
+++ b/src/runtime/CL/functions/CLPermute.cpp
@@ -25,6 +25,7 @@
#include "arm_compute/core/CL/ICLTensor.h"
#include "arm_compute/core/CL/kernels/CLPermuteKernel.h"
+#include "arm_compute/core/Error.h"
#include "support/ToolchainSupport.h"
using namespace arm_compute;
@@ -34,4 +35,10 @@ void CLPermute::configure(const ICLTensor *input, ICLTensor *output, const Permu
auto k = arm_compute::support::cpp14::make_unique<CLPermuteKernel>();
k->configure(input, output, perm);
_kernel = std::move(k);
+}
+
+Status CLPermute::validate(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm)
+{
+ ARM_COMPUTE_RETURN_ERROR_ON(CLPermuteKernel::validate(input, output, perm));
+ return Status{};
} \ No newline at end of file