GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-90751: memoryview now supports half-float by corona10 · Pull Request #96738 · python/cpython

Conversation

@corona10

@corona10 corona10 commented Sep 10, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

With patch


Python 3.12.0a0 (heads/gh-90751:ea5e2db2fa, Sep 10 2022, 15:41:30) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> a = np.array([0.0, -1.5], np.float16())
>>> list(memoryview(a))
[0.0, -1.5]
>>> memoryview(a.tobytes()).cast('e').tolist()
[0.0, -1.5]
>>>
  • Issue: memoryview lacks support for half floats #90751

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added the awaiting core review label Sep 10, 2022
@corona10

corona10 commented Sep 10, 2022

Copy link
Copy Markdown
Member Author

(.oss) ➜  cpython git:(gh-90751) ✗ ./python.exe -m test test_memoryview -R 3:3
Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 1.24 Run tests sequentially
0:00:00 load avg: 1.24 [1/1] test_memoryview
beginning 6 repetitions
123456
......

== Tests result: SUCCESS ==

1 test OK.

Total duration: 660 ms
Tests result: SUCCESS
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10 corona10 changed the title gh-90751: memoryview supports half-float gh-90751: memoryview now supports half-float Sep 10, 2022
@corona10
corona10 requested review from mdickinson and pitrou September 10, 2022 15:46
@corona10
pythongh-90751: memoryview supports half-float
61e926c
@corona10
corona10 force-pushed the gh-90751 branch from 3d897a2 to 61e926c Compare September 10, 2022 15:55
pitrou
pitrou requested changes Sep 10, 2022
View reviewed changes

@pitrou pitrou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thank you @corona10 .
Can you also add half-float to the generic tests in test_buffer.py?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_memoryview.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting changes and removed awaiting core review labels Sep 10, 2022
@bedevere-bot

bedevere-bot commented Sep 10, 2022

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10

corona10 commented Sep 10, 2022

Copy link
Copy Markdown
Member Author

@pitrou

Can you also add half-float to the generic tests in test_buffer.py?

Hmm, would you like to recommend the proper place?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
Address code review
2fd17a8
@pitrou

pitrou commented Sep 10, 2022

Copy link
Copy Markdown
Member

@corona10 You can use this patch:
https://gist.github.com/pitrou/266079854bae1873d771aed14ca8fefa

but you'll see that it triggers some "RuntimeError: memoryview: internal error in richcompare" exceptions.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

corona10 added 2 commits September 11, 2022 01:49
@corona10
Add test
9e615fd
@corona10
Add Antoine Pitrou as author too.
8bc8754
@corona10

corona10 commented Sep 10, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Thanks, I implemented unpack_cmp for half-float to pass your suggestion.
Now it passed all test suites :)


➜  cpython git:(gh-90751) ✗ ./python.exe -m test test_buffer -R 3:3
Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 2.45 Run tests sequentially
0:00:00 load avg: 2.45 [1/1] test_buffer
beginning 6 repetitions
123456
......
test_buffer passed in 38.4 sec

== Tests result: SUCCESS ==

1 test OK.

Total duration: 38.4 sec
Tests result: SUCCESS
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
Update whatsnew
107bdd2
@pitrou

pitrou commented Sep 10, 2022

Copy link
Copy Markdown
Member

With Numpy installed I get errors, will push a fix.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pitrou added 2 commits September 10, 2022 19:17
@pitrou
Fix half-float memoryview comparison
343441d
@pitrou
Merge branch 'pythongh-90751' of https://github.com/corona10/cpython …
abf2050
…into pythongh-90751
pitrou
pitrou approved these changes Sep 10, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting changes labels Sep 10, 2022
pitrou
pitrou reviewed Sep 10, 2022
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pitrou
Update Doc/whatsnew/3.12.rst
a1ce9d4
@corona10

corona10 commented Sep 10, 2022

Copy link
Copy Markdown
Member Author

With Numpy installed I get errors, will push a fix.

Thanks

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pitrou
pitrou requested a review from gpshead September 10, 2022 17:20
@corona10

corona10 commented Sep 10, 2022

Copy link
Copy Markdown
Member Author

@pitrou
With numpy installation:


test_buffer leaked [1481, 1467, 1476] references, sum=4424
test_buffer failed (reference leak) in 53.9 sec
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
Replace deprecated method for numpy test
e8c1fed
@corona10

corona10 commented Sep 10, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Forget about #96738 (comment)
The leakage is not related to this PR, the main branch is leaked also.
(With NumPy only)


test_buffer leaked [1392, 1380, 1375] references, sum=4147
test_buffer failed (reference leak) in 50.1 sec

== Tests result: FAILURE ==

1 test failed:
    test_buffer

Total duration: 50.1 sec
Tests result: FAILURE
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10 corona10 mentioned this pull request Sep 10, 2022
Numpy deprecation warning in test_buffer.py #96742
Closed
mdickinson
mdickinson reviewed Sep 10, 2022
View reviewed changes
Comment thread Lib/test/test_buffer.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

mdickinson
mdickinson approved these changes Sep 10, 2022
View reviewed changes

@mdickinson mdickinson left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pitrou

pitrou commented Sep 10, 2022

Copy link
Copy Markdown
Member


The leakage is not related to this PR, the main branch is leaked also.
(With NumPy only)

Which Numpy version? I don't get this problem here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pitrou
pitrou merged commit 8d75a13 into python:main Sep 10, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Sep 10, 2022
@pitrou

pitrou commented Sep 10, 2022

Copy link
Copy Markdown
Member

Thanks a lot @corona10 !

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
corona10 deleted the gh-90751 branch September 11, 2022 01:11
@corona10

corona10 commented Sep 11, 2022

Copy link
Copy Markdown
Member Author

Which Numpy version? I don't get this problem here.

@pitrou

Python 3.12.0a0 (heads/gh-90751:e8c1fed38f, Sep 10 2022, 17:46:55) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'1.23.3'
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@imaolo imaolo mentioned this pull request Dec 8, 2023
Replace np.array() in Tensor.__init__() with get_mv() and np.frombuffer() tinygrad/tinygrad#2660
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pitrou pitrou pitrou approved these changes
@gpshead gpshead Awaiting requested review from gpshead
+1 more reviewer
@mdickinson mdickinson mdickinson approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@corona10 @bedevere-bot @pitrou @mdickinson
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.