[arrayfire] 44/408: FEAT: intl/uintl for random

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:13 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 470cf9922c7749ca64a6e6fbee7455169fe04362
Author: Umar Arshad <umar at arrayfire.com>
Date:   Thu Jun 25 20:18:58 2015 -0400

    FEAT: intl/uintl for random
---
 src/api/c/data.cpp            |  2 ++
 src/backend/cpu/random.cpp    |  2 ++
 src/backend/cuda/random.cu    |  2 ++
 src/backend/opencl/random.cpp |  2 ++
 test/random.cpp               | 65 ++++++++-----------------------------------
 5 files changed, 20 insertions(+), 53 deletions(-)

diff --git a/src/api/c/data.cpp b/src/api/c/data.cpp
index 32d4583..08267be 100644
--- a/src/api/c/data.cpp
+++ b/src/api/c/data.cpp
@@ -280,6 +280,8 @@ af_err af_randu(af_array *out, const unsigned ndims, const dim_t * const dims, c
         case c64:   result = randu_<cdouble>(d);    break;
         case s32:   result = randu_<int    >(d);    break;
         case u32:   result = randu_<uint   >(d);    break;
+        case s64:   result = randu_<intl   >(d);    break;
+        case u64:   result = randu_<uintl  >(d);    break;
         case u8:    result = randu_<uchar  >(d);    break;
         case b8:    result = randu_<char  >(d);    break;
         default:    TYPE_ERROR(3, type);
diff --git a/src/backend/cpu/random.cpp b/src/backend/cpu/random.cpp
index a806d79..03fabb3 100644
--- a/src/backend/cpu/random.cpp
+++ b/src/backend/cpu/random.cpp
@@ -126,6 +126,8 @@ INSTANTIATE_UNIFORM(cfloat)
 INSTANTIATE_UNIFORM(cdouble)
 INSTANTIATE_UNIFORM(int)
 INSTANTIATE_UNIFORM(uint)
+INSTANTIATE_UNIFORM(intl)
+INSTANTIATE_UNIFORM(uintl)
 INSTANTIATE_UNIFORM(uchar)
 
 #define INSTANTIATE_NORMAL(T)                              \
diff --git a/src/backend/cuda/random.cu b/src/backend/cuda/random.cu
index 737c6c1..c9e6197 100644
--- a/src/backend/cuda/random.cu
+++ b/src/backend/cuda/random.cu
@@ -40,6 +40,8 @@ namespace cuda
     template Array<cdouble> randu<cdouble> (const af::dim4 &dims);
     template Array<int>     randu<int>     (const af::dim4 &dims);
     template Array<uint>    randu<uint>    (const af::dim4 &dims);
+    template Array<intl>    randu<intl>    (const af::dim4 &dims);
+    template Array<uintl>   randu<uintl>   (const af::dim4 &dims);
     template Array<char>    randu<char>    (const af::dim4 &dims);
     template Array<uchar>   randu<uchar>   (const af::dim4 &dims);
 
diff --git a/src/backend/opencl/random.cpp b/src/backend/opencl/random.cpp
index d67f323..a6f2b67 100644
--- a/src/backend/opencl/random.cpp
+++ b/src/backend/opencl/random.cpp
@@ -39,6 +39,8 @@ namespace opencl
     template Array<double> randu<double>  (const af::dim4 &dims);
     template Array<int>    randu<int>     (const af::dim4 &dims);
     template Array<uint>   randu<uint>    (const af::dim4 &dims);
+    template Array<intl>   randu<intl>    (const af::dim4 &dims);
+    template Array<uintl>  randu<uintl>   (const af::dim4 &dims);
     template Array<char>   randu<char>    (const af::dim4 &dims);
     template Array<uchar>  randu<uchar>   (const af::dim4 &dims);
 
diff --git a/test/random.cpp b/test/random.cpp
index 608a8f0..5d4f46c 100644
--- a/test/random.cpp
+++ b/test/random.cpp
@@ -33,7 +33,7 @@ class Random : public ::testing::Test
 };
 
 // create a list of types to be tested
-typedef ::testing::Types<float, cfloat, double, cdouble, int, unsigned, unsigned char> TestTypes;
+typedef ::testing::Types<float, cfloat, double, cdouble, int, unsigned, intl, uintl, unsigned char> TestTypes;
 
 // register the type list
 TYPED_TEST_CASE(Random, TestTypes);
@@ -72,58 +72,17 @@ void randnTest(af::dim4 &dims)
     if(outArray != 0) af_release_array(outArray);
 }
 
-// INT, UNIT, CHAR, UCHAR Not Supported by RANDN
-template<>
-void randnTest<int>(af::dim4 &dims)
-{
-    if (noDoubleTests<int>()) return;
-
-    af_array outArray = 0;
-    ASSERT_EQ(AF_ERR_TYPE, af_randn(&outArray, dims.ndims(), dims.get(), (af_dtype) af::dtype_traits<int>::af_type));
-    if(outArray != 0) af_release_array(outArray);
-}
-
-template<>
-void randnTest<unsigned>(af::dim4 &dims)
-{
-    if (noDoubleTests<unsigned>()) return;
-
-    af_array outArray = 0;
-    ASSERT_EQ(AF_ERR_TYPE, af_randn(&outArray, dims.ndims(), dims.get(), (af_dtype) af::dtype_traits<unsigned>::af_type));
-    if(outArray != 0) af_release_array(outArray);
-}
-
-template<>
-void randnTest<char>(af::dim4 &dims)
-{
-    if (noDoubleTests<char>()) return;
-
-    af_array outArray = 0;
-    ASSERT_EQ(AF_ERR_TYPE, af_randn(&outArray, dims.ndims(), dims.get(), (af_dtype) af::dtype_traits<char>::af_type));
-    if(outArray != 0) af_release_array(outArray);
-}
-
-template<>
-void randnTest<unsigned char>(af::dim4 &dims)
-{
-    if (noDoubleTests<unsigned char>()) return;
-
-    af_array outArray = 0;
-    ASSERT_EQ(AF_ERR_TYPE, af_randn(&outArray, dims.ndims(), dims.get(), (af_dtype) af::dtype_traits<unsigned char>::af_type));
-    if(outArray != 0) af_release_array(outArray);
-}
-
-#define RAND(d0, d1, d2, d3)                            \
-    TYPED_TEST(Random,randu_##d0##_##d1##_##d2##_##d3)  \
-    {                                                   \
-        af::dim4 dims(d0, d1, d2, d3);                  \
-        randuTest<TypeParam>(dims);                     \
-    }                                                   \
-    TYPED_TEST(Random,randn_##d0##_##d1##_##d2##_##d3)  \
-    {                                                   \
-        af::dim4 dims(d0, d1, d2, d3);                  \
-        randnTest<TypeParam>(dims);                     \
-    }                                                   \
+#define RAND(d0, d1, d2, d3)                                    \
+    TYPED_TEST(Random,randu_##d0##_##d1##_##d2##_##d3)          \
+    {                                                           \
+        af::dim4 dims(d0, d1, d2, d3);                          \
+        randuTest<TypeParam>(dims);                             \
+    }                                                           \
+    TYPED_TEST(Random_norm,randn_##d0##_##d1##_##d2##_##d3)     \
+    {                                                           \
+        af::dim4 dims(d0, d1, d2, d3);                          \
+        randnTest<TypeParam>(dims);                             \
+    }                                                           \
 
 RAND(1024, 1024,    1,    1);
 RAND( 512,  512,    1,    1);

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