c`++调用pytorch libtorch`
以GitHub [见参考文献1]为例,学习了c++调用pytorch API libtorch的实现过程。
1.将pytorch模型转换成Torch Script
官方tutorial https://pytorch.org/tutorials/advanced/cpp_export.html中给出了当前将pytorch模型转成Torch Script的两种方式(官方源码如下):
- 1.Converting to Torch Script via Tracing
import torch
import torchvision
# An instance of your model.
model = torchvision