Files
ncnn/tools/pnnx/python/examples/export.py
T

30 lines
629 B
Python

# Copyright 2020 Tencent
# SPDX-License-Identifier: BSD-3-Clause
import pnnx
import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
def forward(self, x, y, z, w):
x = F.relu(x)
y = F.relu(y)
z = F.relu(z)
w = F.relu(w)
return x, y, z, w
if __name__ == "__main__":
net = Model()
torch.manual_seed(0)
x = torch.rand(1, 16)
y = torch.rand(12, 2, 16)
z = torch.rand(1, 3, 12, 16)
w = torch.rand(1, 5, 7, 9, 11)
pnnx.export(net, "test_F_relu", (x, y, z, w))