def test_relu_api(self): X = torch.arange(-5, 5, dtype=torch.float) scale = 2.0 zero_point = 1 qX = torch.quantize_linear(X, scale=scale, zero_point=zero_point, dtype=torch.quint8) qY = torch.ops.quantized.relu(qX) qY_hat = qF.relu(qX) self.assertEqual(qY, qY_hat)
def test_functional_api(self): X = torch.arange(-5, 5, dtype=torch.float) scale = 2.0 zero_point = 1 Y = X.numpy().copy() Y[Y < 0] = 0 qY = _quantize(Y, scale, zero_point) qX = X.quantize_linear(scale=scale, zero_point=zero_point, dtype=torch.qint8) qY_hat = F.relu(qX) np.testing.assert_equal(qY, qY_hat.int_repr())