     const half *input1_data = static_cast<const half *>(qk_bias);
     // BxSx3xNxH => tptr: 3xBxNxSxH.
     if (need_padding) {
-      dim3 grid_p(seq_len, batch, 3);
-      dim3 block_p(head_size_, head_number_, 1);
-      transpose_qkv_padding<<<grid_p, block_p, 0, stream>>>(input0_data,
-                                                            tptr,
-                                                            batch,
-                                                            seq_len,
-                                                            head_number_,
-                                                            head_size_,
-                                                            real_seq_len);
+      TransposePadding(input0_data,
+                       tptr,
+                       batch,
+                       seq_len,
+                       head_number_,
+                       head_size_,
+                       real_seq_len,
+                       stream);
     } else {
       TransposeQKV(
           batch, seq_len, head_size_, head_number_, input0_data, tptr, stream);

                                        const int head_num,
                                        const int size_per_head,
                                        const int real_seq_len) {
  int batch_id = blockIdx.x / (head_num * real_seq_len);
  int seq_id = blockIdx.x % real_seq_len;
  int head_id = blockIdx.x % (head_num * real_seq_len) / real_seq_len;
  dst[batch_id * head_num * real_seq_len * size_per_head +
      seq_id * head_num * size_per_head + head_id * size_per_head +
      threadIdx.x] = src[batch_id * head_num * seq_len * size_per_head +
                         head_id * seq_len * size_per_head +
                         seq_id * size_per_head + threadIdx.x];
}

int QkvToContextPluginDynamic::initialize() TRT_NOEXCEPT { return 0; }

    int block = head_size_;
    half *output = static_cast<half *>(outputs[0]);
    if (need_padding) {
      TransposeUnPadding(tptr,
                         output,
                         batch,
                         seq_len,
                         head_number_,
                         head_size_,
                         real_seq_len,
                         stream);
    } else {
      transpose<half><<<grid, block, 0, stream>>>(
          tptr, output, batch, seq_len, head_number_, head_size_);
