()
| 845 | |
| 846 | |
| 847 | def test_hardtanh(): |
| 848 | class Hardtanh(torch.nn.Module): |
| 849 | def __init__(self): |
| 850 | super().__init__() |
| 851 | self.ht = torch.nn.Hardtanh() |
| 852 | |
| 853 | def forward(self, input): |
| 854 | return self.ht(input) |
| 855 | |
| 856 | class Hardtanh2(torch.nn.Module): |
| 857 | def forward(self, input): |
| 858 | return torch.nn.functional.hardtanh(input) |
| 859 | |
| 860 | class Hardtanh3(torch.nn.Module): |
| 861 | def forward(self, input): |
| 862 | return torch.ops.aten.hardtanh_(input) |
| 863 | |
| 864 | @tvm.script.ir_module |
| 865 | class expected_for_1_2: |
| 866 | @R.function |
| 867 | def main(inp_0: R.Tensor((1, 3, 10, 10), dtype="float32")) -> R.Tuple( |
| 868 | R.Tensor((1, 3, 10, 10), dtype="float32") |
| 869 | ): |
| 870 | with R.dataflow(): |
| 871 | lv: R.Tensor((1, 3, 10, 10), dtype="float32") = R.clip( |
| 872 | inp_0, R.prim_value(T.float64(-1.0)), R.prim_value(T.float64(1.0)) |
| 873 | ) |
| 874 | gv: R.Tuple(R.Tensor((1, 3, 10, 10), dtype="float32")) = (lv,) |
| 875 | R.output(gv) |
| 876 | return gv |
| 877 | |
| 878 | example_args = (torch.randn(1, 3, 10, 10, dtype=torch.float32),) |
| 879 | verify_model(Hardtanh(), example_args, {}, expected_for_1_2) |
| 880 | verify_model(Hardtanh2(), example_args, {}, expected_for_1_2) |
| 881 | # In-place hardtanh_ yields the same program; mutation outputs are dropped. |
| 882 | verify_model(Hardtanh3(), example_args, {}, expected_for_1_2) |
| 883 | |
| 884 | |
| 885 | def test_softplus(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…