Skip to content

Commit

Permalink
fix small bug about dense_grad
Browse files Browse the repository at this point in the history
  • Loading branch information
handar423 committed May 29, 2020
1 parent 95b3ad9 commit 331bea8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/tvm/relay/op/_tensor_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ def bias_add_grad(orig, grad):
def dense_grad(orig, grad):
"""Returns [grad' @ weight, data @ grad']"""
data, weight = orig.args
return [collapse_sum_like(transpose(grad) * weight, data),
collapse_sum_like(data * transpose(grad), weight)]
return [collapse_sum_like(_nn.dense(grad, transpose(weight)), data),
collapse_sum_like(_nn.dense(transpose(grad), transpose(data)), weight)]


@register_gradient("reshape")
Expand Down
1 change: 1 addition & 0 deletions tests/python/relay/test_op_grad_level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def verify_dense_grad(d_shape, w_shape):
def test_dense_grad():
verify_dense_grad((1, 8), (16, 8))
verify_dense_grad((1, 4), (3, 4))
verify_dense_grad((5, 4), (3, 4))


def verify_batch_flatten_grad(d_shape):
Expand Down

0 comments on commit 331bea8

Please sign in to comment.