[arrayfire] 168/408: Corrected memory allocation bug in cpu backend for orb, where

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:48 UTC 2015


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

ghisvail-guest pushed a commit to branch debian/sid
in repository arrayfire.

commit 307040ba29f4417d6a1f3d3f3a8ad2c5b9b2eaf5
Author: pradeep <pradeep at arrayfire.com>
Date:   Fri Jul 24 16:08:54 2015 -0400

    Corrected memory allocation bug in cpu backend for orb, where
---
 src/backend/cpu/orb.cpp   | 9 ++-------
 src/backend/cpu/where.cpp | 3 +--
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/backend/cpu/orb.cpp b/src/backend/cpu/orb.cpp
index 342487f..d279ba5 100644
--- a/src/backend/cpu/orb.cpp
+++ b/src/backend/cpu/orb.cpp
@@ -659,14 +659,12 @@ unsigned orb(Array<float> &x, Array<float> &y,
 
         // Sort features according to Harris responses
         af::dim4 usable_feat_dims(usable_feat);
-        Array<float> score_harris = createHostDataArray(usable_feat_dims, h_score_harris);
+        Array<float> score_harris = createDeviceDataArray<float>(usable_feat_dims, h_score_harris);
         Array<float> harris_sorted = createEmptyArray<float>(af::dim4());
         Array<unsigned> harris_idx = createEmptyArray<unsigned>(af::dim4());
 
         sort_index<float, false>(harris_sorted, harris_idx, score_harris, 0);
 
-        memFree(h_score_harris);
-
         usable_feat = std::min(usable_feat, lvl_best[i]);
 
         if (usable_feat == 0) {
@@ -702,7 +700,7 @@ unsigned orb(Array<float> &x, Array<float> &y,
             if (!h_gauss) {
                 h_gauss = memAlloc<T>(gauss_dims[0]);
                 gaussian1D(h_gauss, gauss_dims[0], 2.f);
-                gauss_filter = createHostDataArray(gauss_dims, h_gauss);
+                gauss_filter = createDeviceDataArray<T>(gauss_dims, h_gauss);
             }
 
             // Filter level image with Gaussian kernel to reduce noise sensitivity
@@ -733,9 +731,6 @@ unsigned orb(Array<float> &x, Array<float> &y,
 
     }
 
-    if (h_gauss != nullptr)
-        memFree(h_gauss);
-
     if (total_feat > 0 ) {
 
         // Allocate feature Arrays
diff --git a/src/backend/cpu/where.cpp b/src/backend/cpu/where.cpp
index da2987e..c1ffd0f 100644
--- a/src/backend/cpu/where.cpp
+++ b/src/backend/cpu/where.cpp
@@ -55,8 +55,7 @@ namespace cpu
             }
         }
 
-        Array<uint> out = createHostDataArray(dim4(count), out_vec);
-        memFree<uint>(out_vec);
+        Array<uint> out = createDeviceDataArray<uint>(dim4(count), out_vec);
         return out;
     }
 

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