Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PIR] A-12 Adapt concat test_errors #61036

Merged
28 changes: 28 additions & 0 deletions test/legacy_test/test_concat_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,5 +940,33 @@ def if_enable_cinn(self):
pass


class TestConcatOpErrorWithPir(unittest.TestCase):
@test_with_pir_api
def test_errors_with_pir(self):
paddle.enable_static()
with paddle.static.program_guard(
paddle.static.Program(), paddle.static.Program()
):
# The input dtype of concat_op must be float16, float32, float64, int32, int64.
x4 = paddle.static.data(shape=[4], dtype='uint8', name='x4')
x5 = paddle.static.data(shape=[4], dtype='uint8', name='x5')
self.assertRaises(TypeError, paddle.concat, [x4, x5])
0x45f marked this conversation as resolved.
Show resolved Hide resolved

# The type of axis in concat_op should be int or Variable.
x6 = paddle.static.data(shape=[-1, 4], dtype='float16', name='x6')
x7 = paddle.static.data(shape=[-1, 4], dtype='float16', name='x7')
x8 = paddle.static.data(shape=[-1, 4], dtype='float32', name='x8')

def test_axis_type():
paddle.concat([x6, x7], 3.2)

self.assertRaises(TypeError, test_axis_type)

def test_input_same_dtype():
paddle.concat([x7, x8])

self.assertRaises(TypeError, test_input_same_dtype)


if __name__ == '__main__':
unittest.main()