| 90 | } |
| 91 | |
| 92 | bool IsPositive(const HloInstruction* hlo, |
| 93 | const AlgebraicSimplifierOptions& options) { |
| 94 | // Utility only handles real types. |
| 95 | if (IsAnyOperandComplex(hlo)) { |
| 96 | return false; |
| 97 | } |
| 98 | switch (hlo->opcode()) { |
| 99 | case HloOpcode::kGetTupleElement: { |
| 100 | const HloInstruction* gte_operand = hlo->operand(0); |
| 101 | switch (gte_operand->opcode()) { |
| 102 | case HloOpcode::kCustomCall: { |
| 103 | const auto& target = gte_operand->custom_call_target(); |
| 104 | return target == |
| 105 | options.get_cudnn_batchnorm_forward_training_metadata() && |
| 106 | hlo->tuple_index() == 2; |
| 107 | } |
| 108 | default: |
| 109 | return false; |
| 110 | } |
| 111 | } |
| 112 | case HloOpcode::kPower: |
| 113 | case HloOpcode::kAbs: |
| 114 | case HloOpcode::kRsqrt: |
| 115 | case HloOpcode::kSqrt: |
| 116 | return IsPositive(hlo->operand(0), options); |
| 117 | |
| 118 | case HloOpcode::kMultiply: { |
| 119 | return hlo->operand(0) == hlo->operand(1) && |
| 120 | IsPositive(hlo->operand(0), options); |
| 121 | } |
| 122 | default: |
| 123 | return false; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | bool IsNonNegative(const HloInstruction* hlo, |
| 128 | const AlgebraicSimplifierOptions& options) { |
no test coverage detected