MCPcopy
hub / github.com/NVIDIA/TensorRT-LLM / permute

Function permute

tensorrt_llm/functional.py:1685–1712  ·  view source on GitHub ↗

Add an operation to permute the dimensions of a tensor. The dimensions of the input tensor are permuted according to the sequence of dimensions in 'dims'. That operation maps to tensorrt.IShuffleLayer where the second transposition is described by the indices in 'dims'. Given

(input: Tensor, dims: Sequence[int])

Source from the content-addressed store, hash-verified

1683
1684
1685def permute(input: Tensor, dims: Sequence[int]) -> Tensor:
1686 '''
1687 Add an operation to permute the dimensions of a tensor.
1688
1689 The dimensions of the input tensor are permuted according to the sequence
1690 of dimensions in 'dims'. That operation maps to tensorrt.IShuffleLayer where
1691 the second transposition is described by the indices in 'dims'.
1692
1693 Given a tensor of rank N, the result of the permutation is a tensor of rank
1694 N in which the i-th input dimension maps to the dims[i]-th dimension.
1695
1696 For example, permute(input, [1, 0]) will transpose a 2D tensor by permuting
1697 the rows and columns.
1698
1699 Parameters:
1700 input : Tensor
1701 The input tensor to permute.
1702
1703 dims : Sequence[int]
1704 The description of the permutation.
1705
1706 Returns:
1707 The tensor produced by the permutation layer.
1708 '''
1709 dims = dim_resolve_negative(tuple(dims), input.ndim())
1710 layer = default_trtnet().add_shuffle(input.trt_tensor)
1711 layer.second_transpose = dims
1712 return _create_tensor(layer.get_output(0), layer)
1713
1714
1715def transpose(input: Tensor, dim0: int, dim1: int) -> Tensor:

Callers 3

permuteMethod · 0.70
transposeFunction · 0.70
rearrangeFunction · 0.70

Calls 5

dim_resolve_negativeFunction · 0.85
default_trtnetFunction · 0.85
_create_tensorFunction · 0.85
ndimMethod · 0.45
get_outputMethod · 0.45

Tested by

no test coverage detected