MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / IsPositive

Function IsPositive

tensorflow/compiler/xla/service/algebraic_simplifier.cc:92–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92bool 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
127bool IsNonNegative(const HloInstruction* hlo,
128 const AlgebraicSimplifierOptions& options) {

Callers 3

IsNonNegativeFunction · 0.85
HandleMultiplyMethod · 0.85
HandleRsqrtMethod · 0.85

Calls 4

IsAnyOperandComplexFunction · 0.85
opcodeMethod · 0.80
operandMethod · 0.45
tuple_indexMethod · 0.45

Tested by

no test coverage detected