Skip to content

Commit 52cb6e3

Browse files
committed
Fix
1 parent 85e1c9a commit 52cb6e3

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

test/xpu/test_quantize_linear_xpu.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import numpy as np
1818

1919
import paddle
20-
from paddle import _legacy_C_ops
20+
from paddle import _C_ops
2121

2222

2323
class TestQuantizeLinerAPI(unittest.TestCase):
@@ -30,10 +30,10 @@ def setUp(self):
3030
paddle.disable_static()
3131

3232
def run_case(self, function_name, xshape, axis, bit_length, qmin, qmax):
33-
func = getattr(_legacy_C_ops, function_name, None)
33+
func = getattr(_C_ops, function_name, None)
3434
if func is None:
3535
raise ValueError(
36-
f"No function named '{function_name}' found in _legacy_C_ops."
36+
f"No function named '{function_name}' found in _C_ops."
3737
)
3838

3939
x_np = np.random.uniform(-0.1, 0.1, xshape).astype("float32")
@@ -81,31 +81,41 @@ def run_case(self, function_name, xshape, axis, bit_length, qmin, qmax):
8181
)
8282

8383
paddle.set_device("xpu")
84-
y_xpu = func(
84+
ret = func(
8585
x_paddle,
8686
scale_paddle,
8787
zero_paddle,
88-
"quant_axis",
88+
None,
89+
None,
90+
axis,
91+
bit_length,
92+
qmin,
93+
qmax,
94+
)
95+
assert len(ret) == 4, "The return value of quantize_linear " + str(
96+
len(ret)
97+
)
98+
y_xpu, _, _, _ = func(
99+
x_paddle,
100+
scale_paddle,
101+
zero_paddle,
102+
None,
103+
None,
89104
axis,
90-
"bit_length",
91105
bit_length,
92-
"qmin",
93106
qmin,
94-
"qmax",
95107
qmax,
96108
)
97109
paddle.set_device("cpu")
98-
y_cpu = func(
110+
y_cpu, _, _, _ = func(
99111
x_paddle_cpu,
100112
scale_paddle_cpu,
101113
zero_paddle_cpu,
102-
"quant_axis",
114+
None,
115+
None,
103116
axis,
104-
"bit_length",
105117
bit_length,
106-
"qmin",
107118
qmin,
108-
"qmax",
109119
qmax,
110120
)
111121
np.testing.assert_allclose(y_xpu.numpy(), y_cpu.numpy(), atol=0, rtol=0)

0 commit comments

Comments
 (0)