从操作员级别的深度学习框架导出 ONNX 模型

Exporting ONNX Model from Deep Learning Frameworks at Operator-level

嗨,我有一些关于导出 ONNX 模型的问题。

假设我们有一个来自 PyTorch 的 LSTM 单元。

使用 torch.onnx.export 使用 LSTM layer 生成 ONNX 模型。

不过,我感兴趣的是它是否可以在operator级别生成ONNX模型,即matmul,add。

有办法吗?

如果没有,是否有另一种方法来制作 operator 级别的 ONNX 模型?

谢谢, 杰克

当您使用 torch.onnx.export() 函数将模型从 PyTorch 导出到 onnx 时,它会记录初始模型使用过的所有操作。如前所述 here.

we call the torch.onnx.export() function. This will execute the model, recording a trace of what operators are used to computing the outputs.

所以,是的,它确实在运算符级别生成了 onnx 模型,您甚至可以使用 netron

可视化导出的 .onnx 模型图

如果您仍想使用 onnx 运算符,here 是 ONNX 运算符模式。