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 API adaptor No.50、57、67】Migrate some ops into pir #58466

Merged
merged 3 commits into from
Oct 31, 2023

Conversation

longranger2
Copy link
Contributor

@longranger2 longranger2 commented Oct 29, 2023

PR types

Others

PR changes

APIs

Description

PIR API 推全升级
将如下算子迁移升级至 pir,并更新单测

  • cumprod(6/7):总计 7 个单测,打开6个单测,1个单测继承自unittest.TestCase没有覆盖到

  • digamma(4/5):总计 5 个单测,打开4个单测,1个单测继承自unittest.TestCase没有覆盖到

  • erfinv(5/5)

  • 新IR Python API适配升级 #58067

@paddle-bot
Copy link

paddle-bot bot commented Oct 29, 2023

你的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.

@paddle-bot paddle-bot bot added the contributor External developers label Oct 29, 2023
Aurelius84
Aurelius84 previously approved these changes Oct 30, 2023
Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

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

LGTM

@Aurelius84
Copy link
Contributor

cumprod 的BF16单测有一些问题,可以把报错日志在此PR下comment记录下,先不开启,我们内部来看是什么问题

@0x45f
Copy link
Contributor

0x45f commented Oct 30, 2023

有一些单测在本pr中没有打开,方便在pr描述中说明一下没有打开的原因嘛~

@longranger2
Copy link
Contributor Author

cumprod 的BF16单测有一些问题,可以把报错日志在此PR下comment记录下,先不开启,我们内部来看是什么问题

image

@longranger2
Copy link
Contributor Author

longranger2 commented Oct 30, 2023

有一些单测在本pr中没有打开,方便在pr描述中说明一下没有打开的原因嘛~

@0x45f 修改好了~

@0x45f
Copy link
Contributor

0x45f commented Oct 31, 2023

test_cumprod_op.py这个文件的代码风格检查挂了,麻烦本地pre-commit后再提交下~

@longranger2
Copy link
Contributor Author

test_cumprod_op.py这个文件的代码风格检查挂了,麻烦本地pre-commit后再提交下~

done

@0x45f
Copy link
Contributor

0x45f commented Oct 31, 2023

有一些单测在本pr中没有打开,方便在pr描述中说明一下没有打开的原因嘛~

@0x45f 修改好了~

继承自unittest.TestCase的单测为什么没有打开呢?是打开之后会报错吗?

@longranger2
Copy link
Contributor Author

有一些单测在本pr中没有打开,方便在pr描述中说明一下没有打开的原因嘛~

@0x45f 修改好了~

继承自unittest.TestCase的单测为什么没有打开呢?是打开之后会报错吗?

好问题,这种应该怎么打开呢?我看上期任务的PR模板也是这么写的

class TestCumprodAPI(unittest.TestCase):
    def init_dtype(self):
        self.dtype = 'float64'
        self.shape = [2, 3, 10, 10]

    def setUp(self):
        paddle.enable_static()
        self.init_dtype()
        self.x = (np.random.rand(2, 3, 10, 10) + 0.5).astype(self.dtype)
        self.place = [paddle.CPUPlace()]
        if core.is_compiled_with_cuda():
            self.place.append(paddle.CUDAPlace(0))

    # test static graph api.
    def test_static_api(self):
        paddle.enable_static()

        def run(place):
            with paddle.static.program_guard(paddle.static.Program()):
                x = paddle.static.data('X', self.shape, dtype=self.dtype)
                out = paddle.cumprod(x, -2)
                exe = paddle.static.Executor(place)
                res = exe.run(feed={'X': self.x}, fetch_list=[out])
            out_ref = np.cumprod(self.x, -2)

            for r in res:
                np.testing.assert_allclose(out_ref, r, rtol=1e-05)

        for place in self.place:
            run(place)

    # test dynamic graph api.
    def test_dygraph_api(self):
        def run(place):
            paddle.disable_static(place)
            x = paddle.to_tensor(self.x)
            out = paddle.cumprod(x, 1)
            out_ref = np.cumprod(self.x, 1)
            np.testing.assert_allclose(out_ref, out.numpy(), rtol=1e-05)
            paddle.enable_static()

        for place in self.place:
            run(place)

@0x45f
Copy link
Contributor

0x45f commented Oct 31, 2023

有一些单测在本pr中没有打开,方便在pr描述中说明一下没有打开的原因嘛~

@0x45f 修改好了~

继承自unittest.TestCase的单测为什么没有打开呢?是打开之后会报错吗?

好问题,这种应该怎么打开呢?我看上期任务的PR模板也是这么写的

class TestCumprodAPI(unittest.TestCase):
    def init_dtype(self):
        self.dtype = 'float64'
        self.shape = [2, 3, 10, 10]

    def setUp(self):
        paddle.enable_static()
        self.init_dtype()
        self.x = (np.random.rand(2, 3, 10, 10) + 0.5).astype(self.dtype)
        self.place = [paddle.CPUPlace()]
        if core.is_compiled_with_cuda():
            self.place.append(paddle.CUDAPlace(0))

    # test static graph api.
    def test_static_api(self):
        paddle.enable_static()

        def run(place):
            with paddle.static.program_guard(paddle.static.Program()):
                x = paddle.static.data('X', self.shape, dtype=self.dtype)
                out = paddle.cumprod(x, -2)
                exe = paddle.static.Executor(place)
                res = exe.run(feed={'X': self.x}, fetch_list=[out])
            out_ref = np.cumprod(self.x, -2)

            for r in res:
                np.testing.assert_allclose(out_ref, r, rtol=1e-05)

        for place in self.place:
            run(place)

    # test dynamic graph api.
    def test_dygraph_api(self):
        def run(place):
            paddle.disable_static(place)
            x = paddle.to_tensor(self.x)
            out = paddle.cumprod(x, 1)
            out_ref = np.cumprod(self.x, 1)
            np.testing.assert_allclose(out_ref, out.numpy(), rtol=1e-05)
            paddle.enable_static()

        for place in self.place:
            run(place)

#58067 本期任务的描述《四、单测验证》部分有提到可以使用装饰器打开这类单测。我先合入这个PR了,可以另提一个PR打开继承自TestCase的单测~

Copy link
Contributor

@0x45f 0x45f left a comment

Choose a reason for hiding this comment

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

LGTM

@0x45f 0x45f merged commit afe6715 into PaddlePaddle:develop Oct 31, 2023
28 checks passed
@longranger2
Copy link
Contributor Author

好的,我晚上修改下~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants