具体见: onnx Operator Schemas

1. shape

取一个tensor的shape

torch.tensor([[2, 3, 4], [3,4,5]])

# shape操作输出 (2, 3)

2. gather

一般用来取shape的某一个维度,例如

torch.tensor([2, 256, 768]).gather(index=0)
# 输出2

torch.tensor([2, 256, 768]).gather(index=1)
# 输出256

3. Unsqueeze

扩充维度

4. concat

将list of tensor合并成一个tensor

5. reshape

将一个tensor变换形状,例如

torch.tensor([1, 2, 3, 4]).reshape(2, 2)
"""
输出:
[[1, 2],
 [3, 4]]
"""

6. MatMul

矩阵相乘

7. Add, Sub, Mul, Div

对应位置加、减、乘、除法。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