Skip to content

use TF's built-in method to get numpy dtype#1035

Merged
amcadmus merged 2 commits intodeepmodeling:develfrom
njzjz:PRECISION_MAPPING
Aug 26, 2021
Merged

use TF's built-in method to get numpy dtype#1035
amcadmus merged 2 commits intodeepmodeling:develfrom
njzjz:PRECISION_MAPPING

Conversation

@njzjz
Copy link
Member

@njzjz njzjz commented Aug 25, 2021

I got a way to get the numpy type from a int. Take an example

>>> tf.as_dtype(19).as_numpy_dtype
<class 'numpy.float16'>

PRECISION_MAPPING is not used any more as the int itself is not a public API, and can be safely removed.

By the way, it also supports str

>>> tf.as_dtype("float16")
tf.float16

I got a way to get the numpy type from a int. Take an example
```py
>>> tf.dtypes.as_dtype(19).as_numpy_dtype
<class 'numpy.float16'>
```

`PRECISION_MAPPING` is not used any more, as it's actually not a public API.

By the way, it also supports `str`
```py
>>> tf.dtypes.as_dtype("float16")
tf.float16
```
@njzjz njzjz requested a review from denghuilu August 25, 2021 21:27
@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2021

Codecov Report

Merging #1035 (17e0866) into devel (0004484) will increase coverage by 10.78%.
The diff coverage is 75.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##            devel    #1035       +/-   ##
===========================================
+ Coverage   64.28%   75.07%   +10.78%     
===========================================
  Files           5       87       +82     
  Lines          14     6945     +6931     
===========================================
+ Hits            9     5214     +5205     
- Misses          5     1731     +1726     
Impacted Files Coverage Δ
deepmd/common.py 83.33% <ø> (ø)
deepmd/utils/graph.py 74.11% <50.00%> (ø)
deepmd/entrypoints/transfer.py 72.54% <100.00%> (ø)
deepmd/descriptor/se_a_ef.py 54.83% <0.00%> (ø)
source/op/_prod_virial_grad.py 100.00% <0.00%> (ø)
deepmd/env.py 74.44% <0.00%> (ø)
deepmd/utils/pair_tab.py 100.00% <0.00%> (ø)
deepmd/utils/errors.py 100.00% <0.00%> (ø)
deepmd/infer/deep_eval.py 96.87% <0.00%> (ø)
deepmd/utils/neighbor_stat.py 93.75% <0.00%> (ø)
... and 75 more

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 0004484...17e0866. Read the comment docs.

Copy link
Member

@denghuilu denghuilu left a comment

Choose a reason for hiding this comment

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

LGTM

@amcadmus amcadmus merged commit ed20998 into deepmodeling:devel Aug 26, 2021
gzq942560379 pushed a commit to HPC-AI-Team/deepmd-kit that referenced this pull request Sep 2, 2021
* use TF's built-in method to get numpy dtype

I got a way to get the numpy type from a int. Take an example
```py
>>> tf.dtypes.as_dtype(19).as_numpy_dtype
<class 'numpy.float16'>
```

`PRECISION_MAPPING` is not used any more, as it's actually not a public API.

By the way, it also supports `str`
```py
>>> tf.dtypes.as_dtype("float16")
tf.float16
```

* sadly only `tf.as_dtype` is supported in TF 1.8
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