Skip to content

Instantly share code, notes, and snippets.

@dsuess
Last active May 17, 2019 00:31
Show Gist options
  • Save dsuess/131c209daa707ea4d13f810385f3b049 to your computer and use it in GitHub Desktop.
Save dsuess/131c209daa707ea4d13f810385f3b049 to your computer and use it in GitHub Desktop.
import numpy as np
import torch
from torch import nn
import onnx_tensorrt.backend as backend
import onnx
class Model(nn.Module):
def forward(self, x):
y = (2 * x)[0:1]
return y
model = Model().eval()
dummy_input = torch.randn(4, 4, 4)
with torch.no_grad():
torch.onnx.export(model, dummy_input, 'test.onnx', verbose=True)
model = onnx.load('test.onnx')
engine = backend.prepare(model, device='CUDA:0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment