From 78d21894415c4f616bf0b100211d6d21740f8790 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Fri, 9 Oct 2020 20:53:34 +0800 Subject: [PATCH] feat(mge): rename comparison operators to their full name GitOrigin-RevId: e503b038a1c1d57d5202d35f7d16f8f09f504a22 --- .../python/megengine/functional/elemwise.py | 28 +++++++++---------- .../python/megengine/functional/loss.py | 2 +- .../python/megengine/module/elemwise.py | 4 +-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/imperative/python/megengine/functional/elemwise.py b/imperative/python/megengine/functional/elemwise.py index 08436ac5..8757b776 100644 --- a/imperative/python/megengine/functional/elemwise.py +++ b/imperative/python/megengine/functional/elemwise.py @@ -30,19 +30,19 @@ __all__ = [ "cos", "cosh", "div", - "eq", + "equal", "exp", "expm1", "fast_tanh", "floor", "floor_div", - "gt", - "ge", + "greater", + "greater_equal", "hswish", "hsigmoid", "left_shift", - "lt", - "le", + "less", + "less_equal", "log", "log1p", "logical_and", @@ -54,7 +54,7 @@ __all__ = [ "mod", "mul", "neg", - "ne", + "not_equal", "pow", "relu", "relu6", @@ -102,7 +102,7 @@ def add(x, y): """Element-wise `addition`. 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. :return: computed tensor. @@ -442,7 +442,7 @@ def logical_xor(x, y): # comparison functions -def eq(x, y): +def equal(x, y): """Element-wise `(x == y)`. :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)) 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()) Outputs: @@ -473,27 +473,27 @@ def eq(x, y): return _elwise(x, y, mode="eq") -def ne(x, y): +def not_equal(x, y): """Element-wise `(x != y)`.""" return x != y -def lt(x, y): +def less(x, y): """Element-wise `(x < y)`.""" return _elwise(x, y, mode="lt") -def le(x, y): +def less_equal(x, y): """Element-wise `(x <= y)`.""" return _elwise(x, y, mode="leq") -def gt(x, y): +def greater(x, y): """Element-wise `(x > y)`.""" return _elwise(y, x, mode="lt") -def ge(x, y): +def greater_equal(x, y): """Element-wise `(x >= y)`.""" return _elwise(y, x, mode="leq") diff --git a/imperative/python/megengine/functional/loss.py b/imperative/python/megengine/functional/loss.py index 95f04fd5..dd69c6b2 100644 --- a/imperative/python/megengine/functional/loss.py +++ b/imperative/python/megengine/functional/loss.py @@ -10,7 +10,7 @@ import numpy as np from ..core.tensor.utils import make_shape_tuple from ..tensor import Tensor -from .elemwise import abs, eq, exp, log, maximum, pow, relu +from .elemwise import abs, equal, exp, log, maximum, pow, relu from .nn import indexing_one_hot from .tensor import where diff --git a/imperative/python/megengine/module/elemwise.py b/imperative/python/megengine/module/elemwise.py index 087563f5..3542359d 100644 --- a/imperative/python/megengine/module/elemwise.py +++ b/imperative/python/megengine/module/elemwise.py @@ -56,9 +56,9 @@ class Elemwise(Module): * "SIGMOID_GRAD": sigmoid_grad * "SWITCH_GT0": switch_gt0 * "TANH_GRAD": tanh_grad - * "LT": lt + * "LT": less * "LEQ": leq - * "EQ": eq + * "EQ": equal * "POW": pow * "LOG_SUM_EXP": log_sum_exp * "FAST_TANH_GRAD": fast_tanh_grad -- GitLab