Skip to content

Commit a714cfe

Browse files
author
Feiyu Chan
authored
always convert numpy array to paddle.Tensor to avoid comparing numpy dtype with paddle dtype. (#40)
* always convert numpy array to paddle.Tensor to avoid comparing numpy dtype with paddle dtype.
1 parent b76c98c commit a714cfe

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

python/paddle/fluid/tests/unittests/fft/test_fft.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def test_fft(self):
129129
class TestFftException(unittest.TestCase):
130130
def test_Fft(self):
131131
with self.assertRaises(self.expect_exception):
132-
paddle.fft.fft(self.x, self.n, self.axis, self.norm)
132+
paddle.fft.fft(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
133133

134134

135135
@place(DEVICES)
@@ -183,7 +183,7 @@ class TestFft2Exception(unittest.TestCase):
183183
def test_fft2(self):
184184
with paddle.fluid.dygraph.guard(self.place):
185185
with self.assertRaises(self.expect_exception):
186-
paddle.fft.fft2(self.x, self.n, self.axis, self.norm)
186+
paddle.fft.fft2(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
187187

188188

189189
@place(DEVICES)
@@ -451,7 +451,7 @@ class TestHfftException(unittest.TestCase):
451451
def test_hfft(self):
452452
with paddle.fluid.dygraph.guard(self.place):
453453
with self.assertRaises(self.expect_exception):
454-
paddle.fft.rfft(self.x, self.n, self.axis, self.norm)
454+
paddle.fft.rfft(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
455455

456456

457457
@place(DEVICES)
@@ -492,7 +492,7 @@ class TestIrfftException(unittest.TestCase):
492492
def test_irfft(self):
493493
with paddle.fluid.dygraph.guard(self.place):
494494
with self.assertRaises(self.expect_exception):
495-
paddle.tensor.fft.irfft(self.x, self.n, self.axis, self.norm)
495+
paddle.tensor.fft.irfft(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
496496

497497

498498
@place(DEVICES)
@@ -532,7 +532,7 @@ class TestHfft2Exception(unittest.TestCase):
532532
def test_hfft2(self):
533533
with paddle.fluid.dygraph.guard(self.place):
534534
with self.assertRaises(self.expect_exception):
535-
paddle.tensor.fft.hfft2(self.x, self.n, self.axis, self.norm)
535+
paddle.tensor.fft.hfft2(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
536536

537537

538538
@place(DEVICES)
@@ -577,7 +577,7 @@ class TestIrfft2Exception(unittest.TestCase):
577577
def test_irfft2(self):
578578
with paddle.fluid.dygraph.guard(self.place):
579579
with self.assertRaises(self.expect_exception):
580-
paddle.tensor.fft.irfft2(self.x, self.n, self.axis, self.norm)
580+
paddle.tensor.fft.irfft2(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
581581

582582

583583
@place(DEVICES)
@@ -617,7 +617,7 @@ class TestHfftnException(unittest.TestCase):
617617
def test_hfftn(self):
618618
with paddle.fluid.dygraph.guard(self.place):
619619
with self.assertRaises(self.expect_exception):
620-
paddle.tensor.fft.hfftn(self.x, self.n, self.axis, self.norm)
620+
paddle.tensor.fft.hfftn(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
621621

622622

623623
@place(DEVICES)
@@ -662,7 +662,7 @@ class TestIrfftnException(unittest.TestCase):
662662
def test_irfftn(self):
663663
with paddle.fluid.dygraph.guard(self.place):
664664
with self.assertRaises(self.expect_exception):
665-
paddle.fft.irfftn(self.x, self.n, self.axis, self.norm)
665+
paddle.fft.irfftn(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
666666

667667

668668
@place(DEVICES)
@@ -700,7 +700,7 @@ def test_rfft(self):
700700
class TestRfftException(unittest.TestCase):
701701
def test_rfft(self):
702702
with self.assertRaises(self.expect_exception):
703-
paddle.fft.rfft(self.x, self.n, self.axis, self.norm)
703+
paddle.fft.rfft(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
704704

705705

706706
@place(DEVICES)
@@ -750,7 +750,7 @@ class TestRfft2Exception(unittest.TestCase):
750750
def test_rfft(self):
751751
with paddle.fluid.dygraph.guard(self.place):
752752
with self.assertRaises(self.expect_exception):
753-
paddle.fft.rfft2(self.x, self.n, self.axis, self.norm)
753+
paddle.fft.rfft2(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
754754

755755

756756
@place(DEVICES)
@@ -792,7 +792,7 @@ class TestRfftnException(unittest.TestCase):
792792
def test_rfft(self):
793793
with paddle.fluid.dygraph.guard(self.place):
794794
with self.assertRaises(self.expect_exception):
795-
paddle.fft.rfftn(self.x, self.n, self.axis, self.norm)
795+
paddle.fft.rfftn(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
796796

797797

798798
@place(DEVICES)
@@ -830,7 +830,7 @@ class TestIhfftException(unittest.TestCase):
830830
def test_ihfft(self):
831831
with paddle.fluid.dygraph.guard(self.place):
832832
with self.assertRaises(self.expect_exception):
833-
paddle.fft.ihfft(self.x, self.n, self.axis, self.norm)
833+
paddle.fft.ihfft(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
834834

835835

836836
@place(DEVICES)
@@ -882,7 +882,7 @@ class TestIhfft2Exception(unittest.TestCase):
882882
def test_rfft(self):
883883
with paddle.fluid.dygraph.guard(self.place):
884884
with self.assertRaises(self.expect_exception):
885-
paddle.fft.ihfft2(self.x, self.n, self.axis, self.norm)
885+
paddle.fft.ihfft2(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
886886

887887

888888
@place(DEVICES)
@@ -922,7 +922,7 @@ class TestIhfftnException(unittest.TestCase):
922922
def test_rfft(self):
923923
with paddle.fluid.dygraph.guard(self.place):
924924
with self.assertRaises(self.expect_exception):
925-
paddle.fft.ihfftn(self.x, self.n, self.axis, self.norm)
925+
paddle.fft.ihfftn(paddle.to_tensor(self.x), self.n, self.axis, self.norm)
926926

927927

928928
@place(DEVICES)

0 commit comments

Comments
 (0)