diff options
author | Giorgio Arena <giorgio.arena@arm.com> | 2017-08-23 16:36:24 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 9fe414430c3c989b1cdc79d41e031495aed2cb7c (patch) | |
tree | 5f893eeb81fe75824918273f49171c85f108fe4e /tests/validation | |
parent | 580f4c7f6c2cbe320c606eb6ba73b3f4a20791ef (diff) | |
download | ComputeLibrary-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/validation')
-rw-r--r-- | tests/validation/CL/DepthwiseConvolution.cpp | 9 | ||||
-rw-r--r-- | tests/validation/CPP/DepthwiseConvolution.cpp | 47 |
2 files changed, 30 insertions, 26 deletions
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); } } } |