shunwang / numexpr

Automatically exported from code.google.com/p/numexpr
MIT License
0 stars 0 forks source link

Reduction failure #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. a = np.array([1,1])
2. b = 2
3. numexpr.evaluate('a + 2 * b', out=a)

expected: array([5,5])
actual: array([8,8])

What version of the product are you using? On what operating system?
Numexpr 2.0

Please provide any additional information below.
Reduction is very usual and important in HPC.

Original issue reported on code.google.com by pierre.c...@gmail.com on 24 Jan 2012 at 9:54

GoogleCodeExporter commented 9 years ago
This isn't itself a reduction, but rather a step in a reduction, yes? The 
trouble here is that the out= parameter introduced a new possibility of overlap 
between the input and output that didn't exist before.

In the case of an input overlapping an output, as in this case, numexpr should 
allocate a buffer for the output, then add a step to the end of its program to 
copy that buffer to the output.

Original comment by mwwi...@gmail.com on 25 Jan 2012 at 8:34

GoogleCodeExporter commented 9 years ago
> This isn't itself a reduction, but rather a step in a reduction, yes?
that's correct.

there are cases that could be optimised, where the output only appears once in 
the expression, at the top-level, in which case no copy would be necessary, but 
the general approach that you've described would already be a big improvement!

Original comment by pierre.c...@gmail.com on 25 Jan 2012 at 7:36

GoogleCodeExporter commented 9 years ago
This should be fixed in revision 13427a49c453. Can you test to confirm?

Original comment by mwwi...@gmail.com on 1 Mar 2012 at 11:31

GoogleCodeExporter commented 9 years ago
Splendid, it works perfectly !!!
Thanks a lot !

Original comment by pierre.c...@gmail.com on 15 Mar 2012 at 10:14