message: [XLA] Add support for int8/uint8 CLZ/PopCount to the evaluator
diff: @@ -2409,39 +2409,23 @@ class HloEvaluatorTypedVisitor : public DfsHloVisitorWithDefault {
  }
  // Enable CLZ only for int32, uint32, int64 and uint64.
  - template <
  - typename NativeT,
  - typename std::enable_if<
  - (std::is_floating_point<NativeT>::value ||
  - std::is_integral<NativeT>::value || is_complex_t<NativeT>::value) &&
  - !(std::is_same<NativeT, uint32>::value ||
  - std::is_same<NativeT, int32>::value ||
  - std::is_same<NativeT, int64>::value ||
  - std::is_same<NativeT, uint64>::value)>::type* = nullptr>
  - Status HandleClz(HloInstruction* clz) {
  - return UnsupportedTypeError(clz);
  - }
  -
  template <typename NativeT,
  typename std::enable_if<
  - std::is_same<NativeT, uint32>::value ||
  - std::is_same<NativeT, int32>::value>::type* = nullptr>
  + (!std::is_integral<NativeT>::value ||
  + std::is_same<NativeT, bool>::value)>::type* = nullptr>
  Status HandleClz(HloInstruction* clz) {
  - TF_ASSIGN_OR_RETURN(parent_->evaluated_[clz],
  - ElementWiseUnaryOp(clz, [](ElementwiseT elem_operand) {
  - return 31 - tensorflow::Log2Floor(elem_operand);
  - }));
  - return Status::OK();
  + return UnsupportedTypeError(clz);
  }
  template <typename NativeT,
  typename std::enable_if<
  - std::is_same<NativeT, uint64>::value ||
  - std::is_same<NativeT, int64>::value>::type* = nullptr>
  + std::is_integral<NativeT>::value &&
  + !std::is_same<NativeT, bool>::value>::type* = nullptr>
  Status HandleClz(HloInstruction* clz) {
  TF_ASSIGN_OR_RETURN(parent_->evaluated_[clz],
  ElementWiseUnaryOp(clz, [](ElementwiseT elem_operand) {
  - return 63 - tensorflow::Log2Floor64(elem_operand);
  + return (sizeof(elem_operand) * CHAR_BIT - 1) -
  + tensorflow::Log2Floor64(elem_operand);
  }));
  return Status::OK();
  }
  @@ -2450,23 +2434,18 @@ class HloEvaluatorTypedVisitor : public DfsHloVisitorWithDefault {
  return HandleClz<ElementwiseT>(clz);
  }
  - // Enable Popcnt only for int32, uint32, int64 and uint64.
  template <typename NativeT,
  typename std::enable_if<
  - !(std::is_same<NativeT, uint32>::value ||
  - std::is_same<NativeT, int32>::value ||
  - std::is_same<NativeT, uint64>::value ||
  - std::is_same<NativeT, int64>::value)>::type* = nullptr>
  + (!std::is_integral<NativeT>::value ||
  + std::is_same<NativeT, bool>::value)>::type* = nullptr>
  Status HandlePopulationCount(HloInstruction* popcnt) {
  return UnsupportedTypeError(popcnt);
  }
  template <typename NativeT,
  typename std::enable_if<
  - std::is_same<NativeT, uint32>::value ||
  - std::is_same<NativeT, int32>::value ||
  - std::is_same<NativeT, uint64>::value ||
  - std::is_same<NativeT, int64>::value>::type* = nullptr>
  + std::is_integral<NativeT>::value &&
  + !std::is_same<NativeT, bool>::value>::type* = nullptr>
  Status HandlePopulationCount(HloInstruction* popcnt) {
  TF_ASSIGN_OR_RETURN(
  parent_->evaluated_[popcnt],
  