|
| 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 torch |
| 9 | +from executorch.backends.arm.test import common |
| 10 | +from executorch.backends.arm.test.tester.test_pipeline import ( |
| 11 | + EthosU55PipelineBI, |
| 12 | + EthosU85PipelineBI, |
| 13 | + TosaPipelineBI, |
| 14 | + TosaPipelineMI, |
| 15 | +) |
| 16 | + |
| 17 | +aten_op = "torch.ops.aten.erf.default" |
| 18 | +exir_op = "executorch_exir_dialects_edge__ops_aten_erf_default" |
| 19 | +input_t1 = Tuple[torch.Tensor] # Input x |
| 20 | + |
| 21 | + |
| 22 | +class Erf(torch.nn.Module): |
| 23 | + def forward(self, x: torch.Tensor): |
| 24 | + return torch.erf(x) |
| 25 | + |
| 26 | + test_data: dict[str, input_t1] = { |
| 27 | + "zeros": (torch.zeros(1, 10, 10, 10),), |
| 28 | + "ones": (torch.ones(10, 10, 10),), |
| 29 | + "rand": ((torch.rand(10, 10) - 0.5),), |
| 30 | + "randn_pos": ((torch.randn(1, 4, 4, 4) + 10),), |
| 31 | + "randn_neg": ((torch.randn(1, 4, 4, 4) - 10),), |
| 32 | + "ramp": (torch.arange(-16, 16, 0.2),), |
| 33 | + } |
| 34 | + |
| 35 | + |
| 36 | +@common.parametrize("test_data", Erf.test_data) |
| 37 | +def test_erf_tosa_MI(test_data: input_t1): |
| 38 | + pipeline = TosaPipelineMI[input_t1](Erf(), test_data, aten_op, exir_op) |
| 39 | + pipeline.run() |
| 40 | + |
| 41 | + |
| 42 | +@common.parametrize("test_data", Erf.test_data) |
| 43 | +def test_erf_tosa_BI(test_data: input_t1): |
| 44 | + pipeline = TosaPipelineBI[input_t1](Erf(), test_data, aten_op, exir_op) |
| 45 | + pipeline.run() |
| 46 | + |
| 47 | + |
| 48 | +@common.parametrize("test_data", Erf.test_data) |
| 49 | +@common.XfailIfNoCorstone300 |
| 50 | +def test_erf_u55_BI(test_data: input_t1): |
| 51 | + pipeline = EthosU55PipelineBI[input_t1]( |
| 52 | + Erf(), test_data, aten_op, exir_op, run_on_fvp=True |
| 53 | + ) |
| 54 | + pipeline.run() |
| 55 | + |
| 56 | + |
| 57 | +@common.parametrize("test_data", Erf.test_data) |
| 58 | +@common.XfailIfNoCorstone320 |
| 59 | +def test_erf_u85_BI(test_data: input_t1): |
| 60 | + pipeline = EthosU85PipelineBI[input_t1]( |
| 61 | + Erf(), test_data, aten_op, exir_op, run_on_fvp=True |
| 62 | + ) |
| 63 | + pipeline.run() |
0 commit comments