Skip to content

Commit

Permalink
Add uint32 and uint64 support for PopulationCount
Browse files Browse the repository at this point in the history
PopulationCount is part of the bitwise operations (BitwiseAnd/Or/Xor/etc)
though unlike other bitwise operatios, PopulationCount does not
have uint32 and uint64 support.

This PR add uint32 and uint64 support and fixes 46676.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
  • Loading branch information
yongtang committed Jan 27, 2021
1 parent b904b76 commit 0118cff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tensorflow/core/kernels/population_count_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ TF_CALL_int8(REGISTER_POPULATION_COUNT);
TF_CALL_uint16(REGISTER_POPULATION_COUNT);
TF_CALL_int16(REGISTER_POPULATION_COUNT);
TF_CALL_int32(REGISTER_POPULATION_COUNT);
TF_CALL_uint32(REGISTER_POPULATION_COUNT);
TF_CALL_int64(REGISTER_POPULATION_COUNT);
TF_CALL_uint64(REGISTER_POPULATION_COUNT);

#undef REGISTER_POPULATION_COUNT

Expand All @@ -87,7 +89,9 @@ POPCNT(uint8, 8);
POPCNT(int16, 16);
POPCNT(uint16, 16);
POPCNT(int32, 32);
POPCNT(uint32, 32);
POPCNT(int64, 64);
POPCNT(uint64, 64);

#undef POPCNT

Expand Down
3 changes: 2 additions & 1 deletion tensorflow/python/ops/bitwise_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def testBinaryOps(self):
def testPopulationCountOp(self):
dtype_list = [dtypes.int8, dtypes.int16,
dtypes.int32, dtypes.int64,
dtypes.uint8, dtypes.uint16]
dtypes.uint8, dtypes.uint16,
dtypes.uint32, dtypes.uint64]
raw_inputs = [0, 1, -1, 3, -3, 5, -5, 14, -14,
127, 128, 255, 256, 65535, 65536,
2**31 - 1, 2**31, 2**32 - 1, 2**32, -2**32 + 1, -2**32,
Expand Down

0 comments on commit 0118cff

Please sign in to comment.