aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/CPP
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2017-11-29 10:17:56 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:41:36 +0000
commitb6f182d3e5b69cc193d7e5ec397c4d61083572d5 (patch)
treebb55a14c3783d3024b77d7a2bc0e1a001d956d94 /tests/validation/CPP
parent2fdc40956a4d521ec811bf33aafd0b1e756d6d54 (diff)
downloadComputeLibrary-b6f182d3e5b69cc193d7e5ec397c4d61083572d5.tar.gz
COMPMID-556: Fix CLDepthwiseConvolution3x3 Kernel.
Kernel was not sliding the input window. Change-Id: Ia5903ceaed1243e86bee773a84102d8a1132dfa5 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/111055 Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com <bsgcomp@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests/validation/CPP')
-rw-r--r--tests/validation/CPP/DepthwiseConvolution.cpp52
1 files changed, 28 insertions, 24 deletions
diff --git a/tests/validation/CPP/DepthwiseConvolution.cpp b/tests/validation/CPP/DepthwiseConvolution.cpp
index ad0653846b..229e044783 100644
--- a/tests/validation/CPP/DepthwiseConvolution.cpp
+++ b/tests/validation/CPP/DepthwiseConvolution.cpp
@@ -137,6 +137,7 @@ SimpleTensor<uint8_t> depthwise_convolution(const SimpleTensor<uint8_t> &src, co
const int input_width = src.shape().x();
const int input_height = src.shape().y();
const int input_depth = src.shape().z();
+ const int num_batches = src.shape().total_size() / (input_width * input_height * input_depth);
const int filter_half_size = filter_width / 2;
const int pad_x = std::min(filter_half_size, static_cast<int>(conv_info.pad().first));
@@ -145,37 +146,40 @@ SimpleTensor<uint8_t> depthwise_convolution(const SimpleTensor<uint8_t> &src, co
const int minimum_y = -pad_y + filter_half_size;
int out_pos = 0;
- for(int z = 0; z < input_depth; ++z)
+ for(int r = 0; r < num_batches; ++r)
{
- int32_t bias_val = *static_cast<const int32_t *>(biases(Coordinates(z)));
- for(int y = minimum_y; y < input_height + pad_y - filter_half_size; y += conv_info.stride().second)
+ for(int z = 0; z < input_depth; ++z)
{
- for(int x = minimum_x; x < input_width + pad_x - filter_half_size; x += conv_info.stride().first)
+ int32_t bias_val = *static_cast<const int32_t *>(biases(Coordinates(z)));
+ for(int y = minimum_y; y < input_height + pad_y - filter_half_size; y += conv_info.stride().second)
{
- Coordinates coords(x, y, z);
- int filter_offset = filter_plane * z;
-
- uint32_t val = 0;
- for(int j = y - filter_half_size; j <= (y + filter_half_size); ++j)
+ for(int x = minimum_x; x < input_width + pad_x - filter_half_size; x += conv_info.stride().first)
{
- for(int i = x - filter_half_size; i <= (x + filter_half_size); ++i)
+ Coordinates coords(x, y, z);
+ int filter_offset = filter_plane * z;
+
+ uint32_t val = 0;
+ for(int j = y - filter_half_size; j <= (y + filter_half_size); ++j)
{
- coords.set(0, i);
- coords.set(1, j);
- auto in_val = tensor_elem_at<uint8_t>(src, coords, BorderMode::CONSTANT, 0);
- uint8_t w_val = *(weights.data() + filter_offset);
- val += (in_val + input_offset) * (w_val + weights_offset);
- ++filter_offset;
+ for(int i = x - filter_half_size; i <= (x + filter_half_size); ++i)
+ {
+ coords.set(0, i);
+ coords.set(1, j);
+ auto in_val = tensor_elem_at<uint8_t>(src, coords, BorderMode::CONSTANT, 0);
+ uint8_t w_val = *(weights.data() + filter_offset);
+ val += (in_val + input_offset) * (w_val + weights_offset);
+ ++filter_offset;
+ }
}
+ val += bias_val;
+ val = asymm_rounding_divide_by_pow2(asymm_int_mult(val, output_multiplier), output_shift);
+ val += output_offset;
+ val = std::max<int32_t>(val, 0);
+ val = std::min<int32_t>(val, 255);
+
+ // Store the result
+ dst[out_pos++] = val;
}
- val += bias_val;
- val = asymm_rounding_divide_by_pow2(asymm_int_mult(val, output_multiplier), output_shift);
- val += output_offset;
- val = std::max<int32_t>(val, 0);
- val = std::min<int32_t>(val, 255);
-
- // Store the result
- dst[out_pos++] = val;
}
}
}