aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Lei <frank.lei@arm.com>2018-01-04 13:02:40 +0800
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:42:39 +0000
commit1bfc7849950b67aeee382b08f27fd0b1b5ef0587 (patch)
treeac26809b0691234f2ae6ee4a775027746455decd
parent345ab188c66017bf80512024a42b8e85ee96c872 (diff)
downloadComputeLibrary-1bfc7849950b67aeee382b08f27fd0b1b5ef0587.tar.gz
APPBROWSER-376: Work around for scale validation error.
Use "vec2 scale" instead of scale_x/scale_y to work around this issue. Change-Id: Ieae55327596fdb853d7b625262fec3a3a84f577c Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/115143 Reviewed-by: Joel Liang <joel.liang@arm.com> Reviewed-by: Pablo Tello <pablo.tello@arm.com> Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Frank Lei <frank.lei@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
-rw-r--r--src/core/GLES_COMPUTE/cs_shaders/scale.cs23
-rw-r--r--src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp10
2 files changed, 14 insertions, 19 deletions
diff --git a/src/core/GLES_COMPUTE/cs_shaders/scale.cs b/src/core/GLES_COMPUTE/cs_shaders/scale.cs
index 08233abaa2..b2689a257d 100644
--- a/src/core/GLES_COMPUTE/cs_shaders/scale.cs
+++ b/src/core/GLES_COMPUTE/cs_shaders/scale.cs
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016, 2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -26,6 +26,9 @@ layout(local_size_x = LOCAL_SIZE_X, local_size_y = LOCAL_SIZE_Y, local_size_z =
#include "helpers_cs.h"
+// We DO have to use highp for DATA_TYPE_FP16 float here to calculate the coordinates of source tensor. float is highp by default, but we still write it down here to make it more clearly, and mediump is only used for src/dst tensor in shader body.
+precision highp float;
+
/** Performs an affine transformation on an image interpolating with the NEAREAST NEIGHBOUR method. Input and output are single channel FP16.
*
* @param[in] src_ptr Pointer to the source tensor. Supported data types: FP16.
@@ -34,8 +37,7 @@ layout(local_size_x = LOCAL_SIZE_X, local_size_y = LOCAL_SIZE_Y, local_size_z =
* @param[in] dst_attrs The attributes of the destination tensor
* @param[in] input_width Input image width
* @param[in] input_height Input image height
- * @param[in] scale_x The scale factor along x dimension
- * @param[in] scale_y The scale factor along y dimension
+ * @param[in] scale The scale factor along x/y dimension
*/
SHADER_PARAMS_DECLARATION
{
@@ -43,8 +45,7 @@ SHADER_PARAMS_DECLARATION
ImageAttributes dst_attrs;
float input_width;
float input_height;
- float scale_x;
- float scale_y;
+ vec2 scale;
};
#if defined(DATA_TYPE_FP16)
@@ -77,19 +78,18 @@ void main()
ImageIterator src_iter = CONVERT_TO_IMAGE_ITERATOR_NO_STEP(src_attrs, src_shift);
ImageIterator dst_iter = CONVERT_TO_IMAGE_ITERATOR(dst_attrs, dst_shift);
- vec2 r = vec2(scale_x, scale_y);
- vec4[2] tc = clamp_to_border_with_size(transform_nearest(vec2(gl_GlobalInvocationID.x << uint(2), gl_GlobalInvocationID.y), r), input_width, input_height, float(BORDER_SIZE));
+ vec4[2] tc = clamp_to_border_with_size(transform_nearest(vec2(gl_GlobalInvocationID.x << uint(2), gl_GlobalInvocationID.y), scale), input_width, input_height, float(BORDER_SIZE));
mediump vec2 s = vec2(0.0f);
mediump vec4 d = vec4(0.0f);
for(int i = 0; i < 4; i++)
{
- uint offset = image_offset_in_bytes(src_iter, int(tc[0][i]), int(tc[1][i]));
+ uint offset_in_bytes = image_offset_in_bytes(src_iter, int(tc[0][i]), int(tc[1][i]));
- s = LOAD_UNPACK2_HALF(src_ptr, uint(offset >> src_shift));
+ s = LOAD_UNPACK2_HALF(src_ptr, uint(offset_in_bytes >> src_shift));
- if(offset % uint(4) == uint(0))
+ if(offset_in_bytes % uint(4) == uint(0))
{
d[i] = s.x;
}
@@ -115,8 +115,7 @@ void main()
mediump vec4 s = vec4(0.0f);
mediump vec4[2] d;
- uint offset = image_offset_in_bytes(src_iter, int(tc[0]), int(tc[1]));
- s = LOAD_UNPACK4_HALF(src_ptr, uint(offset >> src_shift));
+ s = LOAD_UNPACK4_HALF(src_ptr, IMAGE_OFFSET(src_iter, int(tc[0]), int(tc[1])));
d[0] = vec4(s.x, s.x, s.y, s.y);
d[1] = vec4(s.z, s.z, s.w, s.w);
diff --git a/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp
index 7461c544da..f307cfb239 100644
--- a/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016, 2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -128,13 +128,9 @@ void GCScaleKernel::configure(const IGCTensor *input, IGCTensor *output, Interpo
IGCKernel::configure(win);
- // Set static kernel arguments
- const float scale_x = static_cast<float>(input->info()->dimension(0)) / output->info()->dimension(0);
- const float scale_y = static_cast<float>(input->info()->dimension(1)) / output->info()->dimension(1);
-
unsigned int idx = 2 * num_arguments_per_2D_tensor(); //Skip the tensor parameters
_kernel.set_argument<float>(idx++, static_cast<float>(input->info()->dimension(0)));
_kernel.set_argument<float>(idx++, static_cast<float>(input->info()->dimension(1)));
- _kernel.set_argument(idx++, scale_x);
- _kernel.set_argument(idx++, scale_y);
+ _kernel.set_argument<float>(idx++, wr);
+ _kernel.set_argument<float>(idx++, hr);
}