MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / slice_tensor

Function slice_tensor

fastdeploy/model_executor/models/tp_utils.py:222–230  ·  view source on GitHub ↗

slice_tensor

(tensor, start, end)

Source from the content-addressed store, hash-verified

220 return tensor.get_shape() if hasattr(tensor, "get_shape") else tensor.shape
221
222 def slice_tensor(tensor, start, end):
223 """slice_tensor"""
224 shape = get_shape(tensor)
225 if len(shape) == 1:
226 return tensor[start:end]
227 elif is_column:
228 return tensor[..., start:end]
229 else:
230 return tensor[start:end, ...]
231
232 q_end = num_attention_heads * head_dim
233 k_end = q_end + num_key_value_heads * head_dim

Callers 5

gqa_qkv_split_funcMethod · 0.85
split_tensorMethod · 0.85
gqa_qkv_merge_funcMethod · 0.85
fnFunction · 0.85
split_tensorFunction · 0.85

Calls 1

get_shapeFunction · 0.85

Tested by

no test coverage detected