-
Notifications
You must be signed in to change notification settings - Fork 3
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
optimize works unexpectedly on release build (a possible solution included) #19
Comments
Hi @aferust could you please check the code works for you if only |
No. Indeed, it is "work" that matters in terms of initialization; on the other hand, it has no effect if I initialize "iwork" or not in my case. |
The bug is critical. It is very interesting. There is definitely a bug. However, we can't just initialize work to 0 because it wouldn't fix the bug itself. The bug can be in Mir or in LAPACK implementation you are using. If I initialize Could you please transform your code to a unittest that fails on you machine? This way I could find the bug. |
Dear Ilya, I have tested the below code from your unittest (with an extra writeln) on some environments, using LDC for each setting
my ubuntu mate os (sudo apt install libopenblas-dev) release: my windows test uses Intel-MKL and the same problem persists for release builds. In your tests, you always assign y[0] = x[0]; and probably you don't get nan values with y. We print y here before it is changed. I can also use a dummy variable for x[0], but this is not what we want, right? import std.stdio;
import mir.optim.least_squares;
void main()
{
import mir.ndslice.allocation: slice;
import mir.ndslice.slice: sliced;
import mir.blas: nrm2;
LeastSquaresSettings!double settings;
auto x = [100.0, 100].sliced;
auto l = x.shape.slice(-double.infinity);
auto u = x.shape.slice(+double.infinity);
optimize!(
(x, y)
{
writeln(y); /////// check nans here
y[0] = x[0];
y[1] = 2 - x[1];
},
(x, J)
{
J[0, 0] = 1;
J[0, 1] = 0;
J[1, 0] = 0;
J[1, 1] = -1;
},
)(settings, 2, x, l, u);
assert(nrm2((x - [0, 2].sliced).slice) < 1e-8);
} |
Thank you for the example. I will submit this feature soon. |
I wanted to figure out why my code works weirdly on release. I found that the residual delegate "y" always initializes with nan values. Then, I took a look at the code to detect this line. When I removed the debug guard, things worked as expected.
mir-optim/source/mir/optim/least_squares.d
Line 903 in b9b9fa2
The text was updated successfully, but these errors were encountered: