                 *gxp = gh_val*(1-g2);
 
             // gradient with respect to values in the second gate g2
-            auto gg2 = gh_val*(c_val*mask-x_val)*(g2*(1-g2));
+            const auto gg2 = gh_val*(c_val*mask-x_val)*(g2*(1-g2));
             *(gup+2) = gg2;
             gbias2 += gg2;
             gwc2 += gg2*prev_c_val;

        up += ncols_u;
        cp += ncols;
        hp += ncols;
        if (skip_type) xp += ncols_x;
        if (pad_p) pad_p += batch;
    }
}


    scalar_t gbias2 = 0;
    auto cur = *(grad_last + col);

    const auto* up = u + (col*k) + (len-1)*ncols_u;
    const auto* xp = (skip_type == 0) ? NULL : (
        (skip_type == 1) ? (x + col + (len-1)*ncols) : (up + 3)
    );
    const auto* cp = c + col + (len-1)*ncols;
    const auto* ghp = grad_h + col + (len-1)*ncols;
    const unsigned char* pad_p = (mask_pad == NULL) ? NULL : (mask_pad + (col/d) + (len-1)*batch);
    auto* gup = grad_u + (col*k) + (len-1)*ncols_u;
    auto* gxp = (skip_type == 0) ? NULL : (
        (skip_type == 1) ? (grad_x + col + (len-1)*ncols) : (gup + 3)
    );

