tensorflow/compiler/xla/service/collective_ops_utils.cc
// Match the instruction to a reduction kind. We can represent and/or of pred as
// min/max. This works because pred is stored as an 8-bit int of value 0 or 1.
Match the instruction to a reduction kind. We can represent and/or of pred as
min/max. This works because pred is stored as an 8-bit int of value 0 or 1.
Match the instruction to a reduction kind . We can represent and / or of pred as min / max . This works because pred is stored as an 8 - bit int of value 0 or 1 .
absl::optional<ReductionKind> MatchReductionInstruction(
    const HloInstruction* hlo) {
  PrimitiveType type = hlo->shape().element_type();
  switch (hlo->opcode()) {
    case HloOpcode::kAdd:
      return ReductionKind::SUM;
    case HloOpcode::kMultiply:
      return ReductionKind::PRODUCT;
    case HloOpcode::kMinimum:
      return ReductionKind::MIN;
    case HloOpcode::kMaximum:
      return ReductionKind::MAX;
    case HloOpcode::kAnd:
      return type == PRED ? absl::optional<ReductionKind>(ReductionKind::MIN)
                          : absl::nullopt;
    case HloOpcode::kOr:
      return type == PRED ? absl::optional<ReductionKind>(ReductionKind::MAX)
                          : absl::nullopt;
    default:
      return absl::nullopt;
  }
}
absl :: optional < ReductionKind > MatchReductionInstruction ( const HloInstruction * hlo ) { PrimitiveType type = hlo -> shape ( ) . element_type ( ) ; switch ( hlo -> opcode ( ) ) { case HloOpcode :: kAdd : return ReductionKind :: SUM ; case HloOpcode :: kMultiply : return ReductionKind :: PRODUCT ; case HloOpcode :: kMinimum : return ReductionKind :: MIN ; case HloOpcode :: kMaximum : return ReductionKind :: MAX ; case HloOpcode :: kAnd : return type == PRED ? absl :: optional < ReductionKind > ( ReductionKind :: MIN ) : absl :: nullopt ; case HloOpcode :: kOr : return type == PRED ? absl :: optional < ReductionKind > ( ReductionKind :: MAX ) : absl :: nullopt ; default : return absl :: nullopt ; } }
Match the instruction to a reduction kind.
Match the instruction to a reduction kind .