Skip to content

Commit 7892602

Browse files
Add float models e2e test
The original float models are tested by executing aot_compiler script. Additionally, unify the outputs to tuple format in base tester. Co-authored-by: chong-chen <[email protected]>
1 parent b70e6fa commit 7892602

File tree

12 files changed

+157
-59
lines changed

12 files changed

+157
-59
lines changed

.github/workflows/pull.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -929,12 +929,6 @@ jobs:
929929
export SAMSUNG_AI_LITECORE_KEY=$SECRET_SAMSUNG_AI_LITECORE_KEY
930930
source .ci/scripts/setup-samsung-linux-deps.sh
931931
932-
# Test models serially
933-
models="mv2 ic3 resnet18 resnet50 mv3 ic4 dl3 edsr vit w2l"
934-
for model in $models; do
935-
python -m executorch.examples.samsung.aot_compiler --model_name=$model -c E9955
936-
done
937-
938932
# Test quant models
939933
model_scripts="deeplab_v3 edsr inception_v3 inception_v4 mobilenet_v2 mobilenet_v3 resnet18 resnet50 vit wav2letter"
940934
for m_script in $model_scripts; do
@@ -943,6 +937,8 @@ jobs:
943937
944938
# Test ops
945939
python -m unittest discover -s backends/samsung/test/ops -p "test_*.py"
940+
# Test models
941+
python -m unittest discover -s backends/samsung/test/models -p "test_*.py"
946942
947943
948944
test-vulkan-models-linux:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) Samsung Electronics Co. LTD
2+
# All rights reserved
3+
#
4+
# Licensed under the BSD License (the "License"); you may not use this file
5+
# except in compliance with the License. See the license file in the root
6+
# directory of this source tree for more details.
7+
import unittest
8+
9+
from executorch.backends.samsung.serialization.compile_options import (
10+
gen_samsung_backend_compile_spec,
11+
)
12+
from executorch.backends.samsung.test.tester import SamsungTester
13+
from executorch.examples.models.deeplab_v3 import DeepLabV3ResNet50Model
14+
15+
16+
class TestMilestoneDeepLabV3(unittest.TestCase):
17+
def test_dl3_fp16(self):
18+
model = DeepLabV3ResNet50Model().get_eager_model()
19+
example_input = DeepLabV3ResNet50Model().get_example_inputs()
20+
tester = SamsungTester(
21+
model, example_input, [gen_samsung_backend_compile_spec("E9955")]
22+
)
23+
(
24+
tester.export()
25+
.to_edge_transform_and_lower()
26+
.to_executorch()
27+
.run_method_and_compare_outputs(inputs=example_input, atol=0.009)
28+
)

backends/samsung/test/models/test_edsr.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@
88

99
import unittest
1010

11-
import torch
12-
1311
from executorch.backends.samsung.serialization.compile_options import (
1412
gen_samsung_backend_compile_spec,
1513
)
1614
from executorch.backends.samsung.test.tester import SamsungTester
1715
from executorch.examples.models.edsr import EdsrModel
1816

1917

20-
class Test_Milestone_Edsr(unittest.TestCase):
18+
class TestMilestoneEdsr(unittest.TestCase):
2119
def test_edsr_fp16(self):
2220
model = EdsrModel().get_eager_model()
2321
example_input = EdsrModel().get_example_inputs()
24-
22+
tester = SamsungTester(
23+
model, example_input, [gen_samsung_backend_compile_spec("E9955")]
24+
)
2525
(
26-
SamsungTester(model,
27-
example_input,
28-
[gen_samsung_backend_compile_spec("E9955")],)
29-
.export()
26+
tester.export()
3027
.to_edge_transform_and_lower()
3128
.to_executorch()
32-
.run_method_and_compare_outputs(atol=0.02, rtol=0.02)
29+
.run_method_and_compare_outputs(inputs=example_input, atol=0.02)
3330
)

backends/samsung/test/models/test_inception_v3.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@
88

99
import unittest
1010

11-
import torch
12-
1311
from executorch.backends.samsung.serialization.compile_options import (
1412
gen_samsung_backend_compile_spec,
1513
)
1614
from executorch.backends.samsung.test.tester import SamsungTester
1715
from executorch.examples.models.inception_v3 import InceptionV3Model
1816

