         up += ncols_u;
         cp += ncols;
         hp += ncols;
-        if (skip_type) xp += ncols_x;
-        if (pad_p) pad_p += batch;
+        xp = skip_type ? (xp + ncols_x) : NULL;
+        pad_p = mask_pad ? (pad_p + batch) : NULL;
     }
 }
 

        cp -= ncols;
        gup -= ncols_u;
        ghp -= ncols;
        if (skip_type) xp -= ncols_x;
        if (skip_type) gxp -= ncols_x;
        if (pad_p) pad_p -= batch;
    }

    //const int bias_idx = col % d;

    *(grad_wc + col + ncols) = gwc2;
    *(grad_bias + col) = gbias1;
    *(grad_bias + col + ncols) = gbias2;
    *(grad_init + col) = cur;
}

template <typename scalar_t>
