aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/ops/math_grad.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/core/ops/math_grad.cc')
-rw-r--r--tensorflow/core/ops/math_grad.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/tensorflow/core/ops/math_grad.cc b/tensorflow/core/ops/math_grad.cc
index 783d292389..57499a6f1d 100644
--- a/tensorflow/core/ops/math_grad.cc
+++ b/tensorflow/core/ops/math_grad.cc
@@ -495,6 +495,19 @@ Status RealDivGrad(const AttrSlice& attrs, FunctionDef* g) {
}
REGISTER_OP_GRADIENT("RealDiv", RealDivGrad);
+Status UnsafeDivGrad(const AttrSlice& attrs, FunctionDef* g) {
+ // clang-format off
+ return GradForBinaryCwise(g, {
+ {{"gx"}, "UnsafeDiv", {"dz", "y"}},
+ {{"nx"}, "Neg", {"x"}, {}, {"dz"}},
+ {{"y2"}, "Square", {"y"}, {}, {"dz"}},
+ {{"nx_y2"}, "UnsafeDiv", {"nx", "y2"}},
+ {{"gy"}, "Mul", {"dz", "nx_y2"}}, // dz * (- x / y^2)
+ });
+ // clang-format on
+}
+REGISTER_OP_GRADIENT("UnsafeDiv", UnsafeDivGrad);
+
Status PowGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
std::vector<FDH::Node> nodes = {