未验证 提交 d85cf4d4 编写于 作者: W wawltor 提交者: GitHub

fix the document for the add api (#45101)

* fix the api for the add

* update the document for the api add

* update add docs; test=document_fix
Co-authored-by: NLigoml <39876205+Ligoml@users.noreply.github.com>
上级 87ff40b7
......@@ -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 = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册