File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
backends/intel_hpu/custom_ops/python/paddlenlp_ops Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,26 @@ def rebuild_padding_v2(
235
235
return output_data
236
236
237
237
238
+ def rebuild_padding_v3 (
239
+ tmp_out ,
240
+ batch_ids ,
241
+ total_batch ,
242
+ seq_lens_encoder ,
243
+ is_prompt = None ,
244
+ ):
245
+ dim_emb = tmp_out .shape [- 1 ]
246
+ output_data = paddle .zeros ((batch_ids .shape [0 ], dim_emb ))
247
+ if is_prompt is True : # context
248
+ tmp_out = tmp_out .reshape ([total_batch , - 1 , dim_emb ])
249
+ for i in range (batch_ids .shape [0 ]):
250
+ seq_len = seq_lens_encoder [batch_ids [i ]].item ()
251
+ output_data [i ] = tmp_out [i , seq_len - 1 ]
252
+ elif is_prompt is False :
253
+ output_data = tmp_out [: batch_ids .shape [0 ], :]
254
+
255
+ return output_data
256
+
257
+
238
258
def fused_flatpa_proj_ref (
239
259
query ,
240
260
key_cache ,
You can’t perform that action at this time.
0 commit comments