PyTorchConverter

class webdnn.frontend.pytorch.PyTorchConverter[source]

Converter for PyTorch.

In conversion, model is exported as ONNX format, and then converted by ONNXConverter. Therefore both torch and onnx python package are required.

convert(model)[source]

Convert PyTorch computational graph into WebDNN IR.

example

Convert PyTorch pre-trained AlexNet model.

import torch, torchvision
from webdnn.frontend.pytorch import PyTorchConverter

model = torchvision.models.alexnet(pretrained=True)
dummy_input = torch.autograd.Variable(torch.randn(1, 3, 224, 224))

graph = PyTorchConverter().convert(model, dummy_input)
Returns:WebDNN Graph
Return type:(Graph)