Commit 049dfd5e authored by Yong Tang's avatar Yong Tang Committed by Derek Murray
Browse files

Add python built-in types support for `tf.as_dtype` (#17652)



* Add python built-in types support for `tf.as_dtype`

This fix tries to address the issue raised in 17641 where
it was not possible to use `tf.as_dtype(float)` the same
way as numpy `np.dtype(float)`.
This fix adds the built-in types support for `tf.as_dtype`,
so that it is possible to specify:
```
dtypes.as_dtype(float)   # dtypes.float64
dtypes.as_dtype(int)     # dtypes.int32
dtypes.as_dtype(long)    # dtypes.int64
dtypes.as_dtype(complex) # dtypes.complex128
dtypes.as_dtype(bool)    # dtypes.bool
```

This fix fixes 17641.

Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>

* Add test cases for built-in types support with `tf.as_dtype`

Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>

* Fix failed test cases with added built-in types support of tf.as_dtype

Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>

* Fix python 3 build

Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>

* Restrict the changes to float and bool based on review feedback

Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>
parent 6b0ec4ba
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment