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

Fix bug in transfer.py #1246

Merged
merged 1 commit into from
Nov 4, 2021
Merged

Fix bug in transfer.py #1246

merged 1 commit into from
Nov 4, 2021

Conversation

ZhengdQin
Copy link
Contributor

fix the np.frombuffer in dp transfer

fix the np.frombuffer in dp transfer
@codecov-commenter
Copy link

codecov-commenter commented Oct 27, 2021

Codecov Report

Merging #1246 (84278fc) into devel (1a8fd73) will decrease coverage by 0.00%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            devel    #1246      +/-   ##
==========================================
- Coverage   75.99%   75.98%   -0.01%     
==========================================
  Files          91       91              
  Lines        7389     7391       +2     
==========================================
+ Hits         5615     5616       +1     
- Misses       1774     1775       +1     
Impacted Files Coverage Δ
deepmd/entrypoints/transfer.py 72.11% <40.00%> (-0.44%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a8fd73...84278fc. Read the comment docs.

Copy link
Member

@amcadmus amcadmus left a comment

Choose a reason for hiding this comment

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

Could you add an example to explain how to trigger the bug, what is the expected behavior and what is the actual behavior?
Thanks!

@ZhengdQin
Copy link
Contributor Author

fix the np.frombuffer in dp transfer, the point is explained as follows:
Interpret a buffer as a 1-dimensional array, which type is the given data_dtype, which means if the type is float32, the data in the buffer will be converted to float32, no matter what the original data type is. Let's see an example:
#===========================
temp1 = np.array([1.2, 4.5], dtype=np.float64)

temp1
Out[3]: array([1.2, 4.5])

temp2 = np.frombuffer(temp1, dtype=np.float32)

temp2
Out[5]:
array([4.172325e-08, 1.900000e+00, 0.000000e+00, 2.281250e+00],
dtype=float32)
#===========================
If we do not load the data with the old type, the loaded tensor values are wrong.

@wanghan-iapcm wanghan-iapcm changed the title Update transfer.py Fix bug in transfer.py Nov 4, 2021
@wanghan-iapcm wanghan-iapcm merged commit 4e15b0d into deepmodeling:devel Nov 4, 2021
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.

None yet

5 participants