{"action":"created","comment":{"url":"https://api.github.com/repos/stan-dev/math/pulls/comments/205421847","pull_request_review_id":140682931,"id":205421847,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTQyMTg0Nw==","diff_hunk":"@@ -0,0 +1,121 @@\n+#ifndef STAN_MATH_REV_MAT_FUN_ADJ_JAC_APPLY_HPP\n+#define STAN_MATH_REV_MAT_FUN_ADJ_JAC_APPLY_HPP\n+\n+#include <stan/math/prim/mat/fun/Eigen.hpp>\n+#include <stan/math/prim/mat.hpp>\n+#include <stan/math/rev/core.hpp>\n+#include <vector>\n+\n+namespace stan {\n+namespace math {\n+\n+/*\n+ * The adjoint Jacobian vari is a special vari for wrapping up user defined ops\n+ * that supply an apply operation (that performs an operation on some input) and\n+ * a multiply_adjoint_jacobian call (that computes the result of the product of\n+ * the transpose of the adjoint times the Jacobian of the operator).\n+ *\n+ * The adjoint Jacobian vari itself does nothing other than connect the supplied\n+ * operation to the autodiff stack and coordinate movement of data between all\n+ * the involved varis so that someone can implement autodiff functions without\n+ * ever having to deal with autodiff types.\n+ */\n+template <typename F>\n+struct adj_jac_vari : public vari {\n+  F f_;\n+  int N_;\n+  vari** x_vi_;\n+  int M_;\n+  vari** y_vi_;\n+\n+  explicit adj_jac_vari(const Eigen::Matrix<var, Eigen::Dynamic, 1>& x)\n+      : vari(0),  // The val_ in this vari is unused\n+        N_(x.size()),\n+        x_vi_(build_vari_array(x)),\n+        M_(0),\n+        y_vi_(NULL) {\n+    Eigen::Matrix<double, Eigen::Dynamic, 1> val_y = f_(value_of(x));","path":"stan/math/rev/mat/fun/adj_jac_apply.hpp","position":47,"original_position":37,"commit_id":"8d8e34bb4d5ec92a280ac2ce21c18dbd05d7e40a","original_commit_id":"6ae639991d72a380d8b60f237250e625d77302f2","user":{"login":"bob-carpenter","id":3383807,"node_id":"MDQ6VXNlcjMzODM4MDc=","avatar_url":"https://avatars1.githubusercontent.com/u/3383807?v=4","gravatar_id":"","url":"https://api.github.com/users/bob-carpenter","html_url":"https://github.com/bob-carpenter","followers_url":"https://api.github.com/users/bob-carpenter/followers","following_url":"https://api.github.com/users/bob-carpenter/following{/other_user}","gists_url":"https://api.github.com/users/bob-carpenter/gists{/gist_id}","starred_url":"https://api.github.com/users/bob-carpenter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bob-carpenter/subscriptions","organizations_url":"https://api.github.com/users/bob-carpenter/orgs","repos_url":"https://api.github.com/users/bob-carpenter/repos","events_url":"https://api.github.com/users/bob-carpenter/events{/privacy}","received_events_url":"https://api.github.com/users/bob-carpenter/received_events","type":"User","site_admin":false},"body":"See above---I just rewrote the constructor.","created_at":"2018-07-26T11:29:28Z","updated_at":"2018-07-26T11:32:10Z","html_url":"https://github.com/stan-dev/math/pull/924#discussion_r205421847","pull_request_url":"https://api.github.com/repos/stan-dev/math/pulls/924","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/stan-dev/math/pulls/comments/205421847"},"html":{"href":"https://github.com/stan-dev/math/pull/924#discussion_r205421847"},"pull_request":{"href":"https://api.github.com/repos/stan-dev/math/pulls/924"}},"in_reply_to_id":203561827},"pull_request":{"url":"https://api.github.com/repos/stan-dev/math/pulls/924","id":198404208,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4NDA0MjA4","html_url":"https://github.com/stan-dev/math/pull/924","diff_url":"https://github.com/stan-dev/math/pull/924.diff","patch_url":"https://github.com/stan-dev/math/pull/924.patch","issue_url":"https://api.github.com/repos/stan-dev/math/issues/924","number":924,"state":"open","locked":false,"title":"adjoint-vector product, #876","user":{"login":"bbbales2","id":4742424,"node_id":"MDQ6VXNlcjQ3NDI0MjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4742424?v=4","gravatar_id":"","url":"https://api.github.com/users/bbbales2","html_url":"https://github.com/bbbales2","followers_url":"https://api.github.com/users/bbbales2/followers","following_url":"https://api.github.com/users/bbbales2/following{/other_user}","gists_url":"https://api.github.com/users/bbbales2/gists{/gist_id}","starred_url":"https://api.github.com/users/bbbales2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbbales2/subscriptions","organizations_url":"https://api.github.com/users/bbbales2/orgs","repos_url":"https://api.github.com/users/bbbales2/repos","events_url":"https://api.github.com/users/bbbales2/events{/privacy}","received_events_url":"https://api.github.com/users/bbbales2/received_events","type":"User","site_admin":false},"body":"#### Submission Checklist\r\n\r\n- [ ] Run unit tests: `./runTests.py test/unit`\r\n- [ ] Run cpplint: `make cpplint`\r\n- [x] Declare copyright holder and open-source license: see below\r\n\r\n#### Summary:\r\n\r\nThis is my initial attempt at getting https://github.com/stan-dev/math/issues/876 coded up. ~~No tests yet. Work in progress, don't merge.~~ Tests are here!\r\n\r\n#### Intended Effect:\r\n\r\nUse the new features to make softmax better\r\n\r\nThe goal of issue 876 is to allow people to add functions that are compatible with reverse mode autodiff without actually having to dig into the Stan implementation of reverse mode autodiff\r\n\r\n#### How to Verify:\r\n\r\n./runTests.py test/unit/math/rev/mat/fun/softmax_test\r\n\r\n#### Side Effects:\r\n\r\n~~This weird test breaks: https://github.com/stan-dev/math/blob/e7c695c8e085c0c5d2bfc0cf2983dc62bb2cf398/test/unit/math/rev/mat/fun/softmax_test.cpp#L8, but it's a self-proclaimed weird and brittle test. Still makes me nervous.~~ We're getting rid of this test (https://github.com/stan-dev/math/pull/924#issuecomment-402292761)\r\n\r\n#### Documentation:\r\n\r\nDoxygen!\r\n\r\n#### Copyright and Licensing\r\n\r\nPlease list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Columbia University\r\n\r\nBy submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:\r\n- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)\r\n- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)\r\n","created_at":"2018-06-29T19:27:18Z","updated_at":"2018-07-26T11:32:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2e0ec9108b45ccbc9141337f1c465d7ce7bbbdb1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stan-dev/math/pulls/924/commits","review_comments_url":"https://api.github.com/repos/stan-dev/math/pulls/924/comments","review_comment_url":"https://api.github.com/repos/stan-dev/math/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stan-dev/math/issues/924/comments","statuses_url":"https://api.github.com/repos/stan-dev/math/statuses/8d8e34bb4d5ec92a280ac2ce21c18dbd05d7e40a","head":{"label":"stan-dev:feature/issue-876-adj-jac","ref":"feature/issue-876-adj-jac","sha":"8d8e34bb4d5ec92a280ac2ce21c18dbd05d7e40a","user":{"login":"stan-dev","id":3374820,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzNzQ4MjA=","avatar_url":"https://avatars2.githubusercontent.com/u/3374820?v=4","gravatar_id":"","url":"https://api.github.com/users/stan-dev","html_url":"https://github.com/stan-dev","followers_url":"https://api.github.com/users/stan-dev/followers","following_url":"https://api.github.com/users/stan-dev/following{/other_user}","gists_url":"https://api.github.com/users/stan-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/stan-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stan-dev/subscriptions","organizations_url":"https://api.github.com/users/stan-dev/orgs","repos_url":"https://api.github.com/users/stan-dev/repos","events_url":"https://api.github.com/users/stan-dev/events{/privacy}","received_events_url":"https://api.github.com/users/stan-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":38388440,"node_id":"MDEwOlJlcG9zaXRvcnkzODM4ODQ0MA==","name":"math","full_name":"stan-dev/math","owner":{"login":"stan-dev","id":3374820,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzNzQ4MjA=","avatar_url":"https://avatars2.githubusercontent.com/u/3374820?v=4","gravatar_id":"","url":"https://api.github.com/users/stan-dev","html_url":"https://github.com/stan-dev","followers_url":"https://api.github.com/users/stan-dev/followers","following_url":"https://api.github.com/users/stan-dev/following{/other_user}","gists_url":"https://api.github.com/users/stan-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/stan-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stan-dev/subscriptions","organizations_url":"https://api.github.com/users/stan-dev/orgs","repos_url":"https://api.github.com/users/stan-dev/repos","events_url":"https://api.github.com/users/stan-dev/events{/privacy}","received_events_url":"https://api.github.com/users/stan-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stan-dev/math","description":"Stan Math Library","fork":false,"url":"https://api.github.com/repos/stan-dev/math","forks_url":"https://api.github.com/repos/stan-dev/math/forks","keys_url":"https://api.github.com/repos/stan-dev/math/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stan-dev/math/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stan-dev/math/teams","hooks_url":"https://api.github.com/repos/stan-dev/math/hooks","issue_events_url":"https://api.github.com/repos/stan-dev/math/issues/events{/number}","events_url":"https://api.github.com/repos/stan-dev/math/events","assignees_url":"https://api.github.com/repos/stan-dev/math/assignees{/user}","branches_url":"https://api.github.com/repos/stan-dev/math/branches{/branch}","tags_url":"https://api.github.com/repos/stan-dev/math/tags","blobs_url":"https://api.github.com/repos/stan-dev/math/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stan-dev/math/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stan-dev/math/git/refs{/sha}","trees_url":"https://api.github.com/repos/stan-dev/math/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stan-dev/math/statuses/{sha}","languages_url":"https://api.github.com/repos/stan-dev/math/languages","stargazers_url":"https://api.github.com/repos/stan-dev/math/stargazers","contributors_url":"https://api.github.com/repos/stan-dev/math/contributors","subscribers_url":"https://api.github.com/repos/stan-dev/math/subscribers","subscription_url":"https://api.github.com/repos/stan-dev/math/subscription","commits_url":"https://api.github.com/repos/stan-dev/math/commits{/sha}","git_commits_url":"https://api.github.com/repos/stan-dev/math/git/commits{/sha}","comments_url":"https://api.github.com/repos/stan-dev/math/comments{/number}","issue_comment_url":"https://api.github.com/repos/stan-dev/math/issues/comments{/number}","contents_url":"https://api.github.com/repos/stan-dev/math/contents/{+path}","compare_url":"https://api.github.com/repos/stan-dev/math/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stan-dev/math/merges","archive_url":"https://api.github.com/repos/stan-dev/math/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stan-dev/math/downloads","issues_url":"https://api.github.com/repos/stan-dev/math/issues{/number}","pulls_url":"https://api.github.com/repos/stan-dev/math/pulls{/number}","milestones_url":"https://api.github.com/repos/stan-dev/math/milestones{/number}","notifications_url":"https://api.github.com/repos/stan-dev/math/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stan-dev/math/labels{/name}","releases_url":"https://api.github.com/repos/stan-dev/math/releases{/id}","deployments_url":"https://api.github.com/repos/stan-dev/math/deployments","created_at":"2015-07-01T18:40:54Z","updated_at":"2018-07-26T01:54:02Z","pushed_at":"2018-07-26T09:01:49Z","git_url":"git://github.com/stan-dev/math.git","ssh_url":"git@github.com:stan-dev/math.git","clone_url":"https://github.com/stan-dev/math.git","svn_url":"https://github.com/stan-dev/math","homepage":null,"size":261410,"stargazers_count":212,"watchers_count":212,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":74,"mirror_url":null,"archived":false,"open_issues_count":189,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":74,"open_issues":189,"watchers":212,"default_branch":"develop"}},"base":{"label":"stan-dev:develop","ref":"develop","sha":"0d558cc87eb74b6aa0453dd91b699403ee067a55","user":{"login":"stan-dev","id":3374820,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzNzQ4MjA=","avatar_url":"https://avatars2.githubusercontent.com/u/3374820?v=4","gravatar_id":"","url":"https://api.github.com/users/stan-dev","html_url":"https://github.com/stan-dev","followers_url":"https://api.github.com/users/stan-dev/followers","following_url":"https://api.github.com/users/stan-dev/following{/other_user}","gists_url":"https://api.github.com/users/stan-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/stan-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stan-dev/subscriptions","organizations_url":"https://api.github.com/users/stan-dev/orgs","repos_url":"https://api.github.com/users/stan-dev/repos","events_url":"https://api.github.com/users/stan-dev/events{/privacy}","received_events_url":"https://api.github.com/users/stan-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":38388440,"node_id":"MDEwOlJlcG9zaXRvcnkzODM4ODQ0MA==","name":"math","full_name":"stan-dev/math","owner":{"login":"stan-dev","id":3374820,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzNzQ4MjA=","avatar_url":"https://avatars2.githubusercontent.com/u/3374820?v=4","gravatar_id":"","url":"https://api.github.com/users/stan-dev","html_url":"https://github.com/stan-dev","followers_url":"https://api.github.com/users/stan-dev/followers","following_url":"https://api.github.com/users/stan-dev/following{/other_user}","gists_url":"https://api.github.com/users/stan-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/stan-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stan-dev/subscriptions","organizations_url":"https://api.github.com/users/stan-dev/orgs","repos_url":"https://api.github.com/users/stan-dev/repos","events_url":"https://api.github.com/users/stan-dev/events{/privacy}","received_events_url":"https://api.github.com/users/stan-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stan-dev/math","description":"Stan Math Library","fork":false,"url":"https://api.github.com/repos/stan-dev/math","forks_url":"https://api.github.com/repos/stan-dev/math/forks","keys_url":"https://api.github.com/repos/stan-dev/math/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stan-dev/math/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stan-dev/math/teams","hooks_url":"https://api.github.com/repos/stan-dev/math/hooks","issue_events_url":"https://api.github.com/repos/stan-dev/math/issues/events{/number}","events_url":"https://api.github.com/repos/stan-dev/math/events","assignees_url":"https://api.github.com/repos/stan-dev/math/assignees{/user}","branches_url":"https://api.github.com/repos/stan-dev/math/branches{/branch}","tags_url":"https://api.github.com/repos/stan-dev/math/tags","blobs_url":"https://api.github.com/repos/stan-dev/math/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stan-dev/math/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stan-dev/math/git/refs{/sha}","trees_url":"https://api.github.com/repos/stan-dev/math/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stan-dev/math/statuses/{sha}","languages_url":"https://api.github.com/repos/stan-dev/math/languages","stargazers_url":"https://api.github.com/repos/stan-dev/math/stargazers","contributors_url":"https://api.github.com/repos/stan-dev/math/contributors","subscribers_url":"https://api.github.com/repos/stan-dev/math/subscribers","subscription_url":"https://api.github.com/repos/stan-dev/math/subscription","commits_url":"https://api.github.com/repos/stan-dev/math/commits{/sha}","git_commits_url":"https://api.github.com/repos/stan-dev/math/git/commits{/sha}","comments_url":"https://api.github.com/repos/stan-dev/math/comments{/number}","issue_comment_url":"https://api.github.com/repos/stan-dev/math/issues/comments{/number}","contents_url":"https://api.github.com/repos/stan-dev/math/contents/{+path}","compare_url":"https://api.github.com/repos/stan-dev/math/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stan-dev/math/merges","archive_url":"https://api.github.com/repos/stan-dev/math/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stan-dev/math/downloads","issues_url":"https://api.github.com/repos/stan-dev/math/issues{/number}","pulls_url":"https://api.github.com/repos/stan-dev/math/pulls{/number}","milestones_url":"https://api.github.com/repos/stan-dev/math/milestones{/number}","notifications_url":"https://api.github.com/repos/stan-dev/math/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stan-dev/math/labels{/name}","releases_url":"https://api.github.com/repos/stan-dev/math/releases{/id}","deployments_url":"https://api.github.com/repos/stan-dev/math/deployments","created_at":"2015-07-01T18:40:54Z","updated_at":"2018-07-26T01:54:02Z","pushed_at":"2018-07-26T09:01:49Z","git_url":"git://github.com/stan-dev/math.git","ssh_url":"git@github.com:stan-dev/math.git","clone_url":"https://github.com/stan-dev/math.git","svn_url":"https://github.com/stan-dev/math","homepage":null,"size":261410,"stargazers_count":212,"watchers_count":212,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":74,"mirror_url":null,"archived":false,"open_issues_count":189,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":74,"open_issues":189,"watchers":212,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/stan-dev/math/pulls/924"},"html":{"href":"https://github.com/stan-dev/math/pull/924"},"issue":{"href":"https://api.github.com/repos/stan-dev/math/issues/924"},"comments":{"href":"https://api.github.com/repos/stan-dev/math/issues/924/comments"},"review_comments":{"href":"https://api.github.com/repos/stan-dev/math/pulls/924/comments"},"review_comment":{"href":"https://api.github.com/repos/stan-dev/math/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stan-dev/math/pulls/924/commits"},"statuses":{"href":"https://api.github.com/repos/stan-dev/math/statuses/8d8e34bb4d5ec92a280ac2ce21c18dbd05d7e40a"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"bob-carpenter"}}