     handle.Call(cudnnGetRNNWorkspaceSize, rnn_desc, xs.size(), xs_desc, &workSize);
     cudaMalloc((void**)&workspace, workSize);
 
-    hx = hx.AsType(Dtype::kFloat32);
-    cx = cx.AsType(Dtype::kFloat32);
-    dhy = dhy.AsType(Dtype::kFloat32);
-    dcy = dcy.AsType(Dtype::kFloat32);
-
-    CudnnTensorDescriptor hx_desc{AsContiguous(hx)};
-    CudnnTensorDescriptor cx_desc{AsContiguous(cx)};
-    CudnnTensorDescriptor dhy_desc{AsContiguous(dhy)};
-    CudnnTensorDescriptor dcy_desc{AsContiguous(dcy)};
+    hx = AsContiguous(hx.AsType(Dtype::kFloat32));
+    cx = AsContiguous(cx.AsType(Dtype::kFloat32));
+    dhy = AsContiguous(dhy.AsType(Dtype::kFloat32));
+    dcy = AsContiguous(dcy.AsType(Dtype::kFloat32));
+
+    CudnnTensorDescriptor hx_desc{hx};
+    CudnnTensorDescriptor cx_desc{cx};
+    CudnnTensorDescriptor dhy_desc{dhy};
+    CudnnTensorDescriptor dcy_desc{dcy};
 
     Array dhx = Empty(hx.shape(), hx.dtype(), hx.device());
     CudnnTensorDescriptor dhx_desc{dhx};

        rnn_desc,
        xs.size(),
        x_desc,
        internal::GetRawOffsetData(AsContiguous(x)),
        *hxDesc,
        internal::GetRawOffsetData(AsContiguous(hx)),
        *cxDesc,
        internal::GetRawOffsetData(AsContiguous(cx)),
        *wDesc,
        internal::GetRawOffsetData(w),
        y_desc,

                    layer,
                    x_desc,
                    w_desc,
                    internal::GetRawOffsetData(w),
                    lin_layer_id,
                    linlayerbiasdesc,
                    (void**)&b_offset
