Add uint16 support for py_func
authorYong Tang <yong.tang.github@outlook.com>
Wed, 18 Apr 2018 01:17:06 +0000 (01:17 +0000)
committerYong Tang <yong.tang.github@outlook.com>
Wed, 18 Apr 2018 17:37:38 +0000 (17:37 +0000)
commit7ffbedee2d78fd9dc8e6d072858b0fada0d98a3e
tree200474883903d218d9c9404f94a3d1c2c9e594f2
parente1fa4112bb1cf40cec4f0ec3eb2c35321e69f20c
Add uint16 support for py_func

In tf most of the numeric data types are supported though uint16 support
is not:
```
$ python
>>> import tensorflow as tf
>>> def sum_func(x, y):
...   return x + y
...
>>> x = tf.constant(1, dtype=tf.uint16)
>>> y = tf.constant(2, dtype=tf.uint16)
>>> z = tf.py_func(sum_func, [x, y], tf.uint16)
>>> tf.Session().run(z)
...
...
tensorflow.python.framework.errors_impl.UnimplementedError: Unsupported numpy type 4
 [[Node: PyFunc = PyFunc[Tin=[DT_UINT16, DT_UINT16], Tout=[DT_UINT16], token="pyfunc_0", _device="/job:localhost/replica:0/task:0/device:CPU:0"](Const, Const_1)]]
...
```

The reason is that there is no conversion between numpy uint16 and tf.uint16.

This fix adds the support so that py_func could process tf.uint16 data types.

This fix also adds test cases for different data types with py_func to
increase the test coverage.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
tensorflow/python/lib/core/py_func.cc