Skip to content

Commit

Permalink
add some test
Browse files Browse the repository at this point in the history
  • Loading branch information
gouzil committed Oct 16, 2023
1 parent 7bc46e3 commit 46bfd7c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/legacy_test/test_math_op_patch_pir.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import inspect
import unittest
import warnings

import paddle

Expand All @@ -24,9 +25,25 @@ class TestMathOpPatchesPir(unittest.TestCase):
def test_item(self):
with paddle.pir_utils.IrGuard():
x = paddle.static.data(name='x', shape=[3, 2, 1])
y = paddle.static.data(
name='y',
shape=[
3,
],
)
self.assertTrue(y.item() == y)
with self.assertRaises(TypeError):
x.item()

def test_place(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
with paddle.pir_utils.IrGuard():
x = paddle.static.data(name='x', shape=[3, 2, 1])
x.place()
self.assertTrue(len(w) == 1)
self.assertTrue("place" in str(w[-1].message))

def test_some_dim(self):
with paddle.pir_utils.IrGuard():
x = paddle.static.data(name='x', shape=[3, 2, 1])
Expand Down

0 comments on commit 46bfd7c

Please sign in to comment.