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

Function Erf

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

Source from the content-addressed store, hash-verified

297}
298
299XlaOp Erf(XlaOp x) {
300 auto& b = *x.builder();
301 return b.ReportErrorOrReturn([&]() -> StatusOr<XlaOp> {
302 TF_RETURN_IF_ERROR(EnsureOperandIsRealFp("Erf", x));
303 TF_ASSIGN_OR_RETURN(auto shape, b.GetShape(x));
304 // erf(x) =
305 // erf_impl(x) if x < 1
306 // 1 - erfc_impl(x) otherwise
307 if (shape.element_type() == F64) {
308 return Select(Lt(Abs(x), ScalarLike(x, 1)), ErfImpl64(x),
309 ScalarLike(x, 1) - ErfcImpl64(x));
310 }
311 // Erf(c)Impl don't have enough precision when run with bf16 intermediates
312 // (not surprising!), so upcast to f32 in this case.
313 return DoWithUpcastToF32(x, {BF16, F16}, [](XlaOp x) {
314 return Select(Lt(Abs(x), ScalarLike(x, 1)), ErfImpl32(x),
315 ScalarLike(x, 1) - ErfcImpl32(x));
316 });
317 });
318}
319
320namespace {
321

Callers 7

XLA_TEST_FFunction · 0.70
unary_ops.ccFile · 0.50
TESTFunction · 0.50
TEST_FFunction · 0.50
TestCWiseGradMethod · 0.50

Calls 13

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

Tested by 5

XLA_TEST_FFunction · 0.56
TESTFunction · 0.40
TEST_FFunction · 0.40
TestCWiseGradMethod · 0.40