<div dir="ltr">Making the proposed changes let to a crash in fos_gradient.<br>In the assign_ind case the ADOLC_GET_TAYLOR call (which translates to get_tay_block_r) crashes because<br>fseek fails because ADOLC_CURRENT_TAPE_INFOS.tay_file is null...<br>
<br>
As on 2011-06-20 14:35, Noam Gat did write:<br>
> Hi,<br>
><br>
> I have a strange problem when using adol-c to create a gradient.<br>
> Before I try to prevent re-taping, I am currently retaping before each<br>
> gradient evaluation.<br>
><br>
> The general structure of the code is :<br>
><br>
// replace this<br>
> trace_on(0);<br>
// with<br>
trace_on(1,1)<br>
<br>
> for (int i=0; i<N; i++)<br>
> {<br>
> rawGradParams[i] <<= X[i];<br>
> }<br>
> adouble result = objective(rawGradParams);<br>
> double retVal;<br>
> result >>= retVal;<br>
<br>
// replace this<br>
> trace_off(0);<br>
// with<br>
trace_off();<br>
<br>
// replace this<br>
> int gradientRetVal = gradient(0,N,X,G);<br>
// with<br>
double one = 1;<br>
int retval = fos_reverse(1, 1, N, &one, G);<br>
<br>
You should get the gradient in G with this. This is using the taping<br>
process itself as the zero order forward call which is required before<br>
calling the first order reverse call to compute the gradient.<br>
<br>
If you want to prevent retaping you need to make totally sure that all<br>
your comparison statements always give the same result and all loops<br>
always run for the same number of iterations for every argument value.</div>