Skip to content

Commit 80b90a3

Browse files
committed
update
1 parent c856a32 commit 80b90a3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

python/paddle/tensor/creation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,6 +3450,10 @@ def resize_(
34503450
],
34513451
'resize',
34523452
)
3453+
if not isinstance(shape, (list, tuple)):
3454+
raise ValueError(
3455+
f"Input (shape) should be list or tuple but received {type(shape)}"
3456+
)
34533457
new_size = math.prod(shape)
34543458
old_size = math.prod(x.shape)
34553459
if (new_size > old_size) and fill_zero:

test/legacy_test/test_inplace.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2383,13 +2383,22 @@ def leaf_inplace_error():
23832383

23842384
self.assertRaises(ValueError, leaf_inplace_error)
23852385

2386+
def test_argument_error(self):
2387+
with paddle.base.dygraph.guard():
2388+
x = paddle.to_tensor(self.x_np).astype(self.dtype)
2389+
2390+
def argument_error():
2391+
self.inplace_api_processing(x, 2.0)
2392+
2393+
self.assertRaises(ValueError, argument_error)
2394+
23862395

23872396
@unittest.skipIf(
23882397
not paddle.base.core.is_compiled_with_cuda()
23892398
or not paddle.base.core.is_float16_supported(paddle.CUDAPlace(0)),
23902399
"core is not compiled with CUDA and not support the float16",
23912400
)
2392-
class TestDygraphInplaceResizeP16(TestDygraphInplaceResize):
2401+
class TestDygraphInplaceResizeFP16(TestDygraphInplaceResize):
23932402
def setUp(self):
23942403
self.init_data()
23952404
self.places = [paddle.CUDAPlace(0)]

0 commit comments

Comments
 (0)