jefferyzhang 发表于 2020-5-1 21:17
矩阵乘一直都支持,请把不支持的log具体发出来给我们看下。
- class ToyModel3(nn.Module):
- """
- 测试目的:用 one-hot vector multiplication 代替 if-else
- torch -> onnx -> rknn 转化失败, matmul 不支持
- torch -> rknn 失败, matmul 不支持
- """
- def __init__(self, num_channels):
- super(ToyModel3, self).__init__()
- self.num_channels = num_channels
- self.conv0 = nn.Conv2d(self.num_channels, self.num_channels,
- kernel_size=3, stride=1, padding=0, bias=False)
- self.conv1 = nn.Conv2d(self.num_channels, self.num_channels,
- kernel_size=3, stride=1, padding=0, bias=False)
- self.conv2 = nn.Conv2d(self.num_channels, self.num_channels,
- kernel_size=3, stride=1, padding=0, bias=False)
- n = self.num_channels
- self.conv0.weight = torch.nn.Parameter(torch.Tensor(np.ones((n, n, 3, 3)).astype(np.float32)))
- self.conv1.weight = torch.nn.Parameter(torch.Tensor(2 * np.ones((n, n, 3, 3)).astype(np.float32)))
- self.conv2.weight = torch.nn.Parameter(torch.Tensor(3 * np.ones((n, n, 3, 3)).astype(np.float32)))
- def forward(self, x, one_hot_vec):
- """
- :param x:
- :param one_hot_vec: of shape [3, 1]
- :return:
- """
- x0 = self.conv0(x)
- x1 = self.conv0(x)
- x2 = self.conv0(x)
- y = torch.cat([x0, x1, x2], axis=0)
- yt = y.permute(1, 2, 3, 0)
- out = torch.matmul(yt, one_hot_vec)
- return out
复制代码
jefferyzhang 发表于 2020-5-8 09:29
1. pytorch版本号多少?
2. 试下转onnx再转rknn
3. 问题已经包给npu部门了,等他们支持 ...
xindongzhang 发表于 2020-8-4 18:06
你好,请问matmul的问题解决了吗?谢谢
jefferyzhang 发表于 2020-8-4 23:14
本周会发布1.4.0,届时可以再试下。
或者加入置顶帖的rknn官方交流群里可以直接询问rknn的工程师 ...
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |