[arrayfire] 04/34: BUGFIX convolve frequency condition is now based on kernel size

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun Sep 27 14:46:01 UTC 2015


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

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

commit 1311e81f9700fd6561f1fa02d6473125e73e388e
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Mon Sep 14 14:03:10 2015 -0400

    BUGFIX convolve frequency condition is now based on kernel size
    
    * Code cleanup - Put code in try catch blocks
---
 src/api/c/convolve.cpp | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/src/api/c/convolve.cpp b/src/api/c/convolve.cpp
index 694c2cc..912d8fd 100644
--- a/src/api/c/convolve.cpp
+++ b/src/api/c/convolve.cpp
@@ -146,12 +146,12 @@ bool isFreqDomain(const af_array &signal, const af_array filter, af_conv_domain
 
     if (identifyBatchKind<baseDim>(sdims, fdims) == CONVOLVE_BATCH_DIFF) return true;
 
-    int batch = 1;
+    int kbatch = 1;
     for(int i = 3; i >= baseDim; i--) {
-        batch *= std::max(fdims[i], sdims[i]);
+        kbatch *= fdims[i];
     }
 
-    if (batch >= 10) return true;
+    if (kbatch >= 10) return true;
 
     if (baseDim == 1) {
         if (fdims[0] > 128) return true;
@@ -177,12 +177,12 @@ af_err af_convolve1(af_array *out, const af_array signal, const af_array filter,
     try {
         if (isFreqDomain<1>(signal, filter, domain))
             return af_fft_convolve1(out, signal, filter, mode);
-    } CATCHALL;
 
-    if (mode == AF_CONV_EXPAND)
+        if (mode == AF_CONV_EXPAND)
             return convolve<1, true >(out, signal, filter);
-    else
-        return convolve<1, false>(out, signal, filter);
+        else
+            return convolve<1, false>(out, signal, filter);
+    } CATCHALL;
 }
 
 af_err af_convolve2(af_array *out, const af_array signal, const af_array filter, const af_conv_mode mode, af_conv_domain domain)
@@ -190,12 +190,12 @@ af_err af_convolve2(af_array *out, const af_array signal, const af_array filter,
     try {
         if (isFreqDomain<2>(signal, filter, domain))
             return af_fft_convolve2(out, signal, filter, mode);
-    } CATCHALL;
 
-    if (mode == AF_CONV_EXPAND)
-        return convolve<2, true >(out, signal, filter);
-    else
-        return convolve<2, false>(out, signal, filter);
+        if (mode == AF_CONV_EXPAND)
+            return convolve<2, true >(out, signal, filter);
+        else
+            return convolve<2, false>(out, signal, filter);
+    } CATCHALL;
 }
 
 af_err af_convolve3(af_array *out, const af_array signal, const af_array filter, const af_conv_mode mode, af_conv_domain domain)
@@ -203,18 +203,20 @@ af_err af_convolve3(af_array *out, const af_array signal, const af_array filter,
     try {
         if (isFreqDomain<3>(signal, filter, domain))
             return af_fft_convolve3(out, signal, filter, mode);
-    } CATCHALL;
 
-    if (mode == AF_CONV_EXPAND)
-        return convolve<3, true >(out, signal, filter);
-    else
-        return convolve<3, false>(out, signal, filter);
+        if (mode == AF_CONV_EXPAND)
+            return convolve<3, true >(out, signal, filter);
+        else
+            return convolve<3, false>(out, signal, filter);
+    } CATCHALL;
 }
 
 af_err af_convolve2_sep(af_array *out, const af_array signal, const af_array col_filter, const af_array row_filter, const af_conv_mode mode)
 {
-    if (mode == AF_CONV_EXPAND)
-        return convolve2_sep<true >(out, signal, col_filter, row_filter);
-    else
-        return convolve2_sep<false>(out, signal, col_filter, row_filter);
+    try {
+        if (mode == AF_CONV_EXPAND)
+            return convolve2_sep<true >(out, signal, col_filter, row_filter);
+        else
+            return convolve2_sep<false>(out, signal, col_filter, row_filter);
+    } CATCHALL;
 }

-- 
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