Skip to content

Conversation

@zhengshengning
Copy link
Contributor

@zhengshengning zhengshengning commented Nov 6, 2025

PR Category

Operator Mechanism

PR Types

New features

Description

将下面PR cherry-pick到 fleety_12
devPR:#75596
devPR:#75794
devPR:#76004

暂时删掉TestSetValueWithStrideError单测说明:
由于cherry-pick后,下面单测出现device参数未定义,这是因为需要前置兼容性适配的pr,为了不引入额外的麻烦,这里暂时去掉该单测。

@unittest.skipIf(
    not (core.is_compiled_with_cuda() or is_custom_device()),
    "core is not compiled with CUDA",
)
class TestSetValueWithStrideError(unittest.TestCase):
    def test_same_place(self):
        x = paddle.rand([5, 10], device=paddle.CUDAPlace(0))
        y = paddle.rand([10, 5], device=paddle.CUDAPlace(0))
        y.transpose_([1, 0])
        x.set_value(y)
        assert x.is_contiguous()

    def test_different_place1(self):
        # src place != dst place && src is not contiguous
        x = paddle.rand([5, 10], device=paddle.CUDAPlace(0))
        y = paddle.rand([10, 5], device=paddle.CPUPlace())
        y.transpose_([1, 0])
        x.set_value(y)
        assert not x.is_contiguous()

    def test_different_place2(self):
        # src place != dst place && dst is not contiguous
        with self.assertRaises(SystemError):
            x = paddle.ones([5, 4], device=paddle.CUDAPlace(0))
            x.transpose_([1, 0])
            y = paddle.rand([4, 2], device=paddle.CPUPlace())
            assert not x.is_contiguous()

            x[:, 1:3].set_value(y)

@paddle-bot
Copy link

paddle-bot bot commented Nov 6, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants