提交 7a515454 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Add tests for strides with abs value > 1

上级 a42afaf6
...@@ -195,8 +195,10 @@ def test_dot22_strides(): ...@@ -195,8 +195,10 @@ def test_dot22_strides():
mode=mode_with_gpu) mode=mode_with_gpu)
# Try with all stride patterns, and all transposed pattern # Try with all stride patterns, and all transposed pattern
for steps in itertools.product((-1, 1), repeat=4): for step_signs in itertools.product((-1, 1), repeat=4):
b_step1, b_step2, c_step1, c_step2 = steps for step in (1, 2):
b_step1, b_step2, c_step1, c_step2 = (s * step
for s in step_signs)
b.set_value(b_gpu.copy()[::b_step1, ::b_step2], borrow=True) b.set_value(b_gpu.copy()[::b_step1, ::b_step2], borrow=True)
c.set_value(c_gpu.copy()[::c_step1, ::c_step2], borrow=True) c.set_value(c_gpu.copy()[::c_step1, ::c_step2], borrow=True)
...@@ -263,8 +265,10 @@ def test_dot22scalar_strides(): ...@@ -263,8 +265,10 @@ def test_dot22scalar_strides():
mode=mode_with_gpu) mode=mode_with_gpu)
# Try with all stride patterns, and all transposed pattern # Try with all stride patterns, and all transposed pattern
for steps in itertools.product((-1, 1), repeat=4): for step_signs in itertools.product((-1, 1), repeat=4):
b_step1, b_step2, c_step1, c_step2 = steps for step in (1, 2):
b_step1, b_step2, c_step1, c_step2 = (s * step
for s in step_signs)
b.set_value(b_gpu.copy()[::b_step1, ::b_step2], borrow=True) b.set_value(b_gpu.copy()[::b_step1, ::b_step2], borrow=True)
c.set_value(c_gpu.copy()[::c_step1, ::c_step2], borrow=True) c.set_value(c_gpu.copy()[::c_step1, ::c_step2], borrow=True)
...@@ -341,8 +345,10 @@ def test_gemm_strides(): ...@@ -341,8 +345,10 @@ def test_gemm_strides():
mode=mode_with_gpu) mode=mode_with_gpu)
# Try with all stride patterns, and all transposed pattern # Try with all stride patterns, and all transposed pattern
for steps in itertools.product((-1, 1), repeat=6): for step_signs in itertools.product((-1, 1), repeat=6):
a_step1, a_step2, b_step1, b_step2, c_step1, c_step2 = steps for step in (1, 2):
a_step1, a_step2, b_step1, b_step2, c_step1, c_step2 = \
(s * step for s in step_signs)
b.set_value(b_gpu.copy()[::b_step1, ::b_step2], borrow=True) b.set_value(b_gpu.copy()[::b_step1, ::b_step2], borrow=True)
c.set_value(c_gpu.copy()[::c_step1, ::c_step2], borrow=True) c.set_value(c_gpu.copy()[::c_step1, ::c_step2], borrow=True)
...@@ -433,8 +439,10 @@ def test_gemv_strides(): ...@@ -433,8 +439,10 @@ def test_gemv_strides():
mode=mode_with_gpu) mode=mode_with_gpu)
# Try with all stride patterns, and all transposed pattern # Try with all stride patterns, and all transposed pattern
for steps in itertools.product((1, -1), repeat=4): for step_signs in itertools.product((1, -1), repeat=4):
a_step, b_step1, b_step2, c_step = steps for step in (1, 2):
a_step, b_step1, b_step2, c_step = (s * step
for s in step_signs)
a.set_value(a_gpu.copy()[::a_step], borrow=True) a.set_value(a_gpu.copy()[::a_step], borrow=True)
b.set_value(b_gpu.copy()[::b_step1, ::b_step2], b.set_value(b_gpu.copy()[::b_step1, ::b_step2],
...@@ -485,8 +493,11 @@ def test_ger_strides(): ...@@ -485,8 +493,11 @@ def test_ger_strides():
mode=mode_with_gpu) mode=mode_with_gpu)
# Try with all stride patterns, and all transposed patterns # Try with all stride patterns, and all transposed patterns
for steps in itertools.product((1, -1), repeat=4): for step_signs in itertools.product((1, -1), repeat=4):
a_step1, a_step2, b_step, c_step = steps for step in (1, 2):
a_step1, a_step2, b_step, c_step = (s * step
for s in step_signs)
a.set_value(a_gpu.copy()[::a_step1, ::a_step2], borrow=True) a.set_value(a_gpu.copy()[::a_step1, ::a_step2], borrow=True)
a_t.set_value(transpose(a_gpu.copy())[::a_step1, ::a_step2], a_t.set_value(transpose(a_gpu.copy())[::a_step1, ::a_step2],
borrow=True) borrow=True)
...@@ -501,7 +512,8 @@ def test_ger_strides(): ...@@ -501,7 +512,8 @@ def test_ger_strides():
f_t() f_t()
n_t = (av.T[::a_step1, ::a_step2] n_t = (av.T[::a_step1, ::a_step2]
+ l * numpy.outer(bv[::b_step], cv[::c_step]).T) + l * numpy.outer(bv[::b_step], cv[::c_step]).T)
assert numpy.allclose(a_t.get_value(), n_t), (a_t.get_value(), n_t) assert numpy.allclose(a_t.get_value(), n_t),\
(a_t.get_value(), n_t)
cmp((3, 5), 3, 5) cmp((3, 5), 3, 5)
cmp((1, 5), 1, 5) cmp((1, 5), 1, 5)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论