Skip to content

fix numpy2.1 bug when python >=3.10 #67700

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

Merged
merged 5 commits into from
Aug 30, 2024
Merged

Conversation

risemeup1
Copy link
Contributor

@risemeup1 risemeup1 commented Aug 25, 2024

PR Category

Execute Infrastructure

PR Types

Others

Description

Fix the bug in PaddlePaddle under Python 3.10 and NumPy 2.1.

image
  • For any __array__ method on a non-NumPy array-like object, dtype=None and copy=None keywords must be added to the signature - this will work with older NumPy versions as well (although older numpy versions will never pass in copy keyword). If the keywords are added to the __array__ signature, then for:

    copy=True and any dtype value always return a new copy,

    copy=None create a copy if required (for example by dtype),

    copy=False a copy must never be made. If a copy is needed to return a numpy array or satisfy dtype, then raise an exception (ValueError).

  • Restricting numpy to version 1.21 or above is to fix the bug of not finding the ‘NDArray’ attribute when using the numpy.typing module.

To do:
Modify the logic in TensorToPyArray(self) according to the dtype and copy parameters.
pcard-67164

Copy link

paddle-bot bot commented Aug 25, 2024

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

@risemeup1 risemeup1 force-pushed the copy_name_analysisi.h_to_whl branch from a8e4835 to 82a4f42 Compare August 28, 2024 06:52
@risemeup1 risemeup1 changed the title copy_name_analysis.h_to_whl fix numpy2.1 bug when python >=3.10 Aug 28, 2024
jzhang533
jzhang533 previously approved these changes Aug 28, 2024
Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

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

SigureMo
SigureMo previously approved these changes Aug 29, 2024
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@xuxinyi389
Copy link
Contributor

LGTM

jzhang533
jzhang533 previously approved these changes Aug 29, 2024
Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

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

LGTM

SigureMo
SigureMo previously approved these changes Aug 29, 2024
@SigureMo SigureMo dismissed stale reviews from jzhang533 and themself via 573b359 August 29, 2024 12:27
@jzhang533 jzhang533 merged commit 3fd9bda into develop Aug 30, 2024
29 checks passed
@SigureMo SigureMo deleted the copy_name_analysisi.h_to_whl branch August 30, 2024 02:18
jzhang533 pushed a commit to jzhang533/Paddle that referenced this pull request Aug 30, 2024
* fix

* fix

* fix

* fix

* fix codestyle

---------

Co-authored-by: SigureMo <sigure.qaq@gmail.com>
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.

4 participants