1
0
Fork 0

Div on CPU (#58)

* Added Div on CPU

* Removed eps. value

* Fixed tabs
This commit is contained in:
gallanoe 2020-11-05 21:58:37 -08:00 committed by GitHub
parent cc605da36d
commit aea1069f63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,18 @@ class Mul(Function):
return y*grad_output, x*grad_output
register('mul', Mul)
class Div(Function):
@staticmethod
def forward(ctx, x, y):
ctx.save_for_backward(x, y)
return x / y
@staticmethod
def backward(ctx, grad_output):
x,y = ctx.saved_tensors
return grad_output / y, -x * grad_output / y**2
register('div', Div)
class Pow(Function):
@staticmethod
def forward(ctx, x, y):