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

Adds extra var matrix block methods #2188

Merged
merged 13 commits into from
Nov 18, 2020
Merged

Conversation

SteveBronder
Copy link
Collaborator

Summary

This adds a few things I need in var<matrix> and some type traits for checking the inner types of var<Eigen> types.

Essentially with these specialized block member functions I can reuse a whole bunch of the code I just wrote for rvalue() and assign() which is nice!

Tests

Tests added for checking new block member functions propogate adjoints correctly and slice values correctly. Added simple tests for the type traits

Side Effects

Nope!

Release notes

Add more methods for taking blocks of var matrices.

Checklist

  • Math issue How to add static matrix? #1805

  • Copyright holder: (fill in copyright holder information)

    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

Copy link
Member

@bbbales2 bbbales2 left a comment

Choose a reason for hiding this comment

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

Review

stan/math/prim/meta/is_var_dense_dynamic.hpp Outdated Show resolved Hide resolved
stan/math/rev/fun/fill.hpp Outdated Show resolved Hide resolved
});
} else {
reverse_pass_callback(
[x, y, prev_vals]() mutable { x.vi_->val_ = prev_vals; });
Copy link
Member

Choose a reason for hiding this comment

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

Add x.adj().setZero(); if you decide it's important to keep the is_nan branch here. The previous entries of x should be unaffected by the NaN-ness of whatever replaces it.

@SteveBronder
Copy link
Collaborator Author

I removed the nan check and just wrote a separate function the compiler can use

Copy link
Member

@bbbales2 bbbales2 left a comment

Choose a reason for hiding this comment

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

One change. Looks good.

stan/math/rev/fun/initialize_fill.hpp Outdated Show resolved Hide resolved
@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 3.02 3.64 0.83 -20.69% slower
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 1.02 2.16% faster
eight_schools/eight_schools.stan 0.12 0.12 0.96 -4.04% slower
gp_regr/gp_regr.stan 0.17 0.17 1.0 -0.05% slower
irt_2pl/irt_2pl.stan 5.7 5.78 0.99 -1.3% slower
performance.compilation 86.51 85.59 1.01 1.06% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 8.47 8.65 0.98 -2.15% slower
pkpd/one_comp_mm_elim_abs.stan 29.8 29.44 1.01 1.22% faster
sir/sir.stan 136.84 133.4 1.03 2.52% faster
gp_regr/gen_gp_data.stan 0.04 0.04 0.98 -2.01% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.96 3.0 0.98 -1.62% slower
pkpd/sim_one_comp_mm_elim_abs.stan 0.38 0.38 1.01 0.5% faster
arK/arK.stan 1.77 1.8 0.99 -1.15% slower
arma/arma.stan 0.6 0.6 1.0 0.01% faster
garch/garch.stan 0.74 0.59 1.26 20.5% faster
Mean result: 1.00280885786

Jenkins Console Log
Blue Ocean
Commit hash: 3971748


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 d6b2997 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.

4 participants