未验证 提交 7c508d86 编写于 作者: myq406450149's avatar myq406450149 提交者: GitHub

update unbind norm add CUDAPlace api doc information (#29322)

* enhance array_to_lod_tensor_op lod_tensor_to_array_op errors information. test=develop

* fix format. test=develop

* format fix. test=develop

* add lod_rank_table. test=develop

* fix format. test=develop

* fix doc info. test=develop

* fix np error

* add unbind dygraph api. test=develop

* fix unbind doc.test=develop
上级 879e913b
......@@ -1375,7 +1375,6 @@ All parameter, weight, gradient are variables in Paddle.
import paddle
place = paddle.CUDAPlace(0)
paddle.disable_static(place)
)DOC")
.def("__init__",
......
......@@ -173,8 +173,6 @@ def matmul(x, y, transpose_x=False, transpose_y=False, name=None):
def norm(x, p='fro', axis=None, keepdim=False, name=None):
"""
:alias_main: paddle.norm
:alias: paddle.norm,paddle.tensor.norm,paddle.tensor.linalg.norm
Returns the matrix norm (Frobenius) or vector norm (the 1-norm, the Euclidean
or 2-norm, and in general the p-norm for p > 0) of a given tensor.
......@@ -206,7 +204,6 @@ def norm(x, p='fro', axis=None, keepdim=False, name=None):
import paddle
import numpy as np
paddle.disable_static()
shape=[2, 3, 4]
np_input = np.arange(24).astype('float32') - 12
np_input = np_input.reshape(shape)
......
......@@ -791,29 +791,29 @@ def gather(x, index, axis=None, name=None):
def unbind(input, axis=0):
"""
:alias_main: paddle.tensor.unbind
:alias: paddle.tensor.unbind,paddle.tensor.manipulation.unbind
Removes a tensor dimension, then split the input tensor into multiple sub-Tensors.
Args:
input (Variable): The input variable which is an N-D Tensor, data type being float32, float64, int32 or int64.
axis (int32|int64, optional): A scalar with type ``int32|int64`` shape [1]. The dimension along which to unbind. If :math:`axis < 0`, the
dimension to unbind along is :math:`rank(input) + axis`. Default is 0.
input (Tensor): The input variable which is an N-D Tensor, data type being float32, float64, int32 or int64.
axis (int32|int64, optional): A scalar with type ``int32|int64`` shape [1]. The dimension along which to unbind.
If :math:`axis < 0`, the dimension to unbind along is :math:`rank(input) + axis`. Default is 0.
Returns:
list(Variable): The list of segmented Tensor variables.
list(Tensor): The list of segmented Tensor variables.
Example:
.. code-block:: python
import paddle
import numpy as np
# input is a variable which shape is [3, 4, 5]
input = paddle.fluid.data(
name="input", shape=[3, 4, 5], dtype="float32")
[x0, x1, x2] = paddle.tensor.unbind(input, axis=0)
np_input = np.random.rand(3, 4, 5).astype('float32')
input = paddle.to_tensor(np_input)
[x0, x1, x2] = paddle.unbind(input, axis=0)
# x0.shape [4, 5]
# x1.shape [4, 5]
# x2.shape [4, 5]
[x0, x1, x2, x3] = paddle.tensor.unbind(input, axis=1)
[x0, x1, x2, x3] = paddle.unbind(input, axis=1)
# x0.shape [3, 5]
# x1.shape [3, 5]
# x2.shape [3, 5]
......@@ -837,6 +837,8 @@ def unbind(input, axis=0):
helper.create_variable_for_type_inference(dtype=helper.input_dtype())
for i in range(num)
]
if in_dygraph_mode():
return core.ops.unbind(input, num, 'axis', axis)
helper.append_op(
type="unbind",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册