1917

20-
class Test_Inception_V3(unittest.TestCase):
18+
class TestInceptionV3(unittest.TestCase):
2119
def test_inception_v3_fp16(self):
2220
model = InceptionV3Model().get_eager_model()
2321
example_input = InceptionV3Model().get_example_inputs()
24-
22+
tester = SamsungTester(
23+
model, example_input, [gen_samsung_backend_compile_spec("E9955")]
24+
)
2525
(
26-
SamsungTester(model,
27-
example_input,
28-
[gen_samsung_backend_compile_spec("E9955")],)
29-
.export()
26+
tester.export()
3027
.to_edge_transform_and_lower()
3128
.to_executorch()
32-
.run_method_and_compare_outputs(atol=0.02, rtol=0.02)
29+
.run_method_and_compare_outputs(inputs=example_input, atol=0.02, rtol=0.02)
3330
)

backends/samsung/test/models/test_inception_v4.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@
88

99
import unittest
1010

11-
import torch
12-
1311
from executorch.backends.samsung.serialization.compile_options import (
1412
gen_samsung_backend_compile_spec,
1513
)
1614
from executorch.backends.samsung.test.tester import SamsungTester
1715
from executorch.examples.models.inception_v4 import InceptionV4Model
1816

1917

20-
class Test_Milestone_InceptionV4(unittest.TestCase):
18+
class TestMilestoneInceptionV4(unittest.TestCase):
2119
def test_inception_v4_fp16(self):
2220
model = InceptionV4Model().get_eager_model()
2321
example_input = InceptionV4Model().get_example_inputs()
24-
22+
tester = SamsungTester(
23+
model, example_input, [gen_samsung_backend_compile_spec("E9955")]
24+
)
2525
(
26-
SamsungTester(model,
27-
example_input,
28-
[gen_samsung_backend_compile_spec("E9955")],)
29-
.export()
26+
tester.export()
3027
.to_edge_transform_and_lower()
3128
.to_executorch()
32-
.run_method_and_compare_outputs(atol=0.02, rtol=0.02)
29+
.run_method_and_compare_outputs(inputs=example_input, atol=0.02, rtol=0.02)
3330
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) Samsung Electronics Co. LTD
2+
# All rights reserved
3+
#
4+
# Licensed under the BSD License (the "License"); you may not use this file
5+
# except in compliance with the License. See the license file in the root
6+
# directory of this source tree for more details.
7+
import unittest
8+
9+
from executorch.backends.samsung.serialization.compile_options import (
10+
gen_samsung_backend_compile_spec,
11+
)
12+
from executorch.backends.samsung.test.tester import SamsungTester
13+
from executorch.examples.models.mobilenet_v2 import MV2Model
14+
15+
16+
class TestMilestoneMobilenetV2(unittest.TestCase):
17+
def test_mv2_fp16(self):
18+
model = MV2Model().get_eager_model()
19+
example_input = MV2Model().get_example_inputs()
20+
tester = SamsungTester(
21+
model, example_input, [gen_samsung_backend_compile_spec("E9955")]
22+
)
23+
(
24+
tester.export()
25+
.to_edge_transform_and_lower()
26+
.to_executorch()
27+
.run_method_and_compare_outputs(inputs=example_input, atol=0.02)
28+
)

backends/samsung/test/models/test_mobilenet_v3.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@
1717
from executorch.examples.models.mobilenet_v3 import MV3Model
1818

1919

20-
class Test_Milestone_MobilenetV3(unittest.TestCase):
20+
class TestMilestoneMobilenetV3(unittest.TestCase):
2121
def test_mv3_fp16(self):
22+
torch.manual_seed(8)
2223
model = MV3Model().get_eager_model()
2324
example_input = MV3Model().get_example_inputs()
24-
25+
tester = SamsungTester(
26+
model, example_input, [gen_samsung_backend_compile_spec("E9955")]
27+
)
2528
(
26-
SamsungTester(model,
27-
example_input,
28-
[gen_samsung_backend_compile_spec("E9955")],)
29-
.export()
29+
tester.export()
3030
.to_edge_transform_and_lower()
3131
.to_executorch()
32-
.run_method_and_compare_outputs(atol=0.06, rtol=0.06)
33-
# TODO: theshold value should be updated after fixing accuracy issue
32+
.run_method_and_compare_outputs(inputs=example_input, atol=0.07, rtol=0.07)
3433
)

