You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/07/29 07:34:02 UTC

[GitHub] [incubator-mxnet] ChaiBapchya commented on a change in pull request #18784: [1.x][LT] Add forward, backward test for linalg.gemm2

ChaiBapchya commented on a change in pull request #18784:
URL: https://github.com/apache/incubator-mxnet/pull/18784#discussion_r461134108



##########
File path: tests/nightly/test_large_array.py
##########
@@ -1207,9 +1207,28 @@ def check_syrk_batch():
         assert A.grad[0,0,0] == 4
         assert_almost_equal(A.grad[1,0,0], nd.array([0.4]), rtol=1e-3, atol=1e-5)
 
+    def check_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))
+        inp1[0][0]=0.1
+        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] == SMALL_Y
+        assert_almost_equal(inp2_grad.asnumpy()[0][0],49.1)
+

Review comment:
       Added




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org