[Refactor] Remove multiple dead codes (#50285)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
@@ -521,32 +521,6 @@ class Phi4MMAudioEmbeddingInputs(TensorSchema):
|
||||
Phi4MMAudioInputs: TypeAlias = Phi4MMAudioFeatureInputs | Phi4MMAudioEmbeddingInputs
|
||||
|
||||
|
||||
def cat_with_pad(tensors, dim, padding_value=0):
|
||||
"""
|
||||
cat along dim, while pad to max for all other dims
|
||||
"""
|
||||
ndim = tensors[0].dim()
|
||||
assert all(t.dim() == ndim for t in tensors[1:]), (
|
||||
"All tensors must have the same number of dimensions"
|
||||
)
|
||||
|
||||
out_size = [max(t.shape[i] for t in tensors) for i in range(ndim)]
|
||||
out_size[dim] = sum(t.shape[dim] for t in tensors)
|
||||
output = tensors[0].new_full(out_size, padding_value)
|
||||
|
||||
index = 0
|
||||
for t in tensors:
|
||||
# Create a slice list where every dimension except dim is full slice
|
||||
slices = [slice(0, t.shape[d]) for d in range(ndim)]
|
||||
# Update only the concat dimension slice
|
||||
slices[dim] = slice(index, index + t.shape[dim])
|
||||
|
||||
output[slices] = t
|
||||
index += t.shape[dim]
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def stack_with_pad(
|
||||
tensors: torch.Tensor | list[torch.Tensor],
|
||||
padding_value: int | float = 0,
|
||||
|
||||
Reference in New Issue
Block a user