未验证 提交 a89b33ff 编写于 作者: zhouweiwei2014's avatar zhouweiwei2014 提交者: GitHub

fix doc of some sparse api (#47020)

上级 a21a2b5b
...@@ -38,7 +38,7 @@ def matmul(x, y, name=None): ...@@ -38,7 +38,7 @@ def matmul(x, y, name=None):
Applies matrix multiplication of two Tensors. Applies matrix multiplication of two Tensors.
The supported input/output Tensor layout are as follows: The supported input/output Tensor type are as follows:
Note: Note:
x[SparseCsrTensor] @ y[SparseCsrTensor] -> out[SparseCsrTensor] x[SparseCsrTensor] @ y[SparseCsrTensor] -> out[SparseCsrTensor]
...@@ -53,12 +53,12 @@ def matmul(x, y, name=None): ...@@ -53,12 +53,12 @@ def matmul(x, y, name=None):
is zero or more batch dimensions. is zero or more batch dimensions.
Args: Args:
x (Tensor): The input tensor. It can be SparseCooTensor/SparseCsrTensor. The data type can be float32 or float64. x (SparseTensor): The input tensor. It can be SparseCooTensor/SparseCsrTensor. The data type can be float32 or float64.
y (Tensor): The input tensor. It can be SparseCooTensor/SparseCsrTensor/DenseTensor. The data type can be float32 or float64. y (SparseTensor|DenseTensor): The input tensor. It can be SparseCooTensor/SparseCsrTensor/DenseTensor. The data type can be float32 or float64.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
Returns: Returns:
Tensor: Its layout is determined by that of `x` and `y` . SparseTensor|DenseTensor: Determined by `x` and `y` .
Examples: Examples:
...@@ -121,13 +121,13 @@ def masked_matmul(x, y, mask, name=None): ...@@ -121,13 +121,13 @@ def masked_matmul(x, y, mask, name=None):
where `*` is zero or more batch dimensions. where `*` is zero or more batch dimensions.
Args: Args:
x (Tensor): The input tensor. It is DenseTensor. The data type can be float32 or float64. x (DenseTensor): The input tensor. It is DenseTensor. The data type can be float32 or float64.
y (Tensor): The input tensor. It is DenseTensor. The data type can be float32 or float64. y (DenseTensor): The input tensor. It is DenseTensor. The data type can be float32 or float64.
mask (Tensor): The mask tensor, which can be SparseCooTensor/SparseCsrTensor. It specify sparse coordinates. The data type can be float32 or float64. mask (SparseTensor): The mask tensor, which can be SparseCooTensor/SparseCsrTensor. It specify sparse coordinates. The data type can be float32 or float64.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
Returns: Returns:
Tensor: SparseCoo or SparseCsr, which is determined by that of `mask` . SparseTensor: SparseCooTensor or SparseCsrTensor, which is same with `mask` .
Examples: Examples:
...@@ -171,32 +171,30 @@ def mv(x, vec, name=None): ...@@ -171,32 +171,30 @@ def mv(x, vec, name=None):
The supported input/output Tensor layout are as follows: The supported input/output Tensor layout are as follows:
Note: Note:
x[SparseCsrTensor] @ y[DenseTensor] -> out[SparseCsrTensor] x[SparseCsrTensor] @ vec[DenseTensor] -> out[DenseTensor]
x[SparseCooTensor] @ y[DenseTensor] -> out[SparseCooTensor] x[SparseCooTensor] @ vec[DenseTensor] -> out[DenseTensor]
It supports backward propagation. It supports backward propagation.
The shape of `x` should be `[M, N]` , and the shape of `y` should be `[N]` , The shape of `x` should be `[M, N]` , and the shape of `vec` should be `[N]` ,
and the shape of `out` will be `[M]` . and the shape of `out` will be `[M]` .
Args: Args:
x (Tensor): The input 2D tensor. It must be SparseCooTensor/SparseCsrTensor. The data type can be float32 or float64. x (SparseTensor): The input 2D tensor. It must be SparseCooTensor/SparseCsrTensor. The data type can be float32 or float64.
y (Tensor): The input 1D tensor. It must be DenseTensor vector. The data type can be float32 or float64. vec (DenseTensor): The input 1D tensor. It must be DenseTensor vector. The data type can be float32 or float64.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
Returns: Returns:
Tensor: 1D Tensor. DenseTensor: 1D DenseTensor whose dtype is same with input.
Examples: Examples:
.. code-block:: python .. code-block:: python
import paddle import paddle
from paddle.fluid.framework import _test_eager_guard
paddle.seed(100) paddle.seed(100)
# csr @ dense -> dense # csr @ dense -> dense
with _test_eager_guard():
crows = [0, 2, 3, 5] crows = [0, 2, 3, 5]
cols = [1, 3, 2, 0, 1] cols = [1, 3, 2, 0, 1]
values = [1., 2., 3., 4., 5.] values = [1., 2., 3., 4., 5.]
......
...@@ -29,7 +29,7 @@ def addmm(input, x, y, beta=1.0, alpha=1.0, name=None): ...@@ -29,7 +29,7 @@ def addmm(input, x, y, beta=1.0, alpha=1.0, name=None):
.. math:: .. math::
Out = alpha * x * y + beta * input out = alpha * x * y + beta * input
The supported input/output Tensor layout are as follows: The supported input/output Tensor layout are as follows:
...@@ -44,15 +44,15 @@ def addmm(input, x, y, beta=1.0, alpha=1.0, name=None): ...@@ -44,15 +44,15 @@ def addmm(input, x, y, beta=1.0, alpha=1.0, name=None):
Dimensions `input` , `x` , `y` must be same and >= 2D. Automatic broadcasting of Tensor is not supported. Dimensions `input` , `x` , `y` must be same and >= 2D. Automatic broadcasting of Tensor is not supported.
Args: Args:
input (Tensor): The input tensor. Shape is [*, M, N]. The data type can be float32 or float64. input (SparseTensor|DenseTensor): The input tensor. Shape is [*, M, N]. The data type can be float32 or float64.
x (Tensor): The input tensor. Shape is [*, M, K]. The data type can be float32 or float64. x (SparseTensor): The input SparseTensor. Shape is [*, M, K]. The data type can be float32 or float64.
y (Tensor): The input tensor. Shape is [*, K, N]. The data type can be float32 or float64. y (SparseTensor|DenseTensor): The input tensor. Shape is [*, K, N]. The data type can be float32 or float64.
beta (float, optional): Coefficient of `input` . Default: 1.0 beta (float, optional): Coefficient of `input` . Default: 1.0
alpha (float, optional): Coefficient of `x * y` . Default: 1.0 alpha (float, optional): Coefficient of `x * y` . Default: 1.0
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
Returns: Returns:
Tensor: Its layout is determined by that of `x` and `y` . dtype and shape is the same with `input` SparseTensor|DenseTensor: Tensor type, date type and shape is the same with `input` .
Examples: Examples:
......
...@@ -66,8 +66,8 @@ class Softmax(Layer): ...@@ -66,8 +66,8 @@ class Softmax(Layer):
Only support axis=-1 for SparseCsrTensor, which is faster when read data Only support axis=-1 for SparseCsrTensor, which is faster when read data
by row (axis=-1). by row (axis=-1).
From the point of view of dense matrix, for each row :math:`i` and each column :math:`j` Transform x to dense matix, and :math:`i` is row index, :math:`j` is column index.
in the matrix, we have: If axis=-1, We have:
.. math:: .. math::
...@@ -130,7 +130,7 @@ class ReLU6(Layer): ...@@ -130,7 +130,7 @@ class ReLU6(Layer):
.. math:: .. math::
ReLU(x) = min(max(0,x), 6) ReLU6(x) = min(max(0,x), 6)
Parameters: Parameters:
name (str, optional): Name for the operation (optional, default is None). name (str, optional): Name for the operation (optional, default is None).
......
...@@ -549,7 +549,7 @@ def coalesce(x): ...@@ -549,7 +549,7 @@ def coalesce(x):
@dygraph_only @dygraph_only
def rad2deg(x, name=None): def rad2deg(x, name=None):
""" """
Convert each of the elements of input x from angles in radians to degrees, Convert each of the elements of input x from radian to degree,
requiring x to be a SparseCooTensor or SparseCsrTensor. requiring x to be a SparseCooTensor or SparseCsrTensor.
.. math:: .. math::
...@@ -582,7 +582,7 @@ def rad2deg(x, name=None): ...@@ -582,7 +582,7 @@ def rad2deg(x, name=None):
@dygraph_only @dygraph_only
def deg2rad(x, name=None): def deg2rad(x, name=None):
""" """
Convert each of the elements of input x from degrees to angles in radians, Convert each of the elements of input x from degree to radian,
requiring x to be a SparseCooTensor or SparseCsrTensor. requiring x to be a SparseCooTensor or SparseCsrTensor.
.. math:: .. math::
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册