Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[1.x][LT] Add forward, backward test for linalg.gemm2 #18784

Merged
merged 7 commits into from
Jul 28, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/nightly/test_large_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,22 @@ def test_sparse_dot():
assert out.shape == (2, 2)


def test_gemm2():
def run_gemm2(inp1,inp2):
inp1.attach_grad()
inp2.attach_grad()
with mx.autograd.record():
out = mx.nd.linalg.gemm2(inp1,inp2)
return inp1.grad, inp2.grad, out

inp1=mx.nd.ones(shape=(SMALL_Y, LARGE_X))
inp2=mx.nd.ones(shape=(LARGE_X, SMALL_Y))
inp1_grad, inp2_grad, out= run_gemm2(inp1,inp2)
assert out.asnumpy()[0][0] == LARGE_X
out.backward()
assert inp1_grad.asnumpy()[0][0] == 49.2


if __name__ == '__main__':
import nose
nose.runmodule()