Repository navigation
Conversation
|
There's also something else going on, this fixes the out of bound reads but the reconstructed values still aren't quite right |
|
Should I review this or wait until the reconstructed values fix is also done? I think I wrote the stan repo code for this and can take a look there |
|
I'd wait, I think that |
|
The latest push is closer (Jonah's example gets the right thing now) but wrong still for the case where it's a |
|
Thanks for working on this. I guess it's not super urgent since nobody has hit it apparently, probably because an array of tuples of complex numbers is quite rare. I only found it because I was intentionally stress testing fixes to complex number and tuple handing in cmdstanr and giving it all the possible combinations Claude and I could come up with. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1734 +/- ##
=======================================
Coverage 92.36% 92.37%
=======================================
Files 70 70
Lines 10545 10552 +7
=======================================
+ Hits 9740 9747 +7
Misses 805 805
🚀 New features to boost your workflow:
|
|
Looking at the code here that seems wild both in complexity and readability. I wonder if in the stan repo we can write a |
|
I have a change I didn’t push that I think fixes everything and cleans stuff up, I need to test it when I’m back in a week. The generated code is a lot, but we’re also creating almost intentionally evil examples in the tests |
|
I have a branch here that has a |
|
I pushed my changes from before my week off but mostly for historical purposes, if we can use @SteveBronder's stan branch I think that would be universally better. I need to write some more test models a-la the one @jgabry prepared. We can then put those as 'gold' tests in performance-tests-cmdstan stan-dev/performance-tests-cmdstan#72 |
|
Should they be gold tests or should they be tests in the stan repo? |
|
If we put them in performance tests cmdstan we would catch if the code-gen here broke them, which is nice. But I guess if most of the code gen moves to templated functions in stan, then the tests would make sense there too |
|
I've started writing golds over at stan-dev/performance-tests-cmdstan#73 I think it's possible that we're also incorrectly handling 2-d arrays of tuples, though I'm having a hard time exactly wrapping my head around it |
|
@WardBrian I'm working on cleaning up the context reader branch and am going to open that today. The API right now would look like the following the following in the generated stanc code std::vector<...> user_data = // fill in data structure with NA values
validate_dims(...);
read_from_context(user_data, ctx, "user_data");Internally the code detects tuples in |
|
filling with NAs isn't too bad on the compiler side, anyway. I think this branch and the tests added in performance-tests are correct now, so if we can replace it with something simpler while keeping those passing I'm all for it. |
I'll add this to the stan PR |
|
It's possible the bug was codegen-only, in which case the Stan PR may naturally do the right thing https://github.com/stan-dev/performance-tests-cmdstan/blob/compiler-stress-tests/compiler-stress-models/onepl.stan is a really simple test model. If you provide this data file, the output should be 1 through 12 in order, but current stanc flips some of the |
|
Closing in favor of #1742 |
Closes stan-dev/stan#3437.
The logic to read in arrays-of-tuples from a var_context is quite complex, and the current code missed the subtlety that var context already merges complex numbers for us, so it was treating them as being offset-2 apart in the buffer rather than side by side.
Our existing
test/integration/good/tuples/arrays-tuples-nested.stantest actually contained this bug, but it is only visible at runtime and that model is never actually instantiated with data in our tests.Submission Checklist
Release notes
Fixed an issue compiling data blocks with
arrays containingtuples containingcomplexnumbers, which would lead to mangled numbers or crashes.Copyright and Licensing
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)