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

Function Erfc

tensorflow/compiler/xla/client/lib/math.cc:278–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278XlaOp Erfc(XlaOp x) {
279 auto& b = *x.builder();
280 return b.ReportErrorOrReturn([&]() -> StatusOr<XlaOp> {
281 TF_RETURN_IF_ERROR(EnsureOperandIsRealFp("Erfc", x));
282 TF_ASSIGN_OR_RETURN(auto shape, b.GetShape(x));
283 // erfc(x) =
284 // erfc_impl(x) if x > 1
285 // 1 - erf_impl(x) otherwise
286 if (shape.element_type() == F64) {
287 return Select(Gt(Abs(x), ScalarLike(x, 1)), ErfcImpl64(x),
288 ScalarLike(x, 1) - ErfImpl64(x));
289 }
290 // Erf(c)Impl don't have enough precision when run with bf16 intermediates
291 // (not surprising!), so upcast to f32 in this case.
292 return DoWithUpcastToF32(x, {BF16, F16}, [](XlaOp x) {
293 return Select(Gt(Abs(x), ScalarLike(x, 1)), ErfcImpl32(x),
294 ScalarLike(x, 1) - ErfImpl32(x));
295 });
296 });
297}
298
299XlaOp Erf(XlaOp x) {
300 auto& b = *x.builder();

Callers 3

XLA_TEST_FFunction · 0.70
unary_ops.ccFile · 0.50
TEST_FFunction · 0.50

Calls 13

EnsureOperandIsRealFpFunction · 0.85
ScalarLikeFunction · 0.85
ErfcImpl64Function · 0.85
ErfImpl64Function · 0.85
DoWithUpcastToF32Function · 0.85
ErfcImpl32Function · 0.85
ErfImpl32Function · 0.85
ReportErrorOrReturnMethod · 0.80
SelectFunction · 0.50
GtFunction · 0.50
AbsFunction · 0.50
builderMethod · 0.45

Tested by 2

XLA_TEST_FFunction · 0.56
TEST_FFunction · 0.40