问题一:torch模型中有条件支路
ONNX export failure: Exporting the operator silu to ONNX opset version 12 is not supported. Please open a bug to request ONNX export support for the missing operator.
参考link 修改silu实现
class SiLU(Module):
__constants__ = ['inplace']
inplace: bool
def __init__(self, inplace: bool = False):
super(SiLU, self).__init__()
self.inplace = inplace
def forward(self, input: Tensor) -> Tensor:
# ------------------------------------- #
# 把F.silu替换掉,修改后如下
return input * torch.sigmoid(input)
#原来的代码
return F.silu(input, inplace=self.inplace)
2 trt
ERROR: builtin_op_importers.cpp:1602 In function importIf:
[8] Assertion failed: cond.is_weights() && cond.weights().count() == 1 && "If condition must be a initializer!"
vino
There is no registered "infer" function for node "If_156" with op = "If". Please implement this function in the extensions.
参考link
错误是发生在importIf,即if节点,可是我forward函数里没有写任何判断,研究了一下转onnx的输出,发现问题出自squeeze()函数,torch1.7版本在onnx里加了一个判断操作,判断要squeeze的维度是不是1: