|
@@ -30,19 +30,19 @@ __all__ = [ |
|
|
"cos", |
|
|
"cos", |
|
|
"cosh", |
|
|
"cosh", |
|
|
"div", |
|
|
"div", |
|
|
"eq", |
|
|
|
|
|
|
|
|
"equal", |
|
|
"exp", |
|
|
"exp", |
|
|
"expm1", |
|
|
"expm1", |
|
|
"fast_tanh", |
|
|
"fast_tanh", |
|
|
"floor", |
|
|
"floor", |
|
|
"floor_div", |
|
|
"floor_div", |
|
|
"gt", |
|
|
|
|
|
"ge", |
|
|
|
|
|
|
|
|
"greater", |
|
|
|
|
|
"greater_equal", |
|
|
"hswish", |
|
|
"hswish", |
|
|
"hsigmoid", |
|
|
"hsigmoid", |
|
|
"left_shift", |
|
|
"left_shift", |
|
|
"lt", |
|
|
|
|
|
"le", |
|
|
|
|
|
|
|
|
"less", |
|
|
|
|
|
"less_equal", |
|
|
"log", |
|
|
"log", |
|
|
"log1p", |
|
|
"log1p", |
|
|
"logical_and", |
|
|
"logical_and", |
|
@@ -54,7 +54,7 @@ __all__ = [ |
|
|
"mod", |
|
|
"mod", |
|
|
"mul", |
|
|
"mul", |
|
|
"neg", |
|
|
"neg", |
|
|
"ne", |
|
|
|
|
|
|
|
|
"not_equal", |
|
|
"pow", |
|
|
"pow", |
|
|
"relu", |
|
|
"relu", |
|
|
"relu6", |
|
|
"relu6", |
|
@@ -102,7 +102,7 @@ def add(x, y): |
|
|
"""Element-wise `addition`. |
|
|
"""Element-wise `addition`. |
|
|
At least one operand should be tensor. |
|
|
At least one operand should be tensor. |
|
|
|
|
|
|
|
|
Same for sub/mul/div/floor_div/pow/mod/atan2/eq/ne/lt/le/gt/ge/maximum/minmium. |
|
|
|
|
|
|
|
|
Same for sub/mul/div/floor_div/pow/mod/atan2/equal/not_equal/less/less_equal/greater/greater_equal/maximum/minmium. |
|
|
|
|
|
|
|
|
:param x: input tensor. |
|
|
:param x: input tensor. |
|
|
:return: computed tensor. |
|
|
:return: computed tensor. |
|
@@ -442,7 +442,7 @@ def logical_xor(x, y): |
|
|
# comparison functions |
|
|
# comparison functions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def eq(x, y): |
|
|
|
|
|
|
|
|
def equal(x, y): |
|
|
"""Element-wise `(x == y)`. |
|
|
"""Element-wise `(x == y)`. |
|
|
|
|
|
|
|
|
:param x: input tensor 1. |
|
|
:param x: input tensor 1. |
|
@@ -459,7 +459,7 @@ def eq(x, y): |
|
|
|
|
|
|
|
|
x = tensor(np.arange(0, 6, dtype=np.float32).reshape(2, 3)) |
|
|
x = tensor(np.arange(0, 6, dtype=np.float32).reshape(2, 3)) |
|
|
y = tensor(np.arange(0, 6, dtype=np.float32).reshape(2, 3)) |
|
|
y = tensor(np.arange(0, 6, dtype=np.float32).reshape(2, 3)) |
|
|
out = F.eq(x, y) |
|
|
|
|
|
|
|
|
out = F.equal(x, y) |
|
|
print(out.numpy()) |
|
|
print(out.numpy()) |
|
|
|
|
|
|
|
|
Outputs: |
|
|
Outputs: |
|
@@ -473,27 +473,27 @@ def eq(x, y): |
|
|
return _elwise(x, y, mode="eq") |
|
|
return _elwise(x, y, mode="eq") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ne(x, y): |
|
|
|
|
|
|
|
|
def not_equal(x, y): |
|
|
"""Element-wise `(x != y)`.""" |
|
|
"""Element-wise `(x != y)`.""" |
|
|
return x != y |
|
|
return x != y |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def lt(x, y): |
|
|
|
|
|
|
|
|
def less(x, y): |
|
|
"""Element-wise `(x < y)`.""" |
|
|
"""Element-wise `(x < y)`.""" |
|
|
return _elwise(x, y, mode="lt") |
|
|
return _elwise(x, y, mode="lt") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def le(x, y): |
|
|
|
|
|
|
|
|
def less_equal(x, y): |
|
|
"""Element-wise `(x <= y)`.""" |
|
|
"""Element-wise `(x <= y)`.""" |
|
|
return _elwise(x, y, mode="leq") |
|
|
return _elwise(x, y, mode="leq") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gt(x, y): |
|
|
|
|
|
|
|
|
def greater(x, y): |
|
|
"""Element-wise `(x > y)`.""" |
|
|
"""Element-wise `(x > y)`.""" |
|
|
return _elwise(y, x, mode="lt") |
|
|
return _elwise(y, x, mode="lt") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ge(x, y): |
|
|
|
|
|
|
|
|
def greater_equal(x, y): |
|
|
"""Element-wise `(x >= y)`.""" |
|
|
"""Element-wise `(x >= y)`.""" |
|
|
return _elwise(y, x, mode="leq") |
|
|
return _elwise(y, x, mode="leq") |
|
|
|
|
|
|
|
|