提交 d12f4aea authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Fix shape error in tests (which also means that we had wrong behavior).

上级 7f15e04a
......@@ -39,26 +39,26 @@ def gemm_batched(Al, Bl, Cl, m, n, k, lda, ldb, ldc,
def gemv(alpha, A, x, beta, y):
assert A.shape[1] == x.shape[0]
assert A.shape[0] == y.shape[0]
assert A.shape[0] == x.shape[0]
assert A.shape[1] == y.shape[0]
handle = scikits.cuda.misc._global_cublas_handle
cublas.cublasSgemv(handle, 't', A.shape[1], A.shape[0], alpha,
A.gpudata, max(A.strides[0], A.strides[1]),
cublas.cublasSgemv(handle, 'n', A.shape[1], A.shape[0], alpha,
A.gpudata, A.strides[0],
x.gpudata, x.strides[0],
beta, y.gpudata, y.strides[0])
def ger(alpha, x, y, A):
assert A.shape[0] == x.shape[0]
assert A.shape[1] == y.shape[0]
assert A.shape[1] == x.shape[0]
assert A.shape[0] == y.shape[0]
handle = scikits.cuda.misc._global_cublas_handle
cublas.cublasSger(handle, A.shape[1], A.shape[0], alpha,
y.gpudata, y.strides[0],
x.gpudata, x.strides[0],
y.gpudata, y.strides[0],
A.gpudata, A.strides[0])
......
......@@ -36,7 +36,7 @@ def blocksparse_data():
input = randn(inputWindowSize, inputSize).astype('float32')
inputIndice = numpy.random.permutation(nInputBlock)[:inputWindowSize]
outputIndice = numpy.random.permutation(nOutputBlock)[:outputWindowSize]
weight = randn(nInputBlock, nOutputBlock, outputSize, inputSize).astype('float32')
weight = randn(nInputBlock, nOutputBlock, inputSize, outputSize).astype('float32')
bias = randn(nOutputBlock, outputSize).astype('float32')
return weight, input, inputIndice, bias, outputIndice
......@@ -51,7 +51,7 @@ def blocksparse(W, h, iIdx, b, oIdx):
inputIdx = iIdx[i]
w = W[inputIdx, outputIdx]
# this below is a gemv I think
o[j, :] += numpy.dot(w, h[i])
o[j, :] += numpy.dot(h[i], w)
return o
......@@ -78,7 +78,7 @@ def test_blocksparse_grad():
h_val = randn(2, 3).astype('float32')
iIdx_val = numpy.random.permutation(3)[:2]
oIdx_val = numpy.random.permutation(3)[:2]
W_val = randn(3, 3, 4, 3).astype('float32')
W_val = randn(3, 3, 3, 4).astype('float32')
b_val = randn(3, 4).astype('float32')
iIdx = theano.tensor.constant(iIdx_val)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论