[NumPy-Tickets] [NumPy] #2209: Inconsistent dot product with BLAS
NumPy Trac
numpy-tickets@scipy....
Wed Aug 29 02:08:05 CDT 2012
#2209: Inconsistent dot product with BLAS
------------------------------------------------+---------------------------
Reporter: law | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: numpy.core | Version: 1.6.2
Keywords: dot product blas dotblas sse2 sse3 |
------------------------------------------------+---------------------------
Hello,
I found some strang bug related to numpy dot product. When using numpy-
sse2 or numpy-sse3 I get different results for the same data and the same
script. The test script is as follows:
{{{
#test script
from numpy import *
a = [-0.07738518658898276004, 0.96881291391416879399,
-0.00769691931712315151, 0.08111387479193514494, 0.11885744586034743819,
0.05882337083773133551]
a2 = [ \
[0, 0, 0, 0, 0, 0], \
[-0.07738518658898276004, 0.96881291391416879399,
-0.00769691931712315151, 0.08111387479193514494, 0.11885744586034743819,
0.05882337083773133551] \
]
b = [0.89887845358462115097, -0.08609082382649151099,
-0.02124706755589483506, 0.22391191935591209239, 0.32810168298084929628,
0.16237978892078003268]
set_printoptions(precision=20)
ab = dot(a, b)
a2b = dot(a2, b)
ab_i = inner(array(a), swapaxes(array(b), -1, -2))
a2b_i = inner(array(a2), swapaxes(array(b), -1, -2))
r = 0
for i in range(6):
r = r + a[i] * b[i]
print "dot: %.20f" % ab
print "dot2: %.20f" % a2b[1]
print "inner: %.20f" % ab_i
print "inner2: %.20f" % a2b_i[1]
print "sum_prod: %.20f" % r
}}}
And I get:
{{{
C:\Documents and Settings\1>python c:\temp\t0.py
dot: -0.08609082382649152487
dot2: -0.08609082382649149712
inner: -0.08609082382649152487
inner2: -0.08609082382649149712
sum_prod: -0.08609082382649149712
C:\Documents and Settings\1>python -i c:\temp\t0.py
dot: -0.08609082382649152487
dot2: -0.08609082382649151099
inner: -0.08609082382649152487
inner2: -0.08609082382649151099
sum_prod: -0.08609082382649149712
>>> quit()
C:\Documents and Settings\1>python c:\temp\t0.py
dot: -0.08609082382649152487
dot2: -0.08609082382649149712
inner: -0.08609082382649152487
inner2: -0.08609082382649149712
sum_prod: -0.08609082382649149712
C:\Documents and Settings\1>python -i c:\temp\t0.py
dot: -0.08609082382649152487
dot2: -0.08609082382649151099
inner: -0.08609082382649152487
inner2: -0.08609082382649151099
sum_prod: -0.08609082382649149712
>>> quit()
}}}
Surely, I don't change the script or anything else between runs. It seems
that the result depends on something, but I can't figure out what exactly.
In this particular example that difference caused by -i switch, other time
result changed when I add -x or -u, or just run script two time in a row.
I come to conclusion that this strange behavior related to dotblas, cause
I tried to replace numpy-sse3 with numpy-1.6.2-nosse (numpy-1.7.0b1-nosse)
the results are constant and match to simple sum of products:
C:\Documents and Settings\1>python c:\temp\t0.py
dot: -0.08609082382649149712
dot2: -0.08609082382649149712
inner: -0.08609082382649149712
inner2: -0.08609082382649149712
sum_prod: -0.08609082382649149712
At the same time I see that "random" fluctuations with numpy-1.6.2-sse2,
numpy-1.6.2-sse3, numpy-1.7.0b1-sse2, numpy-1.7.0b1-sse3 and on Windows
XP, Windows 2008, Windows 7 (tested on real and virtual machines (AMD
CPU))
I can perform other tests if it can be helpful.
Best regards,
Alexander
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/2209>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list