You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_naiveinput_export.py 578 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright 2021 Tencent
  2. # SPDX-License-Identifier: BSD-3-Clause
  3. import pytest
  4. import pnnx
  5. import torch
  6. import torch.nn as nn
  7. import torch.nn.functional as F
  8. from packaging import version
  9. class Model(nn.Module):
  10. def __init__(self):
  11. super(Model, self).__init__()
  12. def forward(self, x):
  13. x = F.relu(x)
  14. return x
  15. def test_export():
  16. net = Model()
  17. net.eval()
  18. torch.manual_seed(0)
  19. x = torch.rand(1, 16)
  20. a0 = net(x)
  21. net_pnnx = pnnx.export(net, "test_F_relu_nexport", x)
  22. b0 = net_pnnx(x)
  23. assert torch.equal(a0, b0)