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

Method HandleRsqrt

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

Source from the content-addressed store, hash-verified

3472}
3473
3474Status AlgebraicSimplifierVisitor::HandleRsqrt(HloInstruction* rsqrt) {
3475 VLOG(10) << "trying transform [rsqrt(Pow(A, -2)) => |A|] "
3476 << rsqrt->ToString();
3477 HloInstruction* rsqrt_operand = rsqrt->mutable_operand(0);
3478 if (rsqrt_operand->opcode() == HloOpcode::kPower &&
3479 IsAll(rsqrt_operand->operand(1), -2) &&
3480 IsPositive(rsqrt_operand, options_)) {
3481 return ReplaceWithNewInstruction(
3482 rsqrt, HloInstruction::CreateUnary(rsqrt->shape(), HloOpcode::kAbs,
3483 rsqrt_operand->mutable_operand(0)));
3484 }
3485
3486 VLOG(10) << "trying transform [rsqrt(Divide(1, A)) => sqrt(A)] "
3487 << rsqrt->ToString();
3488 if (rsqrt_operand->opcode() == HloOpcode::kDivide &&
3489 IsAll(rsqrt_operand->operand(0), 1) &&
3490 IsPositive(rsqrt_operand->operand(1), options_)) {
3491 return ReplaceWithNewInstruction(
3492 rsqrt, HloInstruction::CreateUnary(rsqrt->shape(), HloOpcode::kSqrt,
3493 rsqrt_operand->mutable_operand(1)));
3494 }
3495
3496 return Status::OK();
3497}
3498
3499Status AlgebraicSimplifierVisitor::HandleDynamicSlice(
3500 HloInstruction* dynamic_slice) {

Callers 1

VisitMethod · 0.45

Calls 7

IsPositiveFunction · 0.85
mutable_operandMethod · 0.80
opcodeMethod · 0.80
IsAllFunction · 0.70
ToStringMethod · 0.45
operandMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected