|
| 1 | +# Copyright 2025 Arm Limited and/or its affiliates. |
| 2 | +# |
| 3 | +# This source code is licensed under the BSD-style license found in the |
| 4 | +# LICENSE file in the root directory of this source tree. |
| 5 | + |
| 6 | +from typing import Tuple |
| 7 | + |
| 8 | +import common |
| 9 | +import pytest |
| 10 | + |
| 11 | +import torch |
| 12 | + |
| 13 | +from executorch.backends.arm.test.tester.test_pipeline import ( |
| 14 | + EthosU55PipelineINT, |
| 15 | + EthosU85PipelineINT, |
| 16 | + TosaPipelineFP, |
| 17 | + TosaPipelineINT, |
| 18 | + VgfPipeline, |
| 19 | +) |
| 20 | + |
| 21 | +from torchvision import models, transforms |
| 22 | + |
| 23 | +ic3 = models.inception_v3(weights=models.Inception_V3_Weights) |
| 24 | +ic3 = ic3.eval() |
| 25 | + |
| 26 | +# Normalization values referenced from here: |
| 27 | +# https://docs.pytorch.org/vision/main/models/generated/torchvision.models.quantization.inception_v3.html |
| 28 | +normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) |
| 29 | + |
| 30 | +model_inputs = (normalize(torch.rand(1, 3, 224, 224)),) |
| 31 | +input_t = Tuple[torch.Tensor] |
| 32 | + |
| 33 | + |
| 34 | +@pytest.mark.slow |
| 35 | +def test_ic3_tosa_FP(): |
| 36 | + pipeline = TosaPipelineFP[input_t]( |
| 37 | + ic3, |
| 38 | + model_inputs, |
| 39 | + aten_op=[], |
| 40 | + exir_op=[], |
| 41 | + use_to_edge_transform_and_lower=True, |
| 42 | + ) |
| 43 | + pipeline.run() |
| 44 | + |
| 45 | + |
| 46 | +@pytest.mark.slow |
| 47 | +def test_ic3_tosa_BI(): |
| 48 | + pipeline = TosaPipelineINT[input_t]( |
| 49 | + ic3, |
| 50 | + model_inputs, |
| 51 | + aten_op=[], |
| 52 | + exir_op=[], |
| 53 | + use_to_edge_transform_and_lower=True, |
| 54 | + atol=0.5, |
| 55 | + qtol=1, |
| 56 | + ) |
| 57 | + pipeline.run() |
| 58 | + |
| 59 | + |
| 60 | +@pytest.mark.slow |
| 61 | +@pytest.mark.skip(reason="Takes too long to run on CI") |
| 62 | +@common.XfailIfNoCorstone300 |
| 63 | +def test_ic3_u55_BI(): |
| 64 | + pipeline = EthosU55PipelineINT[input_t]( |
| 65 | + ic3, |
| 66 | + model_inputs, |
| 67 | + aten_ops=[], |
| 68 | + exir_ops=[], |
| 69 | + run_on_fvp=True, |
| 70 | + use_to_edge_transform_and_lower=True, |
| 71 | + atol=0.5, |
| 72 | + qtol=1, |
| 73 | + ) |
| 74 | + pipeline.run() |
| 75 | + |
| 76 | + |
| 77 | +@pytest.mark.slow |
| 78 | +@pytest.mark.skip(reason="Takes too long to run on CI") |
| 79 | +@common.XfailIfNoCorstone320 |
| 80 | +def test_ic3_u85_BI(): |
| 81 | + pipeline = EthosU85PipelineINT[input_t]( |
| 82 | + ic3, |
| 83 | + model_inputs, |
| 84 | + aten_ops=[], |
| 85 | + exir_ops=[], |
| 86 | + run_on_fvp=True, |
| 87 | + use_to_edge_transform_and_lower=True, |
| 88 | + atol=0.5, |
| 89 | + qtol=1, |
| 90 | + ) |
| 91 | + pipeline.run() |
| 92 | + |
| 93 | + |
| 94 | +@pytest.mark.slow |
| 95 | +@pytest.mark.skip(reason="Takes too long to run on CI") |
| 96 | +@common.SkipIfNoModelConverter |
| 97 | +def test_ic3_vgf_FP(): |
| 98 | + pipeline = VgfPipeline[input_t]( |
| 99 | + ic3, |
| 100 | + model_inputs, |
| 101 | + aten_op=[], |
| 102 | + exir_op=[], |
| 103 | + tosa_version="TOSA-1.0+FP", |
| 104 | + use_to_edge_transform_and_lower=True, |
| 105 | + ) |
| 106 | + pipeline.run() |
| 107 | + |
| 108 | + |
| 109 | +@pytest.mark.slow |
| 110 | +@pytest.mark.skip(reason="Takes too long to run on CI") |
| 111 | +@common.SkipIfNoModelConverter |
| 112 | +def test_ic3_vgf_INT(): |
| 113 | + pipeline = VgfPipeline[input_t]( |
| 114 | + ic3, |
| 115 | + model_inputs, |
| 116 | + aten_op=[], |
| 117 | + exir_op=[], |
| 118 | + tosa_version="TOSA-1.0+INT", |
| 119 | + use_to_edge_transform_and_lower=True, |
| 120 | + ) |
| 121 | + pipeline.run() |
0 commit comments