|
| 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.sinh.default" |
| 18 | +exir_op = "executorch_exir_dialects_edge__ops_aten__sinh_default" |
| 19 | + |
| 20 | + |
| 21 | +input_t1 = Tuple[torch.Tensor] # Input x |
| 22 | + |
| 23 | +test_data_suite = { |
| 24 | + # (test_name, test_data) |
| 25 | + "zeros": torch.zeros(10, 10, 10), |
| 26 | + "zeros_alt_shape": torch.zeros(10, 3, 5), |
| 27 | + "ones": torch.ones(10, 10, 10), |
| 28 | + "rand": torch.rand(10, 10) - 0.5, |
| 29 | + "rand_alt_shape": torch.rand(10, 3, 5) - 0.5, |
| 30 | + "randn_pos": torch.randn(10) + 10, |
| 31 | + "randn_neg": torch.randn(10) - 10, |
| 32 | + "ramp": torch.arange(-16, 16, 0.2), |
| 33 | + "large": 100 * torch.ones(1, 1), |
| 34 | + "small": 0.000001 * torch.ones(1, 1), |
| 35 | +} |
| 36 | + |
| 37 | + |
| 38 | +class Sinh(torch.nn.Module): |
| 39 | + |
| 40 | + def forward(self, x: torch.Tensor): |
| 41 | + return torch.sinh(x) |
| 42 | + |
| 43 | + |
| 44 | +@common.parametrize("test_data", test_data_suite) |
| 45 | +def test_sinh_tosa_MI(test_data: Tuple): |
| 46 | + pipeline = TosaPipelineMI[input_t1]( |
| 47 | + Sinh(), |
| 48 | + (test_data,), |
| 49 | + aten_op, |
| 50 | + exir_op, |
| 51 | + ) |
| 52 | + pipeline.run() |
| 53 | + |
| 54 | + |
| 55 | +@common.parametrize("test_data", test_data_suite) |
| 56 | +def test_sinh_tosa_BI(test_data: Tuple): |
| 57 | + pipeline = TosaPipelineBI[input_t1]( |
| 58 | + Sinh(), (test_data,), aten_op=aten_op, exir_op=exir_op |
| 59 | + ) |
| 60 | + pipeline.run() |
| 61 | + |
| 62 | + |
| 63 | +@common.XfailIfNoCorstone300 |
| 64 | +@common.parametrize("test_data", test_data_suite) |
| 65 | +def test_sinh_u55_BI(test_data: Tuple): |
| 66 | + pipeline = EthosU55PipelineBI[input_t1]( |
| 67 | + Sinh(), (test_data,), aten_ops=aten_op, exir_ops=exir_op |
| 68 | + ) |
| 69 | + pipeline.run() |
| 70 | + |
| 71 | + |
| 72 | +@common.XfailIfNoCorstone320 |
| 73 | +@common.parametrize("test_data", test_data_suite) |
| 74 | +def test_sinh_u85_BI(test_data: Tuple): |
| 75 | + pipeline = EthosU85PipelineBI[input_t1]( |
| 76 | + Sinh(), (test_data,), aten_ops=aten_op, exir_ops=exir_op |
| 77 | + ) |
| 78 | + pipeline.run() |
0 commit comments