forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeeplab_v3.py
More file actions
40 lines (31 loc) · 1.03 KB
/
deeplab_v3.py
File metadata and controls
40 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import unittest
import torch
from executorch.backends.xnnpack.test.tester import Tester
from torchvision.models.segmentation import deeplabv3, deeplabv3_resnet50 # @manual
class DL3Wrapper(torch.nn.Module):
def __init__(self):
super().__init__()
self.m = deeplabv3_resnet50(
weights=deeplabv3.DeepLabV3_ResNet50_Weights.DEFAULT
)
def forward(self, *args):
return self.m(*args)["out"]
class TestDeepLabV3(unittest.TestCase):
dl3 = DL3Wrapper()
dl3 = dl3.eval()
model_inputs = (torch.ones(1, 3, 224, 224),)
def test_fp32_dl3(self):
(
Tester(self.dl3, self.model_inputs)
.export()
.to_edge()
.partition()
.to_executorch()
.serialize()
.run_method_and_compare_outputs()
)