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.54-56】Migrate some ops into pir #58627

Merged
merged 8 commits into from
Nov 10, 2023

Conversation

longranger2
Copy link
Contributor

@longranger2 longranger2 commented Nov 2, 2023

PR types

Others

PR changes

APIs

Description

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

Copy link

paddle-bot bot commented Nov 2, 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 Nov 2, 2023
@longranger2 longranger2 changed the title migrate diagflat, diag_embed, diagonal into pir 【PIR API adaptor No.54-56】Migrate some ops into pir Nov 2, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Nov 3, 2023
@MarioLulab
Copy link
Contributor

现在 ci 挂在了 PR-CI-Py3,我看了一下挂的具体位置:TestDiagEmbedAPICase 的 test_case1 . 具体解决办法可以参考 #58259 (comment)
可能需要修改一下现在的单测~

@longranger2
Copy link
Contributor Author

现在 ci 挂在了 PR-CI-Py3,我看了一下挂的具体位置:TestDiagEmbedAPICase 的 test_case1 . 具体解决办法可以参考 #58259 (comment) 可能需要修改一下现在的单测~

对的,这个我看到了,晚点修复下~

@MarioLulab
Copy link
Contributor

现在 ci 挂在了 PR-CI-windows,具体位置是 test/legacy_test/test_diagflat.py 的 TestDiagFlatAPI::run_static。可能的解决思路是:这个函数里的静态图构建采用 static.program_guard 来管理,如下:

main = paddle.static.Program()
startup = paddle.static.Program()
with paddle.static.program_guard(main, startup):
    ....

np.testing.assert_allclose(res3, self.expected3, rtol=1e-05)
main = paddle.static.Program()
startup = paddle.static.Program()
with paddle.static.program_guard(main, startup):
Copy link
Contributor

Choose a reason for hiding this comment

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

目前挂在了 ci 阶段:PR-CI-Py3。原因应该是没有运行 startup program. 可以做如下修改:

  with paddle.static.program_guard(main, startup):
      exe = paddle.static.Executor(place)
      exe.run(startup)            # <----------------- 运行 startup program
      res0, res3 = exe.run(
          main,
          feed={"input": self.input_np, 'input2': self.input_np2},
          fetch_list=[result0, result3],
      )

Copy link
Contributor

Choose a reason for hiding this comment

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

我重新分析了一下 ci 挂的原因

x = paddle.static.data(name='input', shape=[10, 10], dtype='float64')
x2 = paddle.static.data(name='input2', shape=[20], dtype='float64')
result0 = paddle.diagflat(x)
result3 = paddle.diagflat(x2)

应该放在 with paddle.static.program_guard(main, startup): 下,比如:

main = paddle.static.Program()
startup = paddle.static.Program()
with paddle.static.program_guard(main, startup):
    x = paddle.static.data(name='input', shape=[10, 10], dtype='float64')
    x2 = paddle.static.data(name='input2', shape=[20], dtype='float64')
    result0 = paddle.diagflat(x)
    result3 = paddle.diagflat(x2)
    ...

这样 x, x2 等变量才会被构建在指定的 program ( main, startup ) 之中

Copy link
Contributor

@MarioLulab MarioLulab left a comment

Choose a reason for hiding this comment

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

ci 好像又挂了 🐶

np.testing.assert_allclose(res3, self.expected3, rtol=1e-05)
main = paddle.static.Program()
startup = paddle.static.Program()
with paddle.static.program_guard(main, startup):
Copy link
Contributor

Choose a reason for hiding this comment

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

我重新分析了一下 ci 挂的原因

x = paddle.static.data(name='input', shape=[10, 10], dtype='float64')
x2 = paddle.static.data(name='input2', shape=[20], dtype='float64')
result0 = paddle.diagflat(x)
result3 = paddle.diagflat(x2)

应该放在 with paddle.static.program_guard(main, startup): 下,比如:

main = paddle.static.Program()
startup = paddle.static.Program()
with paddle.static.program_guard(main, startup):
    x = paddle.static.data(name='input', shape=[10, 10], dtype='float64')
    x2 = paddle.static.data(name='input2', shape=[20], dtype='float64')
    result0 = paddle.diagflat(x)
    result3 = paddle.diagflat(x2)
    ...

这样 x, x2 等变量才会被构建在指定的 program ( main, startup ) 之中

Copy link
Contributor

@MarioLulab MarioLulab left a comment

Choose a reason for hiding this comment

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

great work ~
但还有一些小问题,辛苦修改一下吧。btw,这个 pr 描述貌似有误,erfinv 应该改为 diagonal?

Copy link
Contributor

Choose a reason for hiding this comment

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

这个文件下还遗漏了 test_fp16_with_gpu 这个静态图单测,麻烦大佬修改一下吧 ~ 😃

@longranger2
Copy link
Contributor Author

great work ~ 但还有一些小问题,辛苦修改一下吧。btw,这个 pr 描述貌似有误,erfinv 应该改为 diagonal?

done

Copy link
Contributor

@MarioLulab MarioLulab left a comment

Choose a reason for hiding this comment

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

LGTM

@YuanRisheng YuanRisheng merged commit 6397714 into PaddlePaddle:develop Nov 10, 2023
28 checks passed
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
* migrate diagflat, diag_embed, diagonal into pir

* fix bug

* fix bug

* fix bug

* Update test_diagflat.py

* Update test_diagflat.py

* fix bug

* Update test_diagflat.py
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
* migrate diagflat, diag_embed, diagonal into pir

* fix bug

* fix bug

* fix bug

* Update test_diagflat.py

* Update test_diagflat.py

* fix bug

* Update test_diagflat.py
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.

5 participants