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

fix doc of some sparse api (#47020)

上级 a21a2b5b
......@@ -38,7 +38,7 @@ def matmul(x, y, name=None):
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:
x[SparseCsrTensor] @ y[SparseCsrTensor] -> out[SparseCsrTensor]
......@@ -53,12 +53,12 @@ def matmul(x, y, name=None):
is zero or more batch dimensions.
Args:
x (Tensor): 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.
x (SparseTensor): The input tensor. It can be SparseCooTensor/SparseCsrTensor. 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`.
Returns:
Tensor: Its layout is determined by that of `x` and `y` .
SparseTensor|DenseTensor: Determined by `x` and `y` .
Examples:
......@@ -121,13 +121,13 @@ def masked_matmul(x, y, mask, name=None):
where `*` is zero or more batch dimensions.
Args:
x (Tensor): 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.
mask (Tensor): The mask tensor, which can be SparseCooTensor/SparseCsrTensor. It specify sparse coordinates. 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 (DenseTensor): The input tensor. It is DenseTensor. 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`.
Returns:
Tensor: SparseCoo or SparseCsr, which is determined by that of `mask` .
SparseTensor: SparseCooTensor or SparseCsrTensor, which is same with `mask` .
Examples:
......@@ -171,46 +171,44 @@ def mv(x, vec, name=None):
The supported input/output Tensor layout are as follows:
Note:
x[SparseCsrTensor] @ y[DenseTensor] -> out[SparseCsrTensor]
x[SparseCooTensor] @ y[DenseTensor] -> out[SparseCooTensor]
x[SparseCsrTensor] @ vec[DenseTensor] -> out[DenseTensor]
x[SparseCooTensor] @ vec[DenseTensor] -> out[DenseTensor]
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]` .
Args:
x (Tensor): 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.
x (SparseTensor): The input 2D tensor. It must be SparseCooTensor/SparseCsrTensor. 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`.
Returns:
Tensor: 1D Tensor.
DenseTensor: 1D DenseTensor whose dtype is same with input.
Examples:
.. code-block:: python
import paddle
from paddle.fluid.framework import _test_eager_guard
paddle.seed(100)
# csr @ dense -> dense
with _test_eager_guard():
crows = [0, 2, 3, 5]
cols = [1, 3, 2, 0, 1]
values = [1., 2., 3., 4., 5.]
dense_shape = [3, 4]
csr = paddle.incubate.sparse.sparse_csr_tensor(crows, cols, values, dense_shape)
# Tensor(shape=[3, 4], dtype=paddle.float32, place=Place(gpu:0), stop_gradient=True,
# crows=[0, 2, 3, 5],
# cols=[1, 3, 2, 0, 1],
# values=[1., 2., 3., 4., 5.])
vec = paddle.randn([4])
out = paddle.incubate.sparse.mv(csr, vec)
# Tensor(shape=[3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
# [-3.85499096, -2.42975140, -1.75087738])
crows = [0, 2, 3, 5]
cols = [1, 3, 2, 0, 1]
values = [1., 2., 3., 4., 5.]
dense_shape = [3, 4]
csr = paddle.incubate.sparse.sparse_csr_tensor(crows, cols, values, dense_shape)
# Tensor(shape=[3, 4], dtype=paddle.float32, place=Place(gpu:0), stop_gradient=True,
# crows=[0, 2, 3, 5],
# cols=[1, 3, 2, 0, 1],
# values=[1., 2., 3., 4., 5.])
vec = paddle.randn([4])
out = paddle.incubate.sparse.mv(csr, vec)
# Tensor(shape=[3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
# [-3.85499096, -2.42975140, -1.75087738])
"""
return _C_ops.sparse_mv(x, vec)
......
......@@ -29,7 +29,7 @@ def addmm(input, x, y, beta=1.0, alpha=1.0, name=None):
.. math::
Out = alpha * x * y + beta * input
out = alpha * x * y + beta * input
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):
Dimensions `input` , `x` , `y` must be same and >= 2D. Automatic broadcasting of Tensor is not supported.
Args:
input (Tensor): 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.
y (Tensor): The input tensor. Shape is [*, K, 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 (SparseTensor): The input SparseTensor. Shape is [*, M, K]. 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
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`.
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:
......
......@@ -66,8 +66,8 @@ class Softmax(Layer):
Only support axis=-1 for SparseCsrTensor, which is faster when read data
by row (axis=-1).
From the point of view of dense matrix, for each row :math:`i` and each column :math:`j`
in the matrix, we have:
Transform x to dense matix, and :math:`i` is row index, :math:`j` is column index.
If axis=-1, We have:
.. math::
......@@ -130,7 +130,7 @@ class ReLU6(Layer):
.. math::
ReLU(x) = min(max(0,x), 6)
ReLU6(x) = min(max(0,x), 6)
Parameters:
name (str, optional): Name for the operation (optional, default is None).
......
......@@ -549,7 +549,7 @@ def coalesce(x):
@dygraph_only
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.
.. math::
......@@ -582,7 +582,7 @@ def rad2deg(x, name=None):
@dygraph_only
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.
.. math::
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册