backends/samsung/test/models/test_resnet18.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@
88

99
import unittest
1010

11-
import torch
12-
1311
from executorch.backends.samsung.serialization.compile_options import (
1412
gen_samsung_backend_compile_spec,
1513
)
1614
from executorch.backends.samsung.test.tester import SamsungTester
1715
from executorch.examples.models.resnet import ResNet18Model
1816

1917

20-
class Test_Milestone_ResNet18(unittest.TestCase):
18+
class TestMilestoneResNet18(unittest.TestCase):
2119
def test_resnet18_fp16(self):
2220
model = ResNet18Model().get_eager_model()
2321
example_input = ResNet18Model().get_example_inputs()
24-
22+
tester = SamsungTester(
23+
model, example_input, [gen_samsung_backend_compile_spec("E9955")]
24+
)
2525
(
26-
SamsungTester(model,
27-
example_input,
28-
[gen_samsung_backend_compile_spec("E9955")],)
29-
.export()
26+
tester.export()
3027
.to_edge_transform_and_lower()
3128
.to_executorch()
32-
.run_method_and_compare_outputs(atol=0.02, rtol=0.02)
29+
.run_method_and_compare_outputs(inputs=example_input, atol=0.02, rtol=0.02)
3330
)

backends/samsung/test/models/test_resnet50.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@
88

99
import unittest
1010

11-
import torch
12-
1311
from executorch.backends.samsung.serialization.compile_options import (
1412
gen_samsung_backend_compile_spec,
1513
)
1614
from executorch.backends.samsung.test.tester import SamsungTester
1715
from executorch.examples.models.resnet import ResNet50Model
1816

1917

20-
class Test_Milestone_ResNet50(unittest.TestCase):
18+
class TestMilestoneResNet50(unittest.TestCase):
2119
def test_resnet50_fp16(self):
2220
model = ResNet50Model().get_eager_model()
2321
example_input = ResNet50Model().get_example_inputs()
24-
22+
tester = SamsungTester(
23+
model, example_input, [gen_samsung_backend_compile_spec("E9955")]
24+
)
2525
(
26-
SamsungTester(model,
27-
example_input,
28-
[gen_samsung_backend_compile_spec("E9955")],)
29-
.export()
26+
tester.export()
3027
.to_edge_transform_and_lower()
3128
.to_executorch()
32-
.run_method_and_compare_outputs(atol=0.02, rtol=0.02)
29+
.run_method_and_compare_outputs(inputs=example_input, atol=0.02, rtol=0.02)
3330
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) Samsung Electronics Co. LTD
2+
# All rights reserved
3+
#
4+
# Licensed under the BSD License (the "License"); you may not use this file
5+
# except in compliance with the License. See the license file in the root
6+
# directory of this source tree for more details.
7+
import unittest
8+
9+
import torch
10+
from executorch.backends.samsung.serialization.compile_options import (
11+
gen_samsung_backend_compile_spec,
12+
)
13+
from executorch.backends.samsung.test.tester import SamsungTester
14+
from executorch.examples.models.torchvision_vit import TorchVisionViTModel
15+
16+
17+
class TestMilestoneTorchVisionViT(unittest.TestCase):
18+
def test_torchvision_vit_fp16(self):
19+
torch.manual_seed(8)
20+
model = TorchVisionViTModel().get_eager_model()
21+
example_input = TorchVisionViTModel().get_example_inputs()
22+
tester = SamsungTester(
23+
model, example_input, [gen_samsung_backend_compile_spec("E9955")]
24+
)
25+
(
26+
tester.export()
27+
.to_edge_transform_and_lower()
28+
.to_executorch()
29+
.run_method_and_compare_outputs(
30+
inputs=example_input, atol=0.005, rtol=0.005
31+
)
32+
)

0 commit comments

Comments
 (0)