|
|
@@ -255,13 +255,10 @@ def get_bprop_floordiv(self): |
|
|
@bprop_getters.register(P.FloorMod) |
|
|
@bprop_getters.register(P.FloorMod) |
|
|
def get_bprop_floormod(self): |
|
|
def get_bprop_floormod(self): |
|
|
"""Grad definition for `FloorMod` operation.""" |
|
|
"""Grad definition for `FloorMod` operation.""" |
|
|
div_op = P.FloorMod() |
|
|
|
|
|
neg = P.Neg() |
|
|
|
|
|
mul_op = P.Mul() |
|
|
|
|
|
|
|
|
|
|
|
def bprop(x, y, out, dout): |
|
|
def bprop(x, y, out, dout): |
|
|
bc_x = div_op(dout, y) |
|
|
|
|
|
bc_y = neg(mul_op(bc_x, out)) |
|
|
|
|
|
|
|
|
bc_x = dout |
|
|
|
|
|
bc_y = -dout * (x // y) |
|
|
return binop_grad_common(x, y, bc_x, bc_y) |
|
|
return binop_grad_common(x, y, bc_x, bc_y) |
|
|
return bprop |
|
|
return bprop |
|
|
|
|
|
|
|
|
@@ -412,6 +409,7 @@ def get_bprop_reducesum(self): |
|
|
def get_bprop_cumsum(self): |
|
|
def get_bprop_cumsum(self): |
|
|
"""Grad definition for `CumSum` operation.""" |
|
|
"""Grad definition for `CumSum` operation.""" |
|
|
cumsum = P.CumSum(exclusive=self.exclusive, reverse=not self.reverse) |
|
|
cumsum = P.CumSum(exclusive=self.exclusive, reverse=not self.reverse) |
|
|
|
|
|
|
|
|
def bprop(x, axis, out, dout): |
|
|
def bprop(x, axis, out, dout): |
|
|
return cumsum(dout, axis), zeros_like(axis) |
|
|
return cumsum(dout, axis), zeros_like(axis) |
|
|
return bprop |
|
|
return bprop |
|
|
@@ -787,6 +785,7 @@ def get_bprop_atan2(self): |
|
|
"""Generate bprop for Atan2""" |
|
|
"""Generate bprop for Atan2""" |
|
|
|
|
|
|
|
|
square = P.Square() |
|
|
square = P.Square() |
|
|
|
|
|
|
|
|
def bprop(x, y, out, dout): |
|
|
def bprop(x, y, out, dout): |
|
|
tmp = dout / (square(x) + square(y)) |
|
|
tmp = dout / (square(x) + square(y)) |
|
|
dx = tmp * y |
|
|
dx = tmp * y |
|
|
|