{"action":"created","comment":{"url":"https://api.github.com/repos/pfnet/chainer/pulls/comments/33842976","id":33842976,"diff_hunk":"@@ -0,0 +1,226 @@\n+import unittest\n+\n+import numpy\n+import six\n+\n+import chainer\n+from chainer import cuda\n+import chainer.functions as F\n+from chainer import gradient_check\n+from chainer.testing import attr\n+\n+\n+if cuda.available:\n+    cuda.init()\n+\n+\n+class _TestMatMul(unittest.TestCase):\n+\n+    def check_forward(self, x1_data, x2_data):\n+        x1 = chainer.Variable(x1_data)\n+        x2 = chainer.Variable(x2_data)\n+        y = self.op(x1, x2)\n+        if isinstance(y.data, cuda.GPUArray):\n+            self.assertTrue(hasattr(y.data.gpudata, 'device'))\n+        gradient_check.assert_allclose(self.forward_answer, y.data)\n+\n+    def forward_cpu(self):\n+        self.check_forward(self.x1, self.x2)\n+\n+    def test_matmul_forward_cpu(self):\n+        self.forward_cpu()\n+\n+    @attr.gpu\n+    def forward_gpu(self):\n+        self.check_forward(cuda.to_gpu(self.x1), cuda.to_gpu(self.x2))\n+\n+    @attr.gpu\n+    def test_matmul_forward_gpu(self):\n+        self.forward_gpu()","path":"tests/functions_tests/test_matmul.py","position":39,"original_position":39,"commit_id":"532a336752cada182b49f4da26e1909127d8ab75","original_commit_id":"532a336752cada182b49f4da26e1909127d8ab75","user":{"login":"beam2d","id":392019,"avatar_url":"https://avatars.githubusercontent.com/u/392019?v=3","gravatar_id":"","url":"https://api.github.com/users/beam2d","html_url":"https://github.com/beam2d","followers_url":"https://api.github.com/users/beam2d/followers","following_url":"https://api.github.com/users/beam2d/following{/other_user}","gists_url":"https://api.github.com/users/beam2d/gists{/gist_id}","starred_url":"https://api.github.com/users/beam2d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beam2d/subscriptions","organizations_url":"https://api.github.com/users/beam2d/orgs","repos_url":"https://api.github.com/users/beam2d/repos","events_url":"https://api.github.com/users/beam2d/events{/privacy}","received_events_url":"https://api.github.com/users/beam2d/received_events","type":"User","site_admin":false},"body":"ditto","created_at":"2015-07-03T06:34:49Z","updated_at":"2015-07-03T06:34:49Z","html_url":"https://github.com/pfnet/chainer/pull/116#discussion_r33842976","pull_request_url":"https://api.github.com/repos/pfnet/chainer/pulls/116","_links":{"self":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/comments/33842976"},"html":{"href":"https://github.com/pfnet/chainer/pull/116#discussion_r33842976"},"pull_request":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/116"}}},"pull_request":{"url":"https://api.github.com/repos/pfnet/chainer/pulls/116","id":39057157,"html_url":"https://github.com/pfnet/chainer/pull/116","diff_url":"https://github.com/pfnet/chainer/pull/116.diff","patch_url":"https://github.com/pfnet/chainer/pull/116.patch","issue_url":"https://api.github.com/repos/pfnet/chainer/issues/116","number":116,"state":"open","locked":false,"title":"Matrix multiplication (or dot product)","user":{"login":"muupan","id":815970,"avatar_url":"https://avatars.githubusercontent.com/u/815970?v=3","gravatar_id":"","url":"https://api.github.com/users/muupan","html_url":"https://github.com/muupan","followers_url":"https://api.github.com/users/muupan/followers","following_url":"https://api.github.com/users/muupan/following{/other_user}","gists_url":"https://api.github.com/users/muupan/gists{/gist_id}","starred_url":"https://api.github.com/users/muupan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muupan/subscriptions","organizations_url":"https://api.github.com/users/muupan/orgs","repos_url":"https://api.github.com/users/muupan/repos","events_url":"https://api.github.com/users/muupan/events{/privacy}","received_events_url":"https://api.github.com/users/muupan/received_events","type":"User","site_admin":false},"body":"This PR adds two functions named ```matmul``` and ```batch_matmul```, both of which do matrix multiplication of two ```Variable```s representing matrices. They also can be used to compute vector inner products.\r\n\r\n```matmul``` accepts two ```Variable```s that are 1-D or 2-D arrays. 1-D arrays are treated as column vectors while 2-D arrays are as matrices. Its output is always a 2-D array representing a matrix.\r\n\r\n```batch_matmul``` accepts two ```Variable```s that are 2-D or 3-D arrays. 2-D arrays are treated as batches of column vectors while 3-D arrays are as batches of matrices. Its output is always a 3-D array representing a batch of matrices.\r\n\r\nBoth accept Boolean options ```transa``` and ```transb``` for transposing corresponding argument matrices.\r\n\r\nThis PR may solve #8.","created_at":"2015-07-02T08:03:20Z","updated_at":"2015-07-03T06:34:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"63b5b0931b7a3edc7d934a804d0497be9cd85df7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pfnet/chainer/pulls/116/commits","review_comments_url":"https://api.github.com/repos/pfnet/chainer/pulls/116/comments","review_comment_url":"https://api.github.com/repos/pfnet/chainer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pfnet/chainer/issues/116/comments","statuses_url":"https://api.github.com/repos/pfnet/chainer/statuses/532a336752cada182b49f4da26e1909127d8ab75","head":{"label":"muupan:matmul","ref":"matmul","sha":"532a336752cada182b49f4da26e1909127d8ab75","user":{"login":"muupan","id":815970,"avatar_url":"https://avatars.githubusercontent.com/u/815970?v=3","gravatar_id":"","url":"https://api.github.com/users/muupan","html_url":"https://github.com/muupan","followers_url":"https://api.github.com/users/muupan/followers","following_url":"https://api.github.com/users/muupan/following{/other_user}","gists_url":"https://api.github.com/users/muupan/gists{/gist_id}","starred_url":"https://api.github.com/users/muupan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muupan/subscriptions","organizations_url":"https://api.github.com/users/muupan/orgs","repos_url":"https://api.github.com/users/muupan/repos","events_url":"https://api.github.com/users/muupan/events{/privacy}","received_events_url":"https://api.github.com/users/muupan/received_events","type":"User","site_admin":false},"repo":{"id":37308816,"name":"chainer","full_name":"muupan/chainer","owner":{"login":"muupan","id":815970,"avatar_url":"https://avatars.githubusercontent.com/u/815970?v=3","gravatar_id":"","url":"https://api.github.com/users/muupan","html_url":"https://github.com/muupan","followers_url":"https://api.github.com/users/muupan/followers","following_url":"https://api.github.com/users/muupan/following{/other_user}","gists_url":"https://api.github.com/users/muupan/gists{/gist_id}","starred_url":"https://api.github.com/users/muupan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muupan/subscriptions","organizations_url":"https://api.github.com/users/muupan/orgs","repos_url":"https://api.github.com/users/muupan/repos","events_url":"https://api.github.com/users/muupan/events{/privacy}","received_events_url":"https://api.github.com/users/muupan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/muupan/chainer","description":"A flexible framework of neural networks for deep learning","fork":true,"url":"https://api.github.com/repos/muupan/chainer","forks_url":"https://api.github.com/repos/muupan/chainer/forks","keys_url":"https://api.github.com/repos/muupan/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/muupan/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/muupan/chainer/teams","hooks_url":"https://api.github.com/repos/muupan/chainer/hooks","issue_events_url":"https://api.github.com/repos/muupan/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/muupan/chainer/events","assignees_url":"https://api.github.com/repos/muupan/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/muupan/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/muupan/chainer/tags","blobs_url":"https://api.github.com/repos/muupan/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/muupan/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/muupan/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/muupan/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/muupan/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/muupan/chainer/languages","stargazers_url":"https://api.github.com/repos/muupan/chainer/stargazers","contributors_url":"https://api.github.com/repos/muupan/chainer/contributors","subscribers_url":"https://api.github.com/repos/muupan/chainer/subscribers","subscription_url":"https://api.github.com/repos/muupan/chainer/subscription","commits_url":"https://api.github.com/repos/muupan/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/muupan/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/muupan/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/muupan/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/muupan/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/muupan/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/muupan/chainer/merges","archive_url":"https://api.github.com/repos/muupan/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/muupan/chainer/downloads","issues_url":"https://api.github.com/repos/muupan/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/muupan/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/muupan/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/muupan/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/muupan/chainer/labels{/name}","releases_url":"https://api.github.com/repos/muupan/chainer/releases{/id}","created_at":"2015-06-12T07:38:13Z","updated_at":"2015-06-12T07:38:13Z","pushed_at":"2015-07-02T13:02:33Z","git_url":"git://github.com/muupan/chainer.git","ssh_url":"git@github.com:muupan/chainer.git","clone_url":"https://github.com/muupan/chainer.git","svn_url":"https://github.com/muupan/chainer","homepage":"http://chainer.org","size":6415,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pfnet:master","ref":"master","sha":"e2ee9d6a2f3aa914f6733f46128718311ebbd009","user":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"repo":{"id":36914478,"name":"chainer","full_name":"pfnet/chainer","owner":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pfnet/chainer","description":"A flexible framework of neural networks for deep learning","fork":false,"url":"https://api.github.com/repos/pfnet/chainer","forks_url":"https://api.github.com/repos/pfnet/chainer/forks","keys_url":"https://api.github.com/repos/pfnet/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pfnet/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pfnet/chainer/teams","hooks_url":"https://api.github.com/repos/pfnet/chainer/hooks","issue_events_url":"https://api.github.com/repos/pfnet/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/pfnet/chainer/events","assignees_url":"https://api.github.com/repos/pfnet/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/pfnet/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/pfnet/chainer/tags","blobs_url":"https://api.github.com/repos/pfnet/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pfnet/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pfnet/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/pfnet/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pfnet/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/pfnet/chainer/languages","stargazers_url":"https://api.github.com/repos/pfnet/chainer/stargazers","contributors_url":"https://api.github.com/repos/pfnet/chainer/contributors","subscribers_url":"https://api.github.com/repos/pfnet/chainer/subscribers","subscription_url":"https://api.github.com/repos/pfnet/chainer/subscription","commits_url":"https://api.github.com/repos/pfnet/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/pfnet/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/pfnet/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/pfnet/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/pfnet/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/pfnet/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pfnet/chainer/merges","archive_url":"https://api.github.com/repos/pfnet/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pfnet/chainer/downloads","issues_url":"https://api.github.com/repos/pfnet/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/pfnet/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/pfnet/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/pfnet/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pfnet/chainer/labels{/name}","releases_url":"https://api.github.com/repos/pfnet/chainer/releases{/id}","created_at":"2015-06-05T05:50:37Z","updated_at":"2015-07-03T06:19:41Z","pushed_at":"2015-07-03T03:47:10Z","git_url":"git://github.com/pfnet/chainer.git","ssh_url":"git@github.com:pfnet/chainer.git","clone_url":"https://github.com/pfnet/chainer.git","svn_url":"https://github.com/pfnet/chainer","homepage":"http://chainer.org","size":8343,"stargazers_count":469,"watchers_count":469,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":51,"mirror_url":null,"open_issues_count":38,"forks":51,"open_issues":38,"watchers":469,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/116"},"html":{"href":"https://github.com/pfnet/chainer/pull/116"},"issue":{"href":"https://api.github.com/repos/pfnet/chainer/issues/116"},"comments":{"href":"https://api.github.com/repos/pfnet/chainer/issues/116/comments"},"review_comments":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/116/comments"},"review_comment":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/116/commits"},"statuses":{"href":"https://api.github.com/repos/pfnet/chainer/statuses/532a336752cada182b49f4da26e1909127d8ab75"}}}}