aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2017-08-23 16:36:24 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commit9fe414430c3c989b1cdc79d41e031495aed2cb7c (patch)
tree5f893eeb81fe75824918273f49171c85f108fe4e /tests
parent580f4c7f6c2cbe320c606eb6ba73b3f4a20791ef (diff)
downloadComputeLibrary-9fe414430c3c989b1cdc79d41e031495aed2cb7c.tar.gz
COMPMID-452 CL Generic Depthwise Convolution implementation.
Change-Id: I115e48fe6ce5e281f3791aa5d80fdc754cdd2b5e Reviewed-on: http://mpd-gerrit.cambridge.arm.com/85082 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/benchmark/CL/DepthwiseConvolution.cpp2
-rw-r--r--tests/benchmark/CL/DepthwiseSeparableConvolutionLayer.cpp2
-rw-r--r--tests/datasets/DepthwiseConvolutionDataset.h28
-rw-r--r--tests/datasets/LargeDepthwiseConvolutionDataset.h56
-rw-r--r--tests/datasets/SmallDepthwiseConvolutionDataset.h56
-rw-r--r--tests/validation/CL/DepthwiseConvolution.cpp9
-rw-r--r--tests/validation/CPP/DepthwiseConvolution.cpp47
7 files changed, 60 insertions, 140 deletions
diff --git a/tests/benchmark/CL/DepthwiseConvolution.cpp b/tests/benchmark/CL/DepthwiseConvolution.cpp
index acdc4019b4..a8c229fad8 100644
--- a/tests/benchmark/CL/DepthwiseConvolution.cpp
+++ b/tests/benchmark/CL/DepthwiseConvolution.cpp
@@ -44,7 +44,7 @@ TEST_SUITE(CL)
REGISTER_FIXTURE_DATA_TEST_CASE(MobileNetDepthwiseConvolution, CLDepthwiseConvolutionFixture, framework::DatasetMode::ALL,
framework::dataset::combine(framework::dataset::combine(datasets::MobileNetDepthwiseConvolutionDataset(), data_types),
- framework::dataset::make("Batches", { 1, 4, 8 })));
+ framework::dataset::make("Batches", { 1 })));
TEST_SUITE_END()
} // namespace test
diff --git a/tests/benchmark/CL/DepthwiseSeparableConvolutionLayer.cpp b/tests/benchmark/CL/DepthwiseSeparableConvolutionLayer.cpp
index 1ab8628435..0c4fbb18bd 100644
--- a/tests/benchmark/CL/DepthwiseSeparableConvolutionLayer.cpp
+++ b/tests/benchmark/CL/DepthwiseSeparableConvolutionLayer.cpp
@@ -44,7 +44,7 @@ TEST_SUITE(CL)
REGISTER_FIXTURE_DATA_TEST_CASE(MobileNetDepthwiseSeparableConvolutionLayer, CLDepthwiseSeparableConvolutionLayerFixture, framework::DatasetMode::ALL,
framework::dataset::combine(framework::dataset::combine(datasets::MobileNetDepthwiseSeparableConvolutionLayerDataset(), data_types),
- framework::dataset::make("Batches", { 1, 4, 8 })));
+ framework::dataset::make("Batches", { 1 })));
TEST_SUITE_END()
} // namespace test
diff --git a/tests/datasets/DepthwiseConvolutionDataset.h b/tests/datasets/DepthwiseConvolutionDataset.h
index 93da37532f..bdc949501e 100644
--- a/tests/datasets/DepthwiseConvolutionDataset.h
+++ b/tests/datasets/DepthwiseConvolutionDataset.h
@@ -113,6 +113,34 @@ private:
std::vector<TensorShape> _dst_shapes{};
std::vector<PadStrideInfo> _infos{};
};
+class SmallDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset
+{
+public:
+ SmallDepthwiseConvolutionDataset()
+ {
+ add_config(TensorShape(7U, 7U, 3U), TensorShape(3U, 3U, 3U), TensorShape(5U, 5U, 3U), PadStrideInfo(1, 1, 0, 0));
+ add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 5U, 5U), TensorShape(11U, 23U, 5U), PadStrideInfo(2, 1, 0, 0));
+ add_config(TensorShape(33U, 27U, 7U), TensorShape(7U, 3U, 7U), TensorShape(10U, 13U, 7U), PadStrideInfo(3, 2, 1, 0));
+ add_config(TensorShape(17U, 31U, 2U), TensorShape(5U, 9U, 2U), TensorShape(15U, 13U, 2U), PadStrideInfo(1, 2, 1, 1));
+ add_config(TensorShape(23U, 27U, 5U), TensorShape(11U, 3U, 5U), TensorShape(13U, 13U, 5U), PadStrideInfo(1, 2, 0, 0));
+ add_config(TensorShape(17U, 31U, 2U, 3U), TensorShape(5U, 9U, 2U), TensorShape(15U, 13U, 2U, 3U), PadStrideInfo(1, 2, 1, 1));
+ }
+};
+
+class LargeDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset
+{
+public:
+ LargeDepthwiseConvolutionDataset()
+ {
+ add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(116U, 275U, 55U), PadStrideInfo(2, 1, 0, 0));
+ add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(111U, 138U, 77U), PadStrideInfo(3, 2, 1, 0));
+ add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(177U, 156U, 22U), PadStrideInfo(1, 2, 1, 1));
+ add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(231U, 138U, 55U), PadStrideInfo(1, 2, 0, 0));
+ add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(166U, 93U, 77U), PadStrideInfo(2, 3, 0, 1));
+ add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(89U, 311U, 22U), PadStrideInfo(2, 1, 1, 1));
+ }
+};
+
} // namespace datasets
} // namespace test
} // namespace arm_compute
diff --git a/tests/datasets/LargeDepthwiseConvolutionDataset.h b/tests/datasets/LargeDepthwiseConvolutionDataset.h
deleted file mode 100644
index 22b1516d20..0000000000
--- a/tests/datasets/LargeDepthwiseConvolutionDataset.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2017 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_TEST_LARGE_DEPTHWISE_CONVOLUTION_DATASET
-#define ARM_COMPUTE_TEST_LARGE_DEPTHWISE_CONVOLUTION_DATASET
-
-#include "tests/datasets/DepthwiseConvolutionDataset.h"
-
-#include "tests/TypePrinter.h"
-
-#include "arm_compute/core/TensorShape.h"
-#include "arm_compute/core/Types.h"
-
-namespace arm_compute
-{
-namespace test
-{
-namespace datasets
-{
-class LargeDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset
-{
-public:
- LargeDepthwiseConvolutionDataset()
- {
- add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(116U, 275U, 55U), PadStrideInfo(2, 1, 0, 0));
- add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(111U, 138U, 77U), PadStrideInfo(3, 2, 1, 0));
- add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(177U, 156U, 22U), PadStrideInfo(1, 2, 1, 1));
- add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(231U, 138U, 55U), PadStrideInfo(1, 2, 0, 0));
- add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(166U, 93U, 77U), PadStrideInfo(2, 3, 0, 1));
- add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(89U, 311U, 22U), PadStrideInfo(2, 1, 1, 1));
- }
-};
-} // namespace datasets
-} // namespace test
-} // namespace arm_compute
-#endif /* ARM_COMPUTE_TEST_LARGE_DEPTHWISE_CONVOLUTION_DATASET */
diff --git a/tests/datasets/SmallDepthwiseConvolutionDataset.h b/tests/datasets/SmallDepthwiseConvolutionDataset.h
deleted file mode 100644
index 17d01fb5d6..0000000000
--- a/tests/datasets/SmallDepthwiseConvolutionDataset.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2017 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_TEST_SMALL_DEPTHWISE_CONVOLUTION_DATASET
-#define ARM_COMPUTE_TEST_SMALL_DEPTHWISE_CONVOLUTION_DATASET
-
-#include "tests/datasets/DepthwiseConvolutionDataset.h"
-
-#include "tests/TypePrinter.h"
-
-#include "arm_compute/core/TensorShape.h"
-#include "arm_compute/core/Types.h"
-
-namespace arm_compute
-{
-namespace test
-{
-namespace datasets
-{
-class SmallDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset
-{
-public:
- SmallDepthwiseConvolutionDataset()
- {
- add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U), TensorShape(11U, 25U, 5U), PadStrideInfo(2, 1, 0, 0));
- add_config(TensorShape(33U, 27U, 7U), TensorShape(3U, 3U, 7U), TensorShape(11U, 13U, 7U), PadStrideInfo(3, 2, 1, 0));
- add_config(TensorShape(17U, 31U, 2U), TensorShape(3U, 3U, 2U), TensorShape(17U, 16U, 2U), PadStrideInfo(1, 2, 1, 1));
- add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U), TensorShape(21U, 13U, 5U), PadStrideInfo(1, 2, 0, 0));
- add_config(TensorShape(33U, 27U, 7U), TensorShape(3U, 3U, 7U), TensorShape(16U, 9U, 7U), PadStrideInfo(2, 3, 0, 1));
- add_config(TensorShape(17U, 31U, 2U), TensorShape(3U, 3U, 2U), TensorShape(9U, 31U, 2U), PadStrideInfo(2, 1, 1, 1));
- }
-};
-} // namespace datasets
-} // namespace test
-} // namespace arm_compute
-#endif /* ARM_COMPUTE_TEST_SMALL_DEPTHWISE_CONVOLUTION_DATASET */
diff --git a/tests/validation/CL/DepthwiseConvolution.cpp b/tests/validation/CL/DepthwiseConvolution.cpp
index d689f95422..1646ab6157 100644
--- a/tests/validation/CL/DepthwiseConvolution.cpp
+++ b/tests/validation/CL/DepthwiseConvolution.cpp
@@ -27,8 +27,7 @@
#include "arm_compute/runtime/CL/functions/CLDepthwiseConvolution.h"
#include "tests/CL/CLAccessor.h"
#include "tests/PaddingCalculator.h"
-#include "tests/datasets/LargeDepthwiseConvolutionDataset.h"
-#include "tests/datasets/SmallDepthwiseConvolutionDataset.h"
+#include "tests/datasets/DepthwiseConvolutionDataset.h"
#include "tests/framework/Asserts.h"
#include "tests/framework/Macros.h"
#include "tests/framework/datasets/Datasets.h"
@@ -47,18 +46,18 @@ constexpr RelativeTolerance<float> tolerance_f32(0.01f); /**< Tolerance value fo
} // namespace
TEST_SUITE(CL)
-TEST_SUITE(DepthwiseConvolution)
+TEST_SUITE(DepthwiseConvolutionLayer)
template <typename T>
using CLDepthwiseConvolutionFixture = DepthwiseConvolutionValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolution, T>;
// FIXME: COMPMID-523 fix the bug in depthwise convolution
-DISABLED_FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionFixture<float>, framework::DatasetMode::PRECOMMIT, datasets::SmallDepthwiseConvolutionDataset())
+FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionFixture<float>, framework::DatasetMode::PRECOMMIT, datasets::SmallDepthwiseConvolutionDataset())
{
validate(CLAccessor(_target), _reference, tolerance_f32);
}
-DISABLED_FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionFixture<float>, framework::DatasetMode::NIGHTLY, datasets::LargeDepthwiseConvolutionDataset())
+FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionFixture<float>, framework::DatasetMode::NIGHTLY, datasets::LargeDepthwiseConvolutionDataset())
{
validate(CLAccessor(_target), _reference, tolerance_f32);
}
diff --git a/tests/validation/CPP/DepthwiseConvolution.cpp b/tests/validation/CPP/DepthwiseConvolution.cpp
index ce30bed640..ae54494c03 100644
--- a/tests/validation/CPP/DepthwiseConvolution.cpp
+++ b/tests/validation/CPP/DepthwiseConvolution.cpp
@@ -57,37 +57,42 @@ SimpleTensor<T> depthwise_convolution(const SimpleTensor<T> &src, const SimpleTe
const size_t input_width = src.shape().x();
const size_t input_height = src.shape().y();
const size_t input_depth = src.shape().z();
+ const int num_batches = src.shape().total_size() / (input_width * input_height * input_depth);
- const size_t filter_half_size = filter_width / 2;
- const size_t pad_x = std::min(filter_half_size, static_cast<size_t>(conv_info.pad().first));
- const size_t pad_y = std::min(filter_half_size, static_cast<size_t>(conv_info.pad().second));
- const size_t minimum_x = -pad_x + filter_half_size;
- const size_t minimum_y = -pad_y + filter_half_size;
+ const size_t filter_half_width = filter_width / 2;
+ const size_t filter_half_height = filter_height / 2;
+ const size_t pad_x = std::min(filter_half_width, static_cast<size_t>(conv_info.pad().first));
+ const size_t pad_y = std::min(filter_half_height, static_cast<size_t>(conv_info.pad().second));
+ const size_t minimum_x = -pad_x + filter_half_width;
+ const size_t minimum_y = -pad_y + filter_half_height;
int out_pos = 0;
- for(size_t z = 0; z < input_depth; ++z)
+ for(int r = 0; r < num_batches; ++r)
{
- for(size_t y = minimum_y; y < input_height + pad_y - filter_half_size; y += conv_info.stride().second)
+ for(size_t z = 0; z < input_depth; ++z)
{
- for(size_t x = minimum_x; x < input_width + pad_x - filter_half_size; x += conv_info.stride().first)
+ for(size_t y = minimum_y; y < input_height - minimum_y; y += conv_info.stride().second)
{
- Coordinates coords(static_cast<int>(x), static_cast<int>(y), static_cast<int>(z));
- size_t filter_offset = filter_plane * z;
-
- T val = 0;
- for(int j = y - filter_half_size; j <= static_cast<int>(y + filter_half_size); ++j)
+ for(size_t x = minimum_x; x < input_width - minimum_x; x += conv_info.stride().first)
{
- for(int i = x - filter_half_size; i <= static_cast<int>(x + filter_half_size); ++i)
+ Coordinates coords(static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), static_cast<int>(r));
+ size_t filter_offset = filter_plane * z;
+
+ T val = 0;
+ for(int j = y - filter_half_height; j <= static_cast<int>(y + filter_half_height); ++j)
{
- coords.set(0, i);
- coords.set(1, j);
- val += *(weights.data() + filter_offset) * tensor_elem_at(src, coords, BorderMode::CONSTANT, 0.f);
- ++filter_offset;
+ for(int i = x - filter_half_width; i <= static_cast<int>(x + filter_half_width); ++i)
+ {
+ coords.set(0, i);
+ coords.set(1, j);
+ val += *(weights.data() + filter_offset) * tensor_elem_at(src, coords, BorderMode::CONSTANT, 0.f);
+ ++filter_offset;
+ }
}
+ coords.set(0, x);
+ coords.set(1, y);
+ dst[out_pos++] = saturate_cast<T>(val);
}
- coords.set(0, x);
- coords.set(1, y);
- dst[out_pos++] = saturate_cast<T>(val);
}
}
}