|
6 | 6 |
|
7 | 7 |
|
8 | 8 | class TestTorchMethod(TestCase): |
9 | | - @pytest.mark.skip(reason="Need create a PR for torch to align output_scale") |
10 | 9 | def test_qsigmoid(self, dtype=torch.float): |
11 | 10 | dtype = torch.qint8 |
12 | 11 |
|
13 | 12 | input0 = torch.randn(1, 1, 5, 5, device="xpu") |
14 | 13 | q_input = torch.quantize_per_tensor(input0, 0.4, 0, dtype=dtype) |
15 | 14 | q_input_cpu = torch.quantize_per_tensor(input0.to("cpu"), 0.4, 0, dtype=dtype) |
| 15 | + |
16 | 16 | result_functional = torch.dequantize(torch.sigmoid(q_input)) |
17 | 17 | result_inplace = torch.dequantize(torch.sigmoid_(q_input)) |
18 | 18 | result_output = torch.randn(1, 1, 5, 5, device="xpu") |
19 | 19 | result_out = torch.dequantize(torch.sigmoid(q_input, out=result_output)) |
20 | | - result_cpu = torch.dequantize(torch.sigmoid(q_input_cpu)) |
21 | 20 |
|
22 | | - self.assertEqual(result_functional.to("cpu"), result_cpu) |
23 | | - self.assertEqual(result_inplace.to("cpu"), result_cpu) |
24 | | - self.assertEqual(result_out.to("cpu"), result_cpu) |
| 21 | + dqX = torch.dequantize(q_input_cpu) |
| 22 | + Y_ref = torch.sigmoid(dqX) |
| 23 | + qY_ref = torch.quantize_per_tensor(Y_ref, 1.0/255.0, 0, torch.quint8) |
| 24 | + dqY_ref = qY_ref.dequantize() |
| 25 | + |
| 26 | + self.assertEqual(result_functional.to("cpu"), dqY_ref) |
| 27 | + self.assertEqual(result_inplace.to("cpu"), dqY_ref) |
| 28 | + self.assertEqual(result_out.to("cpu"), dqY_ref) |
| 29 | + |
0 commit comments