[arrayfire] 33/79: BUGFIX/TEST: fftConvolve now does multi dimensional batching properly

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Jun 15 13:38:05 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository arrayfire.

commit 55bf05735bed03b9aa720be765156cdf381ae401
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Mon Jun 8 18:28:45 2015 -0400

    BUGFIX/TEST: fftConvolve now does multi dimensional batching properly
    
    - Added another fftConvolve test
---
 src/backend/cuda/fftconvolve.cu | 29 ++++++++++-------------------
 test/convolve.cpp               |  2 +-
 test/fftconvolve.cpp            | 13 ++++++++++++-
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/src/backend/cuda/fftconvolve.cu b/src/backend/cuda/fftconvolve.cu
index 37f8c7c..f95917b 100644
--- a/src/backend/cuda/fftconvolve.cu
+++ b/src/backend/cuda/fftconvolve.cu
@@ -30,29 +30,20 @@ static const dim4 calcPackedSize(Array<T> const& i1,
     const dim4 i1d = i1.dims();
     const dim4 i2d = i2.dims();
 
-    dim_t pd[4];
-
-    // Pack both signal and filter on same memory array, this will ensure
-    // better use of batched cuFFT capabilities
-    for (dim_t k = 0; k < 4; k++) {
-        if (k == 0)
-            pd[k] = nextpow2((unsigned)(i1d[k] + i2d[k] - 1)) / 2;
-        else if (k < baseDim)
-            pd[k] = nextpow2((unsigned)(i1d[k] + i2d[k] - 1));
-        else if (k == baseDim)
-            pd[k] = i1d[k];
-        else
-            pd[k] = 1;
-    }
+    dim_t pd[4] = {1, 1, 1, 1};
+
 
     dim_t max_d0 = (i1d[0] > i2d[0]) ? i1d[0] : i2d[0];
     dim_t min_d0 = (i1d[0] < i2d[0]) ? i1d[0] : i2d[0];
-    unsigned df0  = nextpow2((unsigned)((int)ceil(max_d0 / 2.f) + min_d0 - 1));
+    pd[0]  = nextpow2((unsigned)((int)ceil(max_d0 / 2.f) + min_d0 - 1));
 
-    // Adjust dimension 0 size if ceil(signal/2.f)+filter-1 won't fit in
-    // packed_dims[0]
-    if (df0 == (pd[0]*2))
-        pd[0] *= 2;
+    for (dim_t k = 1; k < 4; k++) {
+        if (k < baseDim) {
+            pd[k] = nextpow2((unsigned)(i1d[k] + i2d[k] - 1));
+        } else {
+            pd[k] = i1d[k];
+        }
+    }
 
     return dim4(pd[0], pd[1], pd[2], pd[3]);
 }
diff --git a/test/convolve.cpp b/test/convolve.cpp
index 200c66b..185eba9 100644
--- a/test/convolve.cpp
+++ b/test/convolve.cpp
@@ -634,7 +634,7 @@ TEST(GFOR, convolve2_MO)
     }
 }
 
-TEST(GFOR, convolve2_1M)
+TEST(GFOR, convolve2_OM)
 {
     array A = randu(5, 5);
     array B = randu(5, 5, 3);
diff --git a/test/fftconvolve.cpp b/test/fftconvolve.cpp
index b8782af..8117ec0 100644
--- a/test/fftconvolve.cpp
+++ b/test/fftconvolve.cpp
@@ -607,7 +607,7 @@ TEST(GFOR, fftConvolve2_MO)
     }
 }
 
-TEST(GFOR, fftConvolve2_1M)
+TEST(GFOR, fftConvolve2_OM)
 {
     array A = randu(5, 5);
     array B = randu(5, 5, 3);
@@ -640,3 +640,14 @@ TEST(GFOR, fftConvolve2_MM)
         ASSERT_EQ(max<double>(abs(c_ii - b_ii)) < 1E-5, true);
     }
 }
+
+TEST(Padding, fftConvolve2)
+{
+    for (int n = 5; n < 32; n++) {
+        array a = randu(n, n);
+        array b = randu(5, 5);
+        array c = fftConvolve2(a, b);
+        array d = convolve2(a, b, AF_CONV_DEFAULT, AF_CONV_SPATIAL);
+        ASSERT_EQ(max<double>(abs(c - d)) < 1E-5, true);
+    }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list