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

Method HandleMaximum

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

Source from the content-addressed store, hash-verified

2132} // namespace
2133
2134Status AlgebraicSimplifierVisitor::HandleMaximum(HloInstruction* maximum) {
2135 HloInstruction *lhs, *rhs;
2136 CHECK(Match(maximum, m::Maximum(m::Op(&lhs), m::Op(&rhs))));
2137
2138 HloInstruction* clamp_upper_bound_bcast;
2139 HloInstruction* clamp_lower_bound_bcast;
2140 HloInstruction* to_clamp;
2141 if (Match(maximum, m::MaximumAnyOrder(
2142 m::Broadcast(&clamp_lower_bound_bcast,
2143 m::ConstantEffectiveScalar()),
2144 m::MinimumAnyOrder(
2145 m::Op(&to_clamp),
2146 m::Broadcast(&clamp_upper_bound_bcast,
2147 m::ConstantEffectiveScalar()))))) {
2148 TF_ASSIGN_OR_RETURN(auto clamp,
2149 MinMaxToClamp(clamp_lower_bound_bcast, to_clamp,
2150 clamp_upper_bound_bcast));
2151 if (clamp) {
2152 return ReplaceWithNewInstruction(maximum, std::move(clamp));
2153 }
2154 }
2155
2156 HloInstruction* clamp_lower_bound;
2157 HloInstruction* clamp_upper_bound;
2158 HloInstruction* max_operand;
2159 HloInstruction* clamp;
2160 if (Match(maximum,
2161 m::MaximumAnyOrder(
2162 m::Op(&max_operand),
2163 m::Clamp(&clamp, m::Op(&clamp_lower_bound), m::Op(&to_clamp),
2164 m::Op(&clamp_upper_bound))))) {
2165 if (max_operand == clamp_lower_bound &&
2166 ReplaceInstructionIfSameShape(maximum, clamp)) {
2167 return Status::OK();
2168 }
2169 }
2170
2171 return Status::OK();
2172}
2173
2174Status AlgebraicSimplifierVisitor::HandleMinimum(HloInstruction* minimum) {
2175 HloInstruction *lhs, *rhs;

Callers 1

VisitMethod · 0.45

Calls 6

BroadcastFunction · 0.85
ConstantEffectiveScalarFunction · 0.85
MatchFunction · 0.70
OpFunction · 0.70
MaximumClass · 0.50
ClampFunction · 0.50

Tested by

no test coverage detected