-
Notifications
You must be signed in to change notification settings - Fork 26
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
Rowwise/Colwise Framework #35
Conversation
Interesting Idea. I have a few questions.
|
Nice. I am guessing this could then also be parallelized with TBB and thus be a replacement of |
As in the Stan syntax would be:
That was my idea, but to be perfectly honest I couldn't figure out a way to do it. The
Unfortunately not yet, since there's still the same issues with parallel reverse mode which would need to be figured out first |
I am pretty sure it does not. It was meant more like could we add support for that - I think the Math functions would just need to get wrapped into functors. Althought that question is probably more for @rok-cesnovar.
I guess we would need to add support for |
Indeed. Its not supported right now, but I think generating functors for any math function used in such cowwise/rowwise should not be a big deal if this is something we think would be beneficial.
Ok, thanks. This is great even without that. |
Well, something that could get in the way of that, and possibly the framework in general, is that the location of the functor isn't fixed between calls. In other words, the functor could be the second argument:
Or the third (or Nth):
Is this likely to be problematic with Stanc3? Are the signatures fine to just be:
|
No, I dont think that is a problem Stanc3 wise. It will require some additional logic for semantic checking that the types match, but right now I dont see it that being a problem if the C++ side of this is handled as you propose. In a chat with @spinkney he pointed out that |
Oh I hadn't thought about ragged arrays, not too familiar with that side of things. I'll take your word for it! |
If we had a tuple type in the language (Not sure about the status of that) we could have something like
Then we wouldn't have to worry about that. One thing we could do for a simpler first impl is just support unary functions to iterate over matrices |
That is a very good point! Tuples make this much easier to do. @rybern any status updates on tuples in stanc3? I believe its stan-dev/stanc3#670 first then stan-dev/stanc3#675 |
Update is that I finally have some time again! My goal for this week is getting it to a point where I can rope in some other contributors. |
Oh yeah tuples would majorly simplify this, both on the Stan and C++ side of things. Great news Ryan!! |
Just revisiting this project now, is it worth waiting for tuples in the language or should I go ahead with the spec as-is? For simplicity, I could just implement the variadic case now, and then add a signature for tuples later when they're available |
Let me see if we can get a better eyeball on tuples this week. Right now we are waiting on stan-dev/stan#3036 but after that we should have a better ballpark on time. One quick thing about the current impl, idt it would work if someone passed a tuple? Though don't think it would require a bit change template <typename T>
using is_stan_type = disjunction<is_stan_scalar<T>, is_container<T>>; I think we need something for type detection there that is more than detecting what it's not. Though I'm not sure if there is some type trait you can use to detect a lambda or functor |
Great! Happy to wait, just wanted to get a better idea on the timeline. Yeah I went down a bit of a rabbithole but I couldn't find a reliable type trait for detecting both lambdas and functors, so I had to settle on the |
This design document outlines a proposed
rowwise
andcolwise
frameworks, allowing users to specify custom row- and column-wise functions in Stan. The frameworks allow for a variadic number of iterated and shared arguments.Rendered markdown is here
Relevant Math branch is here