diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 5ff3d733b24baf47513bcb9cd587bd940debec69..4d9f170d39ee4c6df1b802a9fb9a9c3142ccb4be 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -500,16 +500,19 @@ def add(x, y, name=None): Out=X+Y - X : a tensor of any dimension. - Y: a tensor whose dimensions must be less than or equal to the dimensions of X. + $X$ the tensor of any dimension. + $Y$ the tensor whose dimensions must be less than or equal to the dimensions of $X$. There are two cases for this operator: - 1. The shape of Y is the same with X. - 2. The shape of Y is a continuous subsequence of X. + + 1. The shape of $Y$ is the same with $X$. + 2. The shape of $Y$ is a continuous subsequence of $X$. + For case 2: - 1. Broadcast Y to match the shape of X, where axis is the start dimension index for broadcasting Y onto X. - 2. If axis is -1 (default), axis=rank(X)−rank(Y). - 3. The trailing dimensions of size 1 for Y will be ignored for the consideration of subsequence, such as shape(Y) = (2, 1) => (2). + + 1. Broadcast $Y$ to match the shape of $X$, where axis is the start dimension index for broadcasting $Y$ onto $X$. + 2. If $axis$ is -1 (default), $axis$=rank($X$)−rank($Y$). + 3. The trailing dimensions of size 1 for $Y$ will be ignored for the consideration of subsequence, such as shape($Y$) = (2, 1) => (2). For example: @@ -523,13 +526,12 @@ def add(x, y, name=None): shape(X) = (2, 3, 4, 5), shape(Y) = (2, 1), with axis=0 Args: - x (Tensor) – (Variable), Tensor or LoDTensor of any dimensions. Its dtype should be int32, int64, float32, float64. - y (Tensor) – (Variable), Tensor or LoDTensor of any dimensions. Its dtype should be int32, int64, float32, float64. - with_quant_attr (BOOLEAN) – Whether the operator has attributes used by quantization. - name (string, optional) – Name of the output. Default is None. It’s used to print debug info for developers. Details: :ref:`api_guide_Name` + x (Tensor): Tensor or LoDTensor of any dimensions. Its dtype should be int32, int64, float32, float64. + y (Tensor): Tensor or LoDTensor of any dimensions. Its dtype should be int32, int64, float32, float64. + name (string, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. Returns: - N-dimension tensor. A location into which the result is stored. It’s dimension equals with x + N-D Tensor. A location into which the result is stored. It’s dimension equals with x. Examples: @@ -1079,10 +1081,9 @@ def fmin(x, y, name=None): return _elementwise_op(LayerHelper(op_type, **locals())) for func in [ - add, multiply ]: - proto_dict = {'add': 'elementwise_add', 'multiply': 'elementwise_mul'} + proto_dict = {'multiply': 'elementwise_mul'} op_proto = OpProtoHolder.instance().get_op_proto(proto_dict[func.__name__]) additional_args_lines = [