Skip to content

Commit f2273df

Browse files
mcr229facebook-github-bot
authored andcommitted
Test (#577)
Summary: Pull Request resolved: #577 Test for inception v3 model both fp32 and quantized Currently we don't have a node visitor for avg_pool2d, so we omitt it. This shouldn't be hard to add, but seems like just a node name that we are missing. We can add this after mvp Reviewed By: digantdesai Differential Revision: D49850153 fbshipit-source-id: e1f22188093d282362e71f5b11a9b1eed4faff10
1 parent 921120f commit f2273df

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
import unittest
8+
9+
import torch
10+
import torchvision.models as models
11+
from executorch.backends.xnnpack.test.tester import Tester
12+
13+
14+
class TestInceptionV3(unittest.TestCase):
15+
# pyre-ignore
16+
ic3 = models.inception_v3(weights="IMAGENET1K_V1").eval() # noqa
17+
model_inputs = (torch.ones(1, 3, 224, 224),)
18+
19+
all_operators = {
20+
"executorch_exir_dialects_edge__ops_aten_addmm_default",
21+
"executorch_exir_dialects_edge__ops_aten_add_Tensor",
22+
"executorch_exir_dialects_edge__ops_aten_cat_default",
23+
"executorch_exir_dialects_edge__ops_aten_convolution_default",
24+
"executorch_exir_dialects_edge__ops_aten_max_pool2d_with_indices_default",
25+
# "executorch.exir.dialects.edge._ops.aten.avg_pool2d.default", Currently do not have avg_pool2d partitioned
26+
"executorch_exir_dialects_edge__ops_aten_mean_dim",
27+
"executorch_exir_dialects_edge__ops_aten__native_batch_norm_legit_no_training_default",
28+
"executorch_exir_dialects_edge__ops_aten_permute_copy_default",
29+
"executorch_exir_dialects_edge__ops_aten_relu_default",
30+
}
31+
32+
def test_fp32_ic3(self):
33+
34+
(
35+
Tester(self.ic3, self.model_inputs)
36+
.export()
37+
.to_edge()
38+
.check(list(self.all_operators))
39+
.partition()
40+
.check(["torch.ops.executorch_call_delegate"])
41+
.check_not(list(self.all_operators))
42+
.to_executorch()
43+
.serialize()
44+
.run_method()
45+
.compare_outputs()
46+
)
47+
48+
def test_qs8_ic3(self):
49+
# Quantization fuses away batchnorm, so it is no longer in the graph
50+
ops_after_quantization = self.all_operators - {
51+
"executorch_exir_dialects_edge__ops_aten__native_batch_norm_legit_no_training_default",
52+
}
53+
54+
(
55+
Tester(self.ic3, self.model_inputs)
56+
.quantize()
57+
.export()
58+
.to_edge()
59+
.check(list(ops_after_quantization))
60+
.partition()
61+
.check(["torch.ops.executorch_call_delegate"])
62+
.check_not(list(ops_after_quantization))
63+
.to_executorch()
64+
.serialize()
65+
.run_method()
66+
.compare_outputs()
67+
)

0 commit comments

Comments
 (0)