Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added var<mat> implementations of columns_dot_product and rows_dot_product #2199

Merged
merged 3 commits into from
Nov 18, 2020

Conversation

bbbales2
Copy link
Member

Summary

Added var<mat> versions of columns_dot_product and rows_dot_product

Release notes

Added var<mat> versions of columns_dot_product and rows_dot_product

Checklist

  • Math issue Make functions with custom autodiff var<mat> friendly #2101

  • Copyright holder: Columbia University

    The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
    - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
    - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • the basic tests are passing

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

@bbbales2
Copy link
Member Author

@SteveBronder this passed unit tests. I think the failure is part of: #2200, so ready to review

SteveBronder
SteveBronder previously approved these changes Nov 17, 2020
Copy link
Collaborator

@SteveBronder SteveBronder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two suggestions but looks good!

Comment on lines 79 to 88
if (is_var_matrix<Mat1>::value) {
arena_v1.adj().noalias() += value_of(arena_v2) * res.adj().asDiagonal();
} else {
arena_v1.adj() += value_of(arena_v2) * res.adj().asDiagonal();
}
if (is_var_matrix<Mat2>::value) {
arena_v2.adj().noalias() += value_of(arena_v1) * res.adj().asDiagonal();
} else {
arena_v2.adj() += value_of(arena_v1) * res.adj().asDiagonal();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they are all var types at this point you can use .val() directly

Comment on lines +99 to +103
if (is_var_matrix<Mat2>::value) {
arena_v2.adj().noalias() += arena_v1 * res.adj().asDiagonal();
} else {
arena_v2.adj() += arena_v1 * res.adj().asDiagonal();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the more I stare at this the more I think it would be better to have an update_adjoint() function so we don't have these ifs everywhere

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I saw the @t4c1 thumbs up on the other pull too. I'm happy with update_adjoint. Let's do that in a separate pull to keep the scope limited here

@bbbales2
Copy link
Member Author

Switched the value_of s for .vals , so this should be ready for checking off again and merging if the tests pass

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 3.05 3.54 0.86 -15.9% slower
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 1.07 6.33% faster
eight_schools/eight_schools.stan 0.12 0.11 1.03 2.82% faster
gp_regr/gp_regr.stan 0.17 0.16 1.01 1.27% faster
irt_2pl/irt_2pl.stan 5.69 5.74 0.99 -0.89% slower
performance.compilation 86.49 85.65 1.01 0.98% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 8.48 8.48 1.0 -0.08% slower
pkpd/one_comp_mm_elim_abs.stan 29.15 31.01 0.94 -6.37% slower
sir/sir.stan 134.95 133.15 1.01 1.33% faster
gp_regr/gen_gp_data.stan 0.05 0.04 1.02 2.18% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.96 2.98 0.99 -0.66% slower
pkpd/sim_one_comp_mm_elim_abs.stan 0.4 0.38 1.07 6.17% faster
arK/arK.stan 1.79 1.79 1.0 -0.25% slower
arma/arma.stan 0.6 0.6 1.01 0.5% faster
garch/garch.stan 0.74 0.6 1.23 18.61% faster
Mean result: 1.01592746123

Jenkins Console Log
Blue Ocean
Commit hash: f057b30


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

@bbbales2 bbbales2 merged commit e1e7797 into develop Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants