{"action":"created","issue":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/15636","repository_url":"https://api.github.com/repos/pytorch/pytorch","labels_url":"https://api.github.com/repos/pytorch/pytorch/issues/15636/labels{/name}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/15636/comments","events_url":"https://api.github.com/repos/pytorch/pytorch/issues/15636/events","html_url":"https://github.com/pytorch/pytorch/issues/15636","id":394917571,"node_id":"MDU6SXNzdWUzOTQ5MTc1NzE=","number":15636,"title":"inaccurate description of torch.mul(tensor, tensor)","user":{"login":"elad663","id":8844895,"node_id":"MDQ6VXNlcjg4NDQ4OTU=","avatar_url":"https://avatars3.githubusercontent.com/u/8844895?v=4","gravatar_id":"","url":"https://api.github.com/users/elad663","html_url":"https://github.com/elad663","followers_url":"https://api.github.com/users/elad663/followers","following_url":"https://api.github.com/users/elad663/following{/other_user}","gists_url":"https://api.github.com/users/elad663/gists{/gist_id}","starred_url":"https://api.github.com/users/elad663/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elad663/subscriptions","organizations_url":"https://api.github.com/users/elad663/orgs","repos_url":"https://api.github.com/users/elad663/repos","events_url":"https://api.github.com/users/elad663/events{/privacy}","received_events_url":"https://api.github.com/users/elad663/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-12-31T01:39:11Z","updated_at":"2018-12-31T03:50:34Z","closed_at":null,"author_association":"NONE","body":"## 📚 Documentation for `torch.mul()`\r\n\r\nThe [doc](https://pytorch.org/docs/stable/torch.html#torch.mul) for `torch.mul(tensor, tensor)` is inaccurate.\r\n\r\nThere are two issues.\r\n1. The doc says that \r\n>Each element of the tensor input is multiplied by each element of the Tensor other\r\n\r\ni.e. a Cartesian product but then the doc provides the equation:\r\n\r\n>out_i = input_i * other_i. \r\n\r\nand then the example provided in the doc does not match the math...\r\n```\r\n>>> a = torch.randn(4, 1)\r\n>>> a\r\ntensor([[ 1.1207],\r\n        [-0.3137],\r\n        [ 0.0700],\r\n        [ 0.8378]])\r\n>>> b = torch.randn(1, 4)\r\n>>> b\r\ntensor([[ 0.5146,  0.1216, -0.5244,  2.2382]])\r\n>>> torch.mul(a, b)\r\ntensor([[ 0.5767,  0.1363, -0.5877,  2.5083],\r\n        [-0.1614, -0.0382,  0.1645, -0.7021],\r\n        [ 0.0360,  0.0085, -0.0367,  0.1567],\r\n        [ 0.4312,  0.1019, -0.4394,  1.8753]])\r\n```\r\n\r\n2. There is a case when the math is correct and the multiplication is the naive element-wise product.\r\n```\r\n>>> a\r\ntensor([[ 0.6680,  0.6326],\r\n        [-0.5282, -0.2136],\r\n        [ 0.1368,  1.3523],\r\n        [ 0.7610, -0.1188]])\r\n>>> b\r\ntensor([[-0.5711, -1.2996],\r\n        [ 1.4009,  0.5595],\r\n        [-0.6578,  0.9210],\r\n        [-0.4245,  0.9258]])\r\n>>> torch.mul(a,b)\r\ntensor([[-0.3815, -0.8222],\r\n        [-0.7400, -0.1195],\r\n        [-0.0900,  1.2455],\r\n        [-0.3231, -0.1100]])\r\n```\r\n\r\nIMHO a multiplication function that is sometime element-wise and sometime a matrix multiplication is open to undesired behavior if the user has an undetected issue with dimensions. Perhaps in the second case torch.mul() should complain about dimensions. But in any case the inconsistency should be documented. \r\n\r\n<!-- A clear and concise description of what content in https://pytorch.org/docs is an issue. If this has to do with the general https://pytorch.org website, please file an issue at https://github.com/pytorch/pytorch.github.io/issues/new/choose instead. If this has to do with https://pytorch.org/tutorials, please file an issue at https://github.com/pytorch/tutorials/issues/new -->\r\n"},"comment":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/comments/450605520","html_url":"https://github.com/pytorch/pytorch/issues/15636#issuecomment-450605520","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/15636","id":450605520,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDYwNTUyMA==","user":{"login":"soumith","id":1310570,"node_id":"MDQ6VXNlcjEzMTA1NzA=","avatar_url":"https://avatars0.githubusercontent.com/u/1310570?v=4","gravatar_id":"","url":"https://api.github.com/users/soumith","html_url":"https://github.com/soumith","followers_url":"https://api.github.com/users/soumith/followers","following_url":"https://api.github.com/users/soumith/following{/other_user}","gists_url":"https://api.github.com/users/soumith/gists{/gist_id}","starred_url":"https://api.github.com/users/soumith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soumith/subscriptions","organizations_url":"https://api.github.com/users/soumith/orgs","repos_url":"https://api.github.com/users/soumith/repos","events_url":"https://api.github.com/users/soumith/events{/privacy}","received_events_url":"https://api.github.com/users/soumith/received_events","type":"User","site_admin":false},"created_at":"2018-12-31T03:50:34Z","updated_at":"2018-12-31T03:50:34Z","author_association":"MEMBER","body":"yea, I agree, the wording there is a bit off.\r\nWould you mind sending a Pull Request improving the doc?"}}
{"actor":{"display_login":"soumith"}}