-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Feature/0464 refactor seqview #486
Conversation
The result of a day's pair programming with Bob. Next commit will replace usage.
Eventually the goal is to rewrite and replace all uses of VectorView with some form of seq_view.
f85a20a
to
ff4dda5
Compare
Is that |
Yeah, that was my intention; think someone told me to use [WIP] at one point. |
OK --- we can change that to a label at some point if we
get too many of these and need to sort. Let's hope it doesn't
come to that. Daniel's had some WIPs for a whole as issues.
Usually we kill them after a while pending completion
so our pull requests aren't cluttered.
- Bob
… On Feb 9, 2017, at 2:27 PM, seantalts ***@***.***> wrote:
Yeah, that was my intention; think someone told me to use [WIP] at one point.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yeah -- we shouldn't have too many of those.
The last pull request went from what I thought was complete to realizing it
wasn't; we can kill it and I can reopen later if that helps.
On Thu, Feb 9, 2017 at 2:40 PM, Bob Carpenter <notifications@github.com>
wrote:
… OK --- we can change that to a label at some point if we
get too many of these and need to sort. Let's hope it doesn't
come to that. Daniel's had some WIPs for a whole as issues.
Usually we kill them after a while pending completion
so our pull requests aren't cluttered.
- Bob
> On Feb 9, 2017, at 2:27 PM, seantalts ***@***.***> wrote:
>
> Yeah, that was my intention; think someone told me to use [WIP] at one
point.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub, or mute the thread.
>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#486 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAZ_F-lJc58H_vEkV6LJdFGjh_y3jOB-ks5ra2upgaJpZM4L8cYn>
.
|
@bob-carpenter Okay, tests pass and I'm marking this as non-WIP. I think it might be a good place to start with the refactor, keeping in mind your advice to keep pull requests as small as possible. Bob, since you and I paired on the design together do you think we should get a 3rd party to review it? And then whoever wants to can double check that I did the substitutions correctly... Actually maybe I should have just put up the design first and then done the replacements in a 2nd PR? What do you guys think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good; just needs documentation.
|
||
namespace stan { | ||
|
||
template <typename C, typename T = typename scalar_type<C>::type> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation for the class. See https://github.com/stan-dev/stan/wiki/How-to-Write-Doxygen-Doc-Comments
const C& c_; | ||
}; | ||
|
||
template <typename T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add doc describing what this specialization is.
#include <stan/math/prim/scal/meta/scalar_seq_view.hpp> | ||
|
||
namespace stan { | ||
template <typename T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add doc about the template specialization.
} | ||
|
||
TEST(MetaTraits, ScalarSeqViewMatrix) { | ||
expect_scalar_seq_view_values(Eigen::VectorXd(4)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you're bored, you can look at scoped traces in Google Test to give context when this fails. No need to take action, but it is a useful feature of Google Test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, sounds cool! Will check it out, thanks.
bool b3 = is_same<double, scalar_type<Matrix<double, Dynamic, Dynamic> >::type>::value; | ||
EXPECT_TRUE(b3); | ||
// TODO(Sean): This behavior doesn't seem to make sense prima facie | ||
// Likely change this so that we would expect `double` here instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just commenting; I think scalar_type
just unwraps one layer. I think there's a recursive version kicking around. But either way, this is improperly named.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears to be recursive on std::vector
but not Matrix
🌝
* @param i index | ||
* @return the element at the specified position in the container | ||
*/ | ||
const T& operator[](int i) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you guys think about these operator[]
s being inlined? I'm still getting a feel for where that's appropriate.
jenkins, retest this please |
We're not that worried about size. Yes, they should probably be inline. There's two aspects of inline---the compiler hint and the translation unit duplication feature. Member functions automatically get the latter. See this:
http://stackoverflow.com/questions/26241023/different-implementations-of-inline-functions-in-different-translation-units
|
Re: inline - I just looked into it a little more, and some stuff suggests that all member functions declared inside a class are implicitly inline and that marking it as inline does nothing? http://stackoverflow.com/questions/9370493/inline-function-members-inside-a-class |
Correct, that’s what I was trying to yell in the background.
… On Feb 10, 2017, at 2:43 PM, seantalts ***@***.***> wrote:
Re: inline - I just looked into it a little more, and some stuff suggests that all member functions declared inside a class are implicitly inline and that marking it as inline does nothing? http://stackoverflow.com/questions/9370493/inline-function-members-inside-a-class <http://stackoverflow.com/questions/9370493/inline-function-members-inside-a-class>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#486 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABdNlunAIfCphazpz8ie0-SnuAW6t7fjks5rbL3JgaJpZM4L8cYn>.
|
Schwoops. Well, I'll leave them unmarked then. |
Yes, member functions are automatically inline in the sense that you
can use the definition in multiple translation units.
But what I was trying to say is that I'm not sure if that implies
they are also inline in the nudge the compiler into unfolding sense.
- Bob
… On Feb 10, 2017, at 2:43 PM, seantalts ***@***.***> wrote:
Re: inline - I just looked into it a little more, and some stuff suggests that all member functions declared inside a class are implicitly inline and that marking it as inline does nothing? http://stackoverflow.com/questions/9370493/inline-function-members-inside-a-class
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Bob, gotcha. I think from what I was reading on that SO link that literally nothing changes in the compiler if you mark a member function inline, though it's hard to imagine that being perfectly consistent across all compilers... Daniel, I added doc if you want to take a quick look whenever you have a chance and see if it looks good now? Thanks! |
Looks good to me. Just approved. |
Submisison Checklist
./runTests.py test/unit
make cpplint
Summary:
Refactor most common use case of VectorView (taking either a primitive or a sequence of primitives and treating it seamlessly as a sequence of primitives) into scalar_seq_view, which is much simpler.
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Dual Space LLC
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: