[python-arrayfire] 62/250: Avoid promoting arrays to 64-bit
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:31 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/master
in repository python-arrayfire.
commit 66695c7ff3a79a0d23b157ce5484475eef5c49f7
Author: Filipe Maia <filipe.c.maia at gmail.com>
Date: Thu Aug 27 23:29:11 2015 +0200
Avoid promoting arrays to 64-bit
---
arrayfire/arith.py | 4 ++--
arrayfire/array.py | 4 ++--
arrayfire/util.py | 8 ++++++++
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/arrayfire/arith.py b/arrayfire/arith.py
index ffc8c5b..c06c4ef 100644
--- a/arrayfire/arith.py
+++ b/arrayfire/arith.py
@@ -25,14 +25,14 @@ def arith_binary_func(lhs, rhs, c_func):
elif (is_number(rhs)):
ldims = dim4_tuple(lhs.dims())
- rty = number_dtype(rhs)
+ rty = implicit_dtype(rhs, lhs.type())
other = array()
other.arr = constant_array(rhs, ldims[0], ldims[1], ldims[2], ldims[3], rty)
safe_call(c_func(ct.pointer(out.arr), lhs.arr, other.arr, bcast.get()))
else:
rdims = dim4_tuple(rhs.dims())
- lty = number_dtype(lhs)
+ lty = implicit_dtype(lhs, rhs.type())
other = array()
other.arr = constant_array(lhs, rdims[0], rdims[1], rdims[2], rdims[3], lty)
safe_call(c_func(ct.pointer(out.arr), other.arr, rhs.arr, bcast.get()))
diff --git a/arrayfire/array.py b/arrayfire/array.py
index 39addab..99ff365 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -60,7 +60,7 @@ def binary_func(lhs, rhs, c_func):
if (is_number(rhs)):
ldims = dim4_tuple(lhs.dims())
- rty = number_dtype(rhs)
+ rty = implicit_dtype(rhs, lhs.type())
other = array()
other.arr = constant_array(rhs, ldims[0], ldims[1], ldims[2], ldims[3], rty)
elif not isinstance(rhs, array):
@@ -76,7 +76,7 @@ def binary_funcr(lhs, rhs, c_func):
if (is_number(lhs)):
rdims = dim4_tuple(rhs.dims())
- lty = number_dtype(lhs)
+ lty = implicit_dtype(lhs, rhs.type())
other = array()
other.arr = constant_array(lhs, rdims[0], rdims[1], rdims[2], rdims[3], lty)
elif not isinstance(lhs, array):
diff --git a/arrayfire/util.py b/arrayfire/util.py
index 849cc97..afd0943 100644
--- a/arrayfire/util.py
+++ b/arrayfire/util.py
@@ -34,6 +34,14 @@ def number_dtype(a):
else:
return to_dtype[a.dtype.char]
+def implicit_dtype(number, a_dtype):
+ n_dtype = number_dtype(number)
+ if n_dtype == f64 and (a_dtype == f32 or a_dtype == c32):
+ return f32
+ if n_dtype == c64 and (a_dtype == f32 or a_dtype == c32):
+ return c32
+ return n_dtype
+
def dim4_tuple(dims, default=1):
assert(isinstance(dims, tuple))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-arrayfire.git
More information about the debian-science-commits
mailing list