add grad method to gpu_contiguous