Commit ed20998
authored
use TF's built-in method to get numpy dtype (#1035)
* 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.81 parent 602760e commit ed20998
3 files changed
+4
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 45 | | |
52 | 46 | | |
53 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
121 | 120 | | |
122 | 121 | | |
123 | 122 | | |
124 | | - | |
125 | | - | |
| 123 | + | |
| 124 | + | |
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
174 | 173 | | |
175 | 174 | | |
176 | 175 | | |
177 | | - | |
| 176 | + | |
178 | 177 | | |
179 | 178 | | |
180 | 179 | | |
| |||
262 | 261 | | |
263 | 262 | | |
264 | 263 | | |
265 | | - | |
| 264 | + | |
266 | 265 | | |
267 | 266 | | |
268 | 267 | | |
| |||
0 commit comments