Commits

mattip committed fd0b8b5

back out changeset: 92d3270bf0ab

  • Participants
  • Parent commits 6d2a659
  • Branches missing-ndarray-attributes

Comments (0)

Files changed (1)

pypy/module/micronumpy/loop.py

         y_iter.next()
     return out
 
-axis_reduce1__driver = jit.JitDriver(name='numpy_axis_reduce',
-                                    greens=['shapelen', 
+axis_reduce__driver = jit.JitDriver(name='numpy_axis_reduce',
+                                    greens=['shapelen', 'cumultative',
                                             'func', 'dtype',
                                             'identity'],
                                     reds=['axis', 'arr', 'out', 'shape',
                                           'out_iter', 'arr_iter',
                                           'temp_iter'])
-axis_reduce2__driver = jit.JitDriver(name='numpy_axis_reduce',
-                                    greens=['shapelen', 
-                                            'func', 'dtype',
-                                            'identity'],
-                                    reds=['axis', 'arr', 'out', 'shape',
-                                          'out_iter', 'arr_iter',
-                                          ])
 
 def do_axis_reduce(shape, func, arr, dtype, axis, out, identity, cumultative,
                    temp):
+    out_iter = out.create_axis_iter(arr.get_shape(), axis, cumultative)
     if cumultative:
-        return do_cum_axis_reduce(shape, func, arr, dtype, axis, out, 
-                identity, temp)
+        temp_iter = temp.create_axis_iter(arr.get_shape(), axis, False)
     else:
-        return do_nocum_axis_reduce(shape, func, arr, dtype, axis, out, 
-                identity, temp)
-
-def do_cum_axis_reduce(shape, func, arr, dtype, axis, out, identity,
-                   temp):
-    out_iter = out.create_axis_iter(arr.get_shape(), axis, True)
-    temp_iter = temp.create_axis_iter(arr.get_shape(), axis, False)
+        temp_iter = out_iter # hack
     arr_iter = arr.create_iter()
     if identity is not None:
         identity = identity.convert_to(dtype)
     shapelen = len(shape)
     while not out_iter.done():
-        axis_reduce1__driver.jit_merge_point(shapelen=shapelen, func=func,
+        axis_reduce__driver.jit_merge_point(shapelen=shapelen, func=func,
                                             dtype=dtype, identity=identity,
                                             axis=axis, arr=arr, out=out,
                                             shape=shape, out_iter=out_iter,
                                             arr_iter=arr_iter,
+                                            cumultative=cumultative,
                                             temp_iter=temp_iter)
         w_val = arr_iter.getitem().convert_to(dtype)
         if out_iter.first_line:
             cur = temp_iter.getitem()
             w_val = func(dtype, cur, w_val)
         out_iter.setitem(w_val)
-        temp_iter.setitem(w_val)
-        temp_iter.next()
-        arr_iter.next()
-        out_iter.next()
-    return out
-
-def do_nocum_axis_reduce(shape, func, arr, dtype, axis, out, identity,
-                   temp):
-    out_iter = out.create_axis_iter(arr.get_shape(), axis, False)
-    arr_iter = arr.create_iter()
-    if identity is not None:
-        identity = identity.convert_to(dtype)
-    shapelen = len(shape)
-    while not out_iter.done():
-        axis_reduce2__driver.jit_merge_point(shapelen=shapelen, func=func,
-                                            dtype=dtype, identity=identity,
-                                            axis=axis, arr=arr, out=out,
-                                            shape=shape, out_iter=out_iter,
-                                            arr_iter=arr_iter,
-                                            )
-        w_val = arr_iter.getitem().convert_to(dtype)
-        if out_iter.first_line:
-            if identity is not None:
-                w_val = func(dtype, identity, w_val)
-        else:
-            cur = out_iter.getitem()
-            w_val = func(dtype, cur, w_val)
-        out_iter.setitem(w_val)
+        if cumultative:
+            temp_iter.setitem(w_val)
+            temp_iter.next()
         arr_iter.next()
         out_iter.next()
     return out