Fix `tf.pow(x, y)` edge case with integer x and negative integer y (#15607)
* Fix `tf.pow(x, y)` edge case with integer x and negative integer y This fix tries to address the issue raised in 12156 where pow(x, y) hangs with an integer x and a negative value of y. This fix tries to throw out an error like numpy in this case: ``` >>> np.power([5, 5], [2, -2]) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Integers to negative integer powers are not allowed. ``` This fix adds error to the C++ functor like safe div/mod so that and InvalidArgument error could be triggered if any one of the values of y is negative. This fix fix 12156. This fix is also related to 9560. Signed-off-by:Yong Tang <yong.tang.github@outlook.com> Signed-off-by:
Yong Tang <yong.tang.github@outlook.com> * Add test cases for edge case of pow(x, y) where x is an integer and y is an negative integer Signed-off-by:
Yong Tang <yong.tang.github@outlook.com> * Add DataTypeIsSigned implementation And have a tight constraint on tf.pow error Signed-off-by:
Yong Tang <yong.tang.github@outlook.com> * Sanitize with clang-format -i --style=Google Signed-off-by:
Yong Tang <yong.tang.github@outlook.com>
Loading
Please sign in to comment