{"action":"created","comment":{"url":"https://api.github.com/repos/improbable-research/keanu/pulls/comments/211964484","pull_request_review_id":148494486,"id":211964484,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTk2NDQ4NA==","diff_hunk":"@@ -24,76 +24,116 @@\n  */\n public class INDArrayShim {\n \n-    public static void muli(INDArray left, INDArray right, INDArray result) {\n+    public static INDArray muli(INDArray left, INDArray right) {\n         if (Arrays.equals(left.shape(), right.shape())) {\n-            left.muli(right);\n+            return left.muli(right);\n         } else {\n-            broadcastMultiply(left, right, result);\n+            return broadcastMultiply(left, right);\n         }\n     }\n \n-    private static void broadcastMultiply(INDArray a, INDArray b, INDArray result) {\n-        int[] broadcastDimensions = Shape.getBroadcastDimensions(a.shape(), b.shape());\n-        execBroadcast(a, b,\n-            new BroadcastMulOp(a, b, result, broadcastDimensions)\n+    private static INDArray broadcastMultiply(INDArray a, INDArray b) {\n+        int[] broadcastDimensions = getBroadcastDimensions(a.shape(), b.shape());\n+        if (a.shape().length < b.shape().length) {\n+            return broadcastMultiply(b, a);\n+        }\n+        return execBroadcast(a, b,\n+            new BroadcastMulOp(a, b, a.dup(), broadcastDimensions)\n         );\n     }\n \n-    public static void divi(INDArray left, INDArray right, INDArray result) {\n+    public static INDArray divi(INDArray left, INDArray right) {\n         if (Arrays.equals(left.shape(), right.shape())) {\n-            left.divi(right);\n+            return left.divi(right);\n         } else {\n-            broadcastDivide(left, right, result);\n+            return broadcastDivide(left, right);\n         }\n     }\n \n-    private static void broadcastDivide(INDArray a, INDArray b, INDArray result) {\n-        int[] broadcastDimensions = Shape.getBroadcastDimensions(a.shape(), b.shape());\n-        execBroadcast(a, b,\n-            new BroadcastDivOp(a, b, result, broadcastDimensions)\n+    private static INDArray broadcastDivide(INDArray a, INDArray b) {\n+        int[] broadcastDimensions = getBroadcastDimensions(a.shape(), b.shape());\n+        if (a.shape().length < b.shape().length) {\n+            return broadcastMultiply(b, a.rdiv(1.0));","path":"keanu-project/src/main/java/io/improbable/keanu/tensor/INDArrayShim.java","position":47,"original_position":47,"commit_id":"74b91d65eb6a1133ab1532bd7b7108982fb59588","original_commit_id":"74b91d65eb6a1133ab1532bd7b7108982fb59588","user":{"login":"christophernorth","id":41296447,"node_id":"MDQ6VXNlcjQxMjk2NDQ3","avatar_url":"https://avatars3.githubusercontent.com/u/41296447?v=4","gravatar_id":"","url":"https://api.github.com/users/christophernorth","html_url":"https://github.com/christophernorth","followers_url":"https://api.github.com/users/christophernorth/followers","following_url":"https://api.github.com/users/christophernorth/following{/other_user}","gists_url":"https://api.github.com/users/christophernorth/gists{/gist_id}","starred_url":"https://api.github.com/users/christophernorth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christophernorth/subscriptions","organizations_url":"https://api.github.com/users/christophernorth/orgs","repos_url":"https://api.github.com/users/christophernorth/repos","events_url":"https://api.github.com/users/christophernorth/events{/privacy}","received_events_url":"https://api.github.com/users/christophernorth/received_events","type":"User","site_admin":false},"body":"although perhaps we should just call the Divide function anyway to make it easier to read?","created_at":"2018-08-22T13:59:15Z","updated_at":"2018-08-22T13:59:15Z","html_url":"https://github.com/improbable-research/keanu/pull/187#discussion_r211964484","pull_request_url":"https://api.github.com/repos/improbable-research/keanu/pulls/187","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/comments/211964484"},"html":{"href":"https://github.com/improbable-research/keanu/pull/187#discussion_r211964484"},"pull_request":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/187"}},"in_reply_to_id":211960990},"pull_request":{"url":"https://api.github.com/repos/improbable-research/keanu/pulls/187","id":210135777,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwMTM1Nzc3","html_url":"https://github.com/improbable-research/keanu/pull/187","diff_url":"https://github.com/improbable-research/keanu/pull/187.diff","patch_url":"https://github.com/improbable-research/keanu/pull/187.patch","issue_url":"https://api.github.com/repos/improbable-research/keanu/issues/187","number":187,"state":"open","locked":false,"title":"Fix broadcast ops","user":{"login":"GeorgeNash","id":5854544,"node_id":"MDQ6VXNlcjU4NTQ1NDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/5854544?v=4","gravatar_id":"","url":"https://api.github.com/users/GeorgeNash","html_url":"https://github.com/GeorgeNash","followers_url":"https://api.github.com/users/GeorgeNash/followers","following_url":"https://api.github.com/users/GeorgeNash/following{/other_user}","gists_url":"https://api.github.com/users/GeorgeNash/gists{/gist_id}","starred_url":"https://api.github.com/users/GeorgeNash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GeorgeNash/subscriptions","organizations_url":"https://api.github.com/users/GeorgeNash/orgs","repos_url":"https://api.github.com/users/GeorgeNash/repos","events_url":"https://api.github.com/users/GeorgeNash/events{/privacy}","received_events_url":"https://api.github.com/users/GeorgeNash/received_events","type":"User","site_admin":false},"body":"- Fixes a bug in the broadcast operations when operating on two tensors. Eg, multiplying a 2x2 by a 2x2x2x2 produced incorrect numbers and was different if you were doing A x B or B x A. The behaviour is now representative of numpy.\r\n- Fixes a bug in TensorShape prepend with 1's\r\n- Due to the behaviour of ND4J it's impossible to perform a broadcast in place on a tensor that has to increase in size. You could do an `inPlace` if multiplying a 2x2x2x2 by a 2x2, but not a 2x2 by a 2x2x2x2. To avoid confusing behaviour I've made it so that `inPlace` on a broadcast returns a duplicate. `There's no in place`.\r\n- Fixed `DoubleIfVertex` to use the new broadcast. It was using the previously broken broadcast to apply a mask in a pretty cheeky way \r\n\r\nIt's impossible in `ND4J` to currently do a broadcast op on a small tensor against a larger tensor. To get around this I've done some shenanigans with swapping to ensure the larger tensor is always the primary","created_at":"2018-08-22T13:35:08Z","updated_at":"2018-08-22T13:59:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"23cf1fda4b40546243f3b20e9ef28c35864dd622","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/improbable-research/keanu/pulls/187/commits","review_comments_url":"https://api.github.com/repos/improbable-research/keanu/pulls/187/comments","review_comment_url":"https://api.github.com/repos/improbable-research/keanu/pulls/comments{/number}","comments_url":"https://api.github.com/repos/improbable-research/keanu/issues/187/comments","statuses_url":"https://api.github.com/repos/improbable-research/keanu/statuses/74b91d65eb6a1133ab1532bd7b7108982fb59588","head":{"label":"improbable-research:bug/fixBroadcastOps","ref":"bug/fixBroadcastOps","sha":"74b91d65eb6a1133ab1532bd7b7108982fb59588","user":{"login":"improbable-research","id":37903994,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTAzOTk0","avatar_url":"https://avatars1.githubusercontent.com/u/37903994?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-research","html_url":"https://github.com/improbable-research","followers_url":"https://api.github.com/users/improbable-research/followers","following_url":"https://api.github.com/users/improbable-research/following{/other_user}","gists_url":"https://api.github.com/users/improbable-research/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-research/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-research/subscriptions","organizations_url":"https://api.github.com/users/improbable-research/orgs","repos_url":"https://api.github.com/users/improbable-research/repos","events_url":"https://api.github.com/users/improbable-research/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-research/received_events","type":"Organization","site_admin":false},"repo":{"id":128393918,"node_id":"MDEwOlJlcG9zaXRvcnkxMjgzOTM5MTg=","name":"keanu","full_name":"improbable-research/keanu","owner":{"login":"improbable-research","id":37903994,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTAzOTk0","avatar_url":"https://avatars1.githubusercontent.com/u/37903994?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-research","html_url":"https://github.com/improbable-research","followers_url":"https://api.github.com/users/improbable-research/followers","following_url":"https://api.github.com/users/improbable-research/following{/other_user}","gists_url":"https://api.github.com/users/improbable-research/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-research/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-research/subscriptions","organizations_url":"https://api.github.com/users/improbable-research/orgs","repos_url":"https://api.github.com/users/improbable-research/repos","events_url":"https://api.github.com/users/improbable-research/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-research/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/improbable-research/keanu","description":"A probabilistic approach from an Improbabilistic company","fork":false,"url":"https://api.github.com/repos/improbable-research/keanu","forks_url":"https://api.github.com/repos/improbable-research/keanu/forks","keys_url":"https://api.github.com/repos/improbable-research/keanu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/improbable-research/keanu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/improbable-research/keanu/teams","hooks_url":"https://api.github.com/repos/improbable-research/keanu/hooks","issue_events_url":"https://api.github.com/repos/improbable-research/keanu/issues/events{/number}","events_url":"https://api.github.com/repos/improbable-research/keanu/events","assignees_url":"https://api.github.com/repos/improbable-research/keanu/assignees{/user}","branches_url":"https://api.github.com/repos/improbable-research/keanu/branches{/branch}","tags_url":"https://api.github.com/repos/improbable-research/keanu/tags","blobs_url":"https://api.github.com/repos/improbable-research/keanu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/improbable-research/keanu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/improbable-research/keanu/git/refs{/sha}","trees_url":"https://api.github.com/repos/improbable-research/keanu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/improbable-research/keanu/statuses/{sha}","languages_url":"https://api.github.com/repos/improbable-research/keanu/languages","stargazers_url":"https://api.github.com/repos/improbable-research/keanu/stargazers","contributors_url":"https://api.github.com/repos/improbable-research/keanu/contributors","subscribers_url":"https://api.github.com/repos/improbable-research/keanu/subscribers","subscription_url":"https://api.github.com/repos/improbable-research/keanu/subscription","commits_url":"https://api.github.com/repos/improbable-research/keanu/commits{/sha}","git_commits_url":"https://api.github.com/repos/improbable-research/keanu/git/commits{/sha}","comments_url":"https://api.github.com/repos/improbable-research/keanu/comments{/number}","issue_comment_url":"https://api.github.com/repos/improbable-research/keanu/issues/comments{/number}","contents_url":"https://api.github.com/repos/improbable-research/keanu/contents/{+path}","compare_url":"https://api.github.com/repos/improbable-research/keanu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/improbable-research/keanu/merges","archive_url":"https://api.github.com/repos/improbable-research/keanu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/improbable-research/keanu/downloads","issues_url":"https://api.github.com/repos/improbable-research/keanu/issues{/number}","pulls_url":"https://api.github.com/repos/improbable-research/keanu/pulls{/number}","milestones_url":"https://api.github.com/repos/improbable-research/keanu/milestones{/number}","notifications_url":"https://api.github.com/repos/improbable-research/keanu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/improbable-research/keanu/labels{/name}","releases_url":"https://api.github.com/repos/improbable-research/keanu/releases{/id}","deployments_url":"https://api.github.com/repos/improbable-research/keanu/deployments","created_at":"2018-04-06T12:48:36Z","updated_at":"2018-08-22T13:42:26Z","pushed_at":"2018-08-22T13:42:23Z","git_url":"git://github.com/improbable-research/keanu.git","ssh_url":"git@github.com:improbable-research/keanu.git","clone_url":"https://github.com/improbable-research/keanu.git","svn_url":"https://github.com/improbable-research/keanu","homepage":"","size":4246,"stargazers_count":77,"watchers_count":77,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":13,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":19,"open_issues":13,"watchers":77,"default_branch":"develop"}},"base":{"label":"improbable-research:develop","ref":"develop","sha":"e9743220c69dd2f4127accc1ee8aaf4293a4d889","user":{"login":"improbable-research","id":37903994,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTAzOTk0","avatar_url":"https://avatars1.githubusercontent.com/u/37903994?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-research","html_url":"https://github.com/improbable-research","followers_url":"https://api.github.com/users/improbable-research/followers","following_url":"https://api.github.com/users/improbable-research/following{/other_user}","gists_url":"https://api.github.com/users/improbable-research/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-research/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-research/subscriptions","organizations_url":"https://api.github.com/users/improbable-research/orgs","repos_url":"https://api.github.com/users/improbable-research/repos","events_url":"https://api.github.com/users/improbable-research/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-research/received_events","type":"Organization","site_admin":false},"repo":{"id":128393918,"node_id":"MDEwOlJlcG9zaXRvcnkxMjgzOTM5MTg=","name":"keanu","full_name":"improbable-research/keanu","owner":{"login":"improbable-research","id":37903994,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3OTAzOTk0","avatar_url":"https://avatars1.githubusercontent.com/u/37903994?v=4","gravatar_id":"","url":"https://api.github.com/users/improbable-research","html_url":"https://github.com/improbable-research","followers_url":"https://api.github.com/users/improbable-research/followers","following_url":"https://api.github.com/users/improbable-research/following{/other_user}","gists_url":"https://api.github.com/users/improbable-research/gists{/gist_id}","starred_url":"https://api.github.com/users/improbable-research/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/improbable-research/subscriptions","organizations_url":"https://api.github.com/users/improbable-research/orgs","repos_url":"https://api.github.com/users/improbable-research/repos","events_url":"https://api.github.com/users/improbable-research/events{/privacy}","received_events_url":"https://api.github.com/users/improbable-research/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/improbable-research/keanu","description":"A probabilistic approach from an Improbabilistic company","fork":false,"url":"https://api.github.com/repos/improbable-research/keanu","forks_url":"https://api.github.com/repos/improbable-research/keanu/forks","keys_url":"https://api.github.com/repos/improbable-research/keanu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/improbable-research/keanu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/improbable-research/keanu/teams","hooks_url":"https://api.github.com/repos/improbable-research/keanu/hooks","issue_events_url":"https://api.github.com/repos/improbable-research/keanu/issues/events{/number}","events_url":"https://api.github.com/repos/improbable-research/keanu/events","assignees_url":"https://api.github.com/repos/improbable-research/keanu/assignees{/user}","branches_url":"https://api.github.com/repos/improbable-research/keanu/branches{/branch}","tags_url":"https://api.github.com/repos/improbable-research/keanu/tags","blobs_url":"https://api.github.com/repos/improbable-research/keanu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/improbable-research/keanu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/improbable-research/keanu/git/refs{/sha}","trees_url":"https://api.github.com/repos/improbable-research/keanu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/improbable-research/keanu/statuses/{sha}","languages_url":"https://api.github.com/repos/improbable-research/keanu/languages","stargazers_url":"https://api.github.com/repos/improbable-research/keanu/stargazers","contributors_url":"https://api.github.com/repos/improbable-research/keanu/contributors","subscribers_url":"https://api.github.com/repos/improbable-research/keanu/subscribers","subscription_url":"https://api.github.com/repos/improbable-research/keanu/subscription","commits_url":"https://api.github.com/repos/improbable-research/keanu/commits{/sha}","git_commits_url":"https://api.github.com/repos/improbable-research/keanu/git/commits{/sha}","comments_url":"https://api.github.com/repos/improbable-research/keanu/comments{/number}","issue_comment_url":"https://api.github.com/repos/improbable-research/keanu/issues/comments{/number}","contents_url":"https://api.github.com/repos/improbable-research/keanu/contents/{+path}","compare_url":"https://api.github.com/repos/improbable-research/keanu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/improbable-research/keanu/merges","archive_url":"https://api.github.com/repos/improbable-research/keanu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/improbable-research/keanu/downloads","issues_url":"https://api.github.com/repos/improbable-research/keanu/issues{/number}","pulls_url":"https://api.github.com/repos/improbable-research/keanu/pulls{/number}","milestones_url":"https://api.github.com/repos/improbable-research/keanu/milestones{/number}","notifications_url":"https://api.github.com/repos/improbable-research/keanu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/improbable-research/keanu/labels{/name}","releases_url":"https://api.github.com/repos/improbable-research/keanu/releases{/id}","deployments_url":"https://api.github.com/repos/improbable-research/keanu/deployments","created_at":"2018-04-06T12:48:36Z","updated_at":"2018-08-22T13:42:26Z","pushed_at":"2018-08-22T13:42:23Z","git_url":"git://github.com/improbable-research/keanu.git","ssh_url":"git@github.com:improbable-research/keanu.git","clone_url":"https://github.com/improbable-research/keanu.git","svn_url":"https://github.com/improbable-research/keanu","homepage":"","size":4246,"stargazers_count":77,"watchers_count":77,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":13,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":19,"open_issues":13,"watchers":77,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/187"},"html":{"href":"https://github.com/improbable-research/keanu/pull/187"},"issue":{"href":"https://api.github.com/repos/improbable-research/keanu/issues/187"},"comments":{"href":"https://api.github.com/repos/improbable-research/keanu/issues/187/comments"},"review_comments":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/187/comments"},"review_comment":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/improbable-research/keanu/pulls/187/commits"},"statuses":{"href":"https://api.github.com/repos/improbable-research/keanu/statuses/74b91d65eb6a1133ab1532bd7b7108982fb59588"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"christophernorth"}}