|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. |
| 16 | +import torch |
| 17 | +from fx2ait.acc_tracer import acc_ops |
| 18 | +from fx2ait.tools.common_fx2ait import AITTestCase |
| 19 | + |
| 20 | + |
| 21 | +class TestEluConverter(AITTestCase): |
| 22 | + def test_elu(self): |
| 23 | + class TestModule(torch.nn.Module): |
| 24 | + def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 25 | + return torch.nn.functional.elu(x) |
| 26 | + |
| 27 | + model = TestModule().cuda().half() |
| 28 | + inputs = [ |
| 29 | + torch.randn(2, 3).half().cuda(), |
| 30 | + ] |
| 31 | + |
| 32 | + self.run_test(model, inputs, expected_ops={acc_ops.elu}) |
| 33 | + |
| 34 | + def test_elu_with_alpha(self): |
| 35 | + class TestModule(torch.nn.Module): |
| 36 | + def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 37 | + return torch.nn.functional.elu(x, alpha=3.14) |
| 38 | + |
| 39 | + model = TestModule().cuda().half() |
| 40 | + inputs = [ |
| 41 | + torch.randn(2, 3).half().cuda(), |
| 42 | + ] |
| 43 | + |
| 44 | + self.run_test(model, inputs, expected_ops={acc_ops.elu}) |
0 commit comments