[pypy-commit] pypy ufunc-reduce: move temp array creation inside loop.do_accumulate()

rlamy noreply at buildbot.pypy.org
Sun Jul 26 17:53:14 CEST 2015


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: ufunc-reduce
Changeset: r78672:80032f7aad54
Date: 2015-07-26 16:53 +0100
http://bitbucket.org/pypy/pypy/changeset/80032f7aad54/

Log:	move temp array creation inside loop.do_accumulate()

diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -246,9 +246,12 @@
                                   greens=['shapelen', 'func', 'dtype'],
                                   reds='auto')
 
-def do_accumulate(space, shape, func, arr, dtype, axis, out, identity, temp):
+def do_accumulate(space, shape, func, arr, dtype, axis, out, identity):
     out_iter = AxisIter(out.implementation, arr.get_shape(), axis, cumulative=True)
     out_state = out_iter.reset()
+    obj_shape = arr.get_shape()
+    temp_shape = obj_shape[:axis] + obj_shape[axis + 1:]
+    temp = W_NDimArray.from_shape(space, temp_shape, dtype, w_instance=arr)
     temp_iter = AxisIter(temp.implementation, arr.get_shape(), axis, False)
     temp_state = temp_iter.reset()
     arr_iter, arr_state = arr.create_iter()
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -293,13 +293,7 @@
             dtype = self.find_binop_type(space, dtype)
             call__array_wrap__ = True
             if shapelen > 1:
-                temp = None
                 shape = obj_shape[:]
-                temp_shape = obj_shape[:axis] + obj_shape[axis + 1:]
-                if out:
-                    dtype = out.get_dtype()
-                temp = W_NDimArray.from_shape(space, temp_shape, dtype,
-                                            w_instance=obj)
                 if out:
                     # Test for shape agreement
                     # XXX maybe we need to do broadcasting here, although I must
@@ -329,7 +323,7 @@
                         out.fill(space, self.identity.convert_to(space, dtype))
                     return out
                 loop.do_accumulate(space, shape, self.func, obj, dtype, axis,
-                                    out, self.identity, temp)
+                                    out, self.identity)
             else:
                 if out:
                     call__array_wrap__ = False


More information about the pypy-commit mailing list