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

Method Compile

tensorflow/compiler/tf2xla/kernels/elu_op.cc:62–71  ·  view source on GitHub ↗

Return the lhs (incoming gradient) if the rhs (input feature) > 0, otherwise return lhs * (1 + rhs).

Source from the content-addressed store, hash-verified

60 // Return the lhs (incoming gradient) if the rhs (input feature) > 0,
61 // otherwise return lhs * (1 + rhs).
62 void Compile(XlaOpKernelContext* ctx) override {
63 xla::XlaBuilder* b = ctx->builder();
64 const auto zero = XlaHelpers::Zero(b, input_type(0));
65 const auto one = XlaHelpers::One(b, input_type(0));
66 const auto grad = ctx->Input(0);
67 const auto activation = ctx->Input(1);
68 const auto exp_grad = xla::Mul(grad, xla::Add(activation, one));
69 const auto pred = xla::Gt(activation, zero);
70 ctx->SetOutput(0, xla::Select(pred, grad, exp_grad));
71 }
72};
73
74REGISTER_XLA_OP(Name("Elu"), EluOp);

Callers

nothing calls this directly

Calls 9

ZeroFunction · 0.50
OneFunction · 0.50
MulFunction · 0.50
AddClass · 0.50
GtClass · 0.50
SelectFunction · 0.50
builderMethod · 0.45
InputMethod · 0.45
SetOutputMethod · 0.45

Tested by

no test coverage detected