ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

Output mismatch in CLEqualizeHistogram kernel

Open manjunathahg opened this issue 8 years ago • 4 comments

**Output of 'strings libarm_compute.so | grep arm_compute_version':**arm_compute_version.embed

**Platform:**ACL GPU

**Operating System:**Linux 64 bit

**Problem description:**Hi sir We are executing CLEqualizeHistogram kernel in compute library 18.05 on ACL GPU. We have a openvx reference implementation of the Equalize Histogram and we are observing mismatch in output. ACL NEON and GPU outputs are matching. This problem is seen after updating the compute library from 17.10 to 18.05. Is there a difference in implementation of CLEqualizeHistogram in 18.05 version of the libray? Please help us in resolving this issue. Stand alone work space and logs are attached for your reference. Thanks in advance stand_alone_out.txt cl_histEq_test.txt c_model_out.txt

input.rgb.zip

manjunathahg avatar Sep 05 '18 12:09 manjunathahg

Hi @manjunathahg

May I ask you what height and width you pass to your example?

mdigiorgio avatar Sep 05 '18 14:09 mdigiorgio

HI @mdigiorgio width = 640 height = 480

manjunathahg avatar Sep 05 '18 14:09 manjunathahg

Hi @manjunathahg

In fact there was a change between the two versions and it's a bug. Thanks for reporting it, the fix will be part of next release. Meanwhile, you can use the following patch to fix it:

diff --git a/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp b/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp
index d2eac2c25..31b688c51 100644
--- a/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp
+++ b/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp
@@ -102,7 +102,7 @@ void NECumulativeDistributionKernel::run(const Window &window, const ThreadInfo
     }
     else
     {
-        const float diff = image_size - 1;
+        const float diff = image_size - cd_min;
 
         for(unsigned int x = 0; x < _histogram_size; ++x)
         {
diff --git a/src/runtime/CL/functions/CLEqualizeHistogram.cpp b/src/runtime/CL/functions/CLEqualizeHistogram.cpp
index 45f70d2fa..a0663b754 100644
--- a/src/runtime/CL/functions/CLEqualizeHistogram.cpp
+++ b/src/runtime/CL/functions/CLEqualizeHistogram.cpp
@@ -68,7 +68,7 @@ void calculate_cum_dist_and_lut(CLDistribution1D &dist, CLDistribution1D &cum_di
     }
     else
     {
-        const float diff = image_size - 1;
+        const float diff = image_size - num_lowest_pixels;
 
         for(size_t i = 0; i < 256; ++i)
         {
diff --git a/tests/validation/reference/EqualizeHistogram.cpp b/tests/validation/reference/EqualizeHistogram.cpp
index 0e966cd0b..1a10c2c30 100644
--- a/tests/validation/reference/EqualizeHistogram.cpp
+++ b/tests/validation/reference/EqualizeHistogram.cpp
@@ -66,7 +66,7 @@ SimpleTensor<T> equalize_histogram(const SimpleTensor<T> &src)
     }
     else
     {
-        const float diff = total_num_pixels - 1;
+        const float diff = total_num_pixels - cd_min;
 
         for(size_t i = 0; i < num_bins; ++i)
         {

Best regards, Michele

mdigiorgio avatar Sep 05 '18 15:09 mdigiorgio

Hi @mdigiorgio, thank you very much for the quick help. The example is working fine after applying the patch.

manjunathahg avatar Sep 06 '18 12:09 manjunathahg