Author: Richard Plangger <r...@pasra.at> Branch: vecopt-merge Changeset: r78881:4dcddb2caee3 Date: 2015-08-11 11:59 +0200 http://bitbucket.org/pypy/pypy/changeset/4dcddb2caee3/
Log: added missing vectorize=True for the jit drivers in loop.py diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py --- a/pypy/module/micronumpy/compile.py +++ b/pypy/module/micronumpy/compile.py @@ -15,7 +15,7 @@ from pypy.module.micronumpy.descriptor import get_dtype_cache from pypy.interpreter.miscutils import ThreadLocals, make_weak_value_dictionary from pypy.interpreter.executioncontext import (ExecutionContext, ActionFlag, - UserDelAction, CodeUniqueIds) + UserDelAction) from pypy.interpreter.pyframe import PyFrame @@ -93,7 +93,6 @@ self.config = config self.interned_strings = make_weak_value_dictionary(self, str, W_Root) - self.code_unique_ids = CodeUniqueIds() self.builtin = DictObject({}) self.FrameClass = PyFrame self.threadlocals = ThreadLocals() @@ -165,6 +164,10 @@ lgt = (stop - start - 1) / step + 1 return (start, stop, step, lgt) + def unicode_from_object(self, w_item): + # XXX + return StringObject("") + @specialize.argtype(1) def wrap(self, obj): if isinstance(obj, float): @@ -281,6 +284,12 @@ return w_obj.v raise NotImplementedError + def unicode_w(self, w_obj): + # XXX + if isinstance(w_obj, StringObject): + return unicode(w_obj.v) + raise NotImplementedError + def int(self, w_obj): if isinstance(w_obj, IntObject): return w_obj diff --git a/pypy/module/micronumpy/flatiter.py b/pypy/module/micronumpy/flatiter.py --- a/pypy/module/micronumpy/flatiter.py +++ b/pypy/module/micronumpy/flatiter.py @@ -97,7 +97,7 @@ finally: self.iter.reset(self.state, mutate=True) - def descr___array_wrap__(self, space, obj): + def descr___array_wrap__(self, space, obj, w_context=None): return obj W_FlatIterator.typedef = TypeDef("numpy.flatiter", 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 @@ -9,7 +9,7 @@ from pypy.module.micronumpy import support, constants as NPY from pypy.module.micronumpy.base import W_NDimArray, convert_to_array from pypy.module.micronumpy.iterators import PureShapeIter, AxisIter, \ - AllButAxisIter + AllButAxisIter, ArrayIter from pypy.interpreter.argument import Arguments @@ -202,29 +202,28 @@ reduce_flat_driver = jit.JitDriver( name='numpy_reduce_flat', - greens = ['shapelen', 'func', 'done_func', 'calc_dtype'], reds = 'auto') + greens = ['shapelen', 'func', 'done_func', 'calc_dtype'], reds = 'auto', + vectorize = True) -def compute_reduce(space, obj, calc_dtype, func, done_func, identity): - obj_iter, obj_state = obj.create_iter() +def reduce_flat(space, func, w_arr, calc_dtype, done_func, identity): + obj_iter, obj_state = w_arr.create_iter() if identity is None: cur_value = obj_iter.getitem(obj_state).convert_to(space, calc_dtype) obj_state = obj_iter.next(obj_state) else: cur_value = identity.convert_to(space, calc_dtype) - shapelen = len(obj.get_shape()) + shapelen = len(w_arr.get_shape()) while not obj_iter.done(obj_state): - reduce_driver.jit_merge_point(shapelen=shapelen, func=func, - done_func=done_func, - calc_dtype=calc_dtype) + reduce_flat_driver.jit_merge_point( + shapelen=shapelen, func=func, + done_func=done_func, calc_dtype=calc_dtype) rval = obj_iter.getitem(obj_state).convert_to(space, calc_dtype) if done_func is not None and done_func(calc_dtype, rval): return rval cur_value = func(calc_dtype, cur_value, rval) obj_state = obj_iter.next(obj_state) - rval = None return cur_value - reduce_driver = jit.JitDriver( name='numpy_reduce', greens=['shapelen', 'func', 'dtype'], reds='auto', @@ -316,7 +315,8 @@ accumulate_driver = jit.JitDriver( name='numpy_accumulate', - greens=['shapelen', 'func', 'calc_dtype'], reds='auto', + greens=['shapelen', 'func', 'calc_dtype'], + reds='auto', vectorize=True) @@ -367,7 +367,8 @@ where_driver = jit.JitDriver(name='numpy_where', greens = ['shapelen', 'dtype', 'arr_dtype'], - reds = 'auto', vectorize=True) + reds = 'auto', + vectorize=True) def where(space, out, shape, arr, x, y, dtype): out_iter, out_state = out.create_iter(shape) diff --git a/pypy/module/micronumpy/strides.py b/pypy/module/micronumpy/strides.py --- a/pypy/module/micronumpy/strides.py +++ b/pypy/module/micronumpy/strides.py @@ -7,6 +7,7 @@ # structures to describe slicing class BaseChunk(object): + _attrs_ = ['step'] pass 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 @@ -276,7 +276,7 @@ loop.accumulate_flat( space, self.func, obj, dtype, out, self.identity) if call__array_wrap__: - out = space.call_method(obj, '__array_wrap__', out) + out = space.call_method(obj, '__array_wrap__', out, None) return out axis_flags = [False] * shapelen @@ -313,7 +313,7 @@ out.implementation.setitem(0, res) res = out if call__array_wrap__: - res = space.call_method(obj, '__array_wrap__', res) + res = space.call_method(obj, '__array_wrap__', res, None) return res else: @@ -360,7 +360,7 @@ loop.reduce( space, self.func, obj, axis_flags, dtype, out, self.identity) if call__array_wrap__: - out = space.call_method(obj, '__array_wrap__', out) + out = space.call_method(obj, '__array_wrap__', out, None) return out def descr_outer(self, space, __args__): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit