aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGeorge Wort <george.wort@arm.com>2019-01-16 11:39:57 +0000
committerGeorge Wort <george.wort@arm.com>2019-01-23 15:15:20 +0000
commitdc9b52867b26e59ba34365f53820ddd7edf01ded (patch)
treef5fbd33c9bc04c1c46a37b975e5d07e3045e1b34 /tests
parent1d4f3853dfd16f55338d772ad757db0ee8710d78 (diff)
downloadComputeLibrary-dc9b52867b26e59ba34365f53820ddd7edf01ded.tar.gz
COMPMID-1795: Add support for NHWC in CLGenerateProposalsLayer
Change-Id: Idd805513783fa1323e239eac8a899d8ab04fb14f Reviewed-on: https://review.mlplatform.org/536 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/validation/CL/GenerateProposalsLayer.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/tests/validation/CL/GenerateProposalsLayer.cpp b/tests/validation/CL/GenerateProposalsLayer.cpp
index b4772fcf79..ac2d0ef969 100644
--- a/tests/validation/CL/GenerateProposalsLayer.cpp
+++ b/tests/validation/CL/GenerateProposalsLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 ARM Limited.
+ * Copyright (c) 2018-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -24,6 +24,7 @@
#include "arm_compute/runtime/CL/CLScheduler.h"
#include "arm_compute/runtime/CL/functions/CLComputeAllAnchors.h"
#include "arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h"
+#include "arm_compute/runtime/CL/functions/CLPermute.h"
#include "arm_compute/runtime/CL/functions/CLSlice.h"
#include "tests/CL/CLAccessor.h"
#include "tests/CL/CLArrayAccessor.h"
@@ -48,6 +49,31 @@ inline void fill_tensor(U &&tensor, const std::vector<T> &v)
std::memcpy(tensor.data(), v.data(), sizeof(T) * v.size());
}
+template <typename T>
+inline void fill_tensor(CLAccessor &&tensor, const std::vector<T> &v)
+{
+ if(tensor.data_layout() == DataLayout::NCHW)
+ {
+ std::memcpy(tensor.data(), v.data(), sizeof(T) * v.size());
+ }
+ else
+ {
+ const int channels = tensor.shape()[0];
+ const int width = tensor.shape()[1];
+ const int height = tensor.shape()[2];
+ for(int x = 0; x < width; ++x)
+ {
+ for(int y = 0; y < height; ++y)
+ {
+ for(int c = 0; c < channels; ++c)
+ {
+ *(reinterpret_cast<T *>(tensor(Coordinates(c, x, y)))) = *(reinterpret_cast<const T *>(v.data() + x + y * width + c * height * width));
+ }
+ }
+ }
+ }
+}
+
const auto ComputeAllInfoDataset = framework::dataset::make("ComputeAllInfo",
{
ComputeAnchorsInfo(10U, 10U, 1. / 16.f),
@@ -165,8 +191,9 @@ DATA_TEST_CASE(IntegrationTestCaseAllAnchors, framework::DatasetMode::ALL, frame
validate(CLAccessor(all_anchors), anchors_expected);
}
-DATA_TEST_CASE(IntegrationTestCaseGenerateProposals, framework::DatasetMode::ALL, framework::dataset::make("DataType", { DataType::F32 }),
- data_type)
+DATA_TEST_CASE(IntegrationTestCaseGenerateProposals, framework::DatasetMode::ALL, combine(framework::dataset::make("DataType", { DataType::F32 }),
+ framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
+ data_type, data_layout)
{
const int values_per_roi = 4;
const int num_anchors = 2;
@@ -260,9 +287,17 @@ DATA_TEST_CASE(IntegrationTestCaseGenerateProposals, framework::DatasetMode::ALL
8.91025957e-06f
});
+ TensorShape scores_shape = TensorShape(feature_width, feature_height, num_anchors);
+ TensorShape deltas_shape = TensorShape(feature_width, feature_height, values_per_roi * num_anchors);
+ if(data_layout == DataLayout::NHWC)
+ {
+ permute(scores_shape, PermutationVector(2U, 0U, 1U));
+ permute(deltas_shape, PermutationVector(2U, 0U, 1U));
+ }
+
// Inputs
- CLTensor scores = create_tensor<CLTensor>(TensorShape(feature_width, feature_height, num_anchors), data_type);
- CLTensor bbox_deltas = create_tensor<CLTensor>(TensorShape(feature_width, feature_height, values_per_roi * num_anchors), data_type);
+ CLTensor scores = create_tensor<CLTensor>(scores_shape, data_type, 1, QuantizationInfo(), data_layout);
+ CLTensor bbox_deltas = create_tensor<CLTensor>(deltas_shape, data_type, 1, QuantizationInfo(), data_layout);
CLTensor anchors = create_tensor<CLTensor>(TensorShape(values_per_roi, num_anchors), data_type);
// Outputs
@@ -282,7 +317,6 @@ DATA_TEST_CASE(IntegrationTestCaseGenerateProposals, framework::DatasetMode::ALL
proposals.allocator()->allocate();
num_valid_proposals.allocator()->allocate();
scores_out.allocator()->allocate();
-
// Fill inputs
fill_tensor(CLAccessor(scores), scores_vector);
fill_tensor(CLAccessor(bbox_deltas), bbx_vector);
@@ -290,7 +324,6 @@ DATA_TEST_CASE(IntegrationTestCaseGenerateProposals, framework::DatasetMode::ALL
// Run operator
generate_proposals.run();
-
// Gather num_valid_proposals
num_valid_proposals.map();
const uint32_t N = *reinterpret_cast<uint32_t *>(num_valid_proposals.ptr_to_element(Coordinates(0, 0)));