torch_npu.npu_confusion_transpose

API接口

torch_npu.npu_confusion_transpose(self, perm, shape, transpose_first) -> Tensor

功能描述

混淆reshape和transpose运算。

参数说明

示例

>>> x = torch.rand(2, 3, 4, 6).npu()
>>> x.shape
torch.Size([2, 3, 4, 6])
>>> y = torch_npu.npu_confusion_transpose(x, (0, 2, 1, 3), (2, 4, 18), True)
>>> y.shape
torch.Size([2, 4, 18])
>>> y2 = torch_npu.npu_confusion_transpose(x, (0, 2, 1), (2, 12, 6), False)
>>> y2.shape
torch.Size([2, 6, 12])