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

Address comments.

上级 4703a2b4
...@@ -149,8 +149,22 @@ class SparseBlockOuterSS(GpuOp): ...@@ -149,8 +149,22 @@ class SparseBlockOuterSS(GpuOp):
sparse_block_outer_ss = SparseBlockOuterSS() sparse_block_outer_ss = SparseBlockOuterSS()
#############################################################
# All code above this line is unused (except for the imports)
def sparse_block_dot_DS(W, h, inputIdx, b, outputIdx): def sparse_block_dot_DS(W, h, inputIdx, b, outputIdx):
"""
var: shape, comment
W: (iBlocks, oBlocks, iSize, oSize), weight matrix
h: (iWin, iSize), input from lower layer (sparse)
inputIdx: (iWin,), indexes of the input blocks
b: (oBlocks, oSize), bias vector
outputIdx: (oWin,), indexes of the output blocks
returns (oBlocks, oSize), dot(W[i, j], h[i]) + b[j]
but b[j] is only added once
"""
o = b.take(outputIdx, axis=0) o = b.take(outputIdx, axis=0)
def outer_fn(out_id, W, h, b, iIdx): def outer_fn(out_id, W, h, b, iIdx):
def inner_fn(inp_id, h_i, out_id, W): def inner_fn(inp_id, h_i, out_id, W):
......
...@@ -24,7 +24,7 @@ def blocksparse_data(): ...@@ -24,7 +24,7 @@ def blocksparse_data():
return weight, input, inputIndice, bias, outputIndice return weight, input, inputIndice, bias, outputIndice
def blocksparse(W, h, iIdx, b, oIdx): def blocksparse(W, h, iIdx, b, oIdx):
o = b.take(oIdx, axis=0).copy() o = b.take(oIdx, axis=0)
for j in range(o.shape[0]): for j in range(o.shape[0]):
outputIdx = oIdx[j] outputIdx = oIdx[j]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论