{"action":"created","issue":{"url":"https://api.github.com/repos/Lasagne/Lasagne/issues/394","labels_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/394/labels{/name}","comments_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/394/comments","events_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/394/events","html_url":"https://github.com/Lasagne/Lasagne/pull/394","id":102849036,"number":394,"title":"Optimize TransformerLayer","user":{"login":"f0k","id":629706,"avatar_url":"https://avatars.githubusercontent.com/u/629706?v=3","gravatar_id":"","url":"https://api.github.com/users/f0k","html_url":"https://github.com/f0k","followers_url":"https://api.github.com/users/f0k/followers","following_url":"https://api.github.com/users/f0k/following{/other_user}","gists_url":"https://api.github.com/users/f0k/gists{/gist_id}","starred_url":"https://api.github.com/users/f0k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f0k/subscriptions","organizations_url":"https://api.github.com/users/f0k/orgs","repos_url":"https://api.github.com/users/f0k/repos","events_url":"https://api.github.com/users/f0k/events{/privacy}","received_events_url":"https://api.github.com/users/f0k/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-08-24T17:31:19Z","updated_at":"2015-08-25T14:48:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Lasagne/Lasagne/pulls/394","html_url":"https://github.com/Lasagne/Lasagne/pull/394","diff_url":"https://github.com/Lasagne/Lasagne/pull/394.diff","patch_url":"https://github.com/Lasagne/Lasagne/pull/394.patch"},"body":"This PR does a few things to the spatial transform layer:\r\n\r\n* For consistency, it renames the `input` constructor argument to `incoming` and adapts the docstring accordingly\r\n* Also for consistency, it changes the exception messages a little\r\n* It drops the `deterministic=False` keyword argument from `get_output_for`, it was never used\r\n* It allows `downscale_factor` to be a two-element tuple and adapts the docstring and tests accordingly\r\n* If the image size is known at compile time, it constructs the meshgrid offline instead of doing it symbolically\r\n* Shape and coordinate casting is done in a better order to avoid needless device/host transfers\r\n* The custom `_repeat` function is replaced by `T.repeat`\r\n\r\nUnluckily, speed improvements were minuscule. I've got something between 1% and 4% both for the forward and backward pass, mostly because of reordering the casts. Offline computation of the meshgrid hardly changes anything (but it definitely didn't get slower). If the batch size is known at compile time, the `base` index array in `_interpolate` could be precomputed as well, but that seemed to be a less common case than a fixed image size, so I didn't try that. After all, a more promising approach would be turning this into a custom kernel, possibly using `tex2D`, but then we'd also need to do a gradient Op and CPU Ops and a graph optimizer."},"comment":{"url":"https://api.github.com/repos/Lasagne/Lasagne/issues/comments/134610557","html_url":"https://github.com/Lasagne/Lasagne/pull/394#issuecomment-134610557","issue_url":"https://api.github.com/repos/Lasagne/Lasagne/issues/394","id":134610557,"user":{"login":"f0k","id":629706,"avatar_url":"https://avatars.githubusercontent.com/u/629706?v=3","gravatar_id":"","url":"https://api.github.com/users/f0k","html_url":"https://github.com/f0k","followers_url":"https://api.github.com/users/f0k/followers","following_url":"https://api.github.com/users/f0k/following{/other_user}","gists_url":"https://api.github.com/users/f0k/gists{/gist_id}","starred_url":"https://api.github.com/users/f0k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f0k/subscriptions","organizations_url":"https://api.github.com/users/f0k/orgs","repos_url":"https://api.github.com/users/f0k/repos","events_url":"https://api.github.com/users/f0k/events{/privacy}","received_events_url":"https://api.github.com/users/f0k/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T14:48:15Z","updated_at":"2015-08-25T14:48:15Z","body":"> Do you know what caused the speedup then?\r\n\r\nThe cast and the `_repeat`, I guess. The latter was causing a CPU `dot`. I didn't time the steps separately on the K40, only on the GT640, where each brought a minor improvement only."}}