Skip to content

Commit 7e322b3

Browse files
authored
update unbind norm add CUDAPlace api doc information (#29322) (#29391)
* 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
1 parent 2816f59 commit 7e322b3

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

paddle/fluid/pybind/pybind.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,6 @@ All parameter, weight, gradient are variables in Paddle.
13751375
import paddle
13761376
13771377
place = paddle.CUDAPlace(0)
1378-
paddle.disable_static(place)
13791378
13801379
)DOC")
13811380
.def("__init__",

python/paddle/tensor/linalg.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ def __check_input(x, y):
173173

174174
def norm(x, p='fro', axis=None, keepdim=False, name=None):
175175
"""
176-
:alias_main: paddle.norm
177-
:alias: paddle.norm,paddle.tensor.norm,paddle.tensor.linalg.norm
178176
179177
Returns the matrix norm (Frobenius) or vector norm (the 1-norm, the Euclidean
180178
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):
206204
207205
import paddle
208206
import numpy as np
209-
paddle.disable_static()
210207
shape=[2, 3, 4]
211208
np_input = np.arange(24).astype('float32') - 12
212209
np_input = np_input.reshape(shape)

python/paddle/tensor/manipulation.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -791,29 +791,29 @@ def gather(x, index, axis=None, name=None):
791791

792792
def unbind(input, axis=0):
793793
"""
794-
:alias_main: paddle.tensor.unbind
795-
:alias: paddle.tensor.unbind,paddle.tensor.manipulation.unbind
796794
797795
Removes a tensor dimension, then split the input tensor into multiple sub-Tensors.
796+
798797
Args:
799-
input (Variable): The input variable which is an N-D Tensor, data type being float32, float64, int32 or int64.
800-
801-
axis (int32|int64, optional): A scalar with type ``int32|int64`` shape [1]. The dimension along which to unbind. If :math:`axis < 0`, the
802-
dimension to unbind along is :math:`rank(input) + axis`. Default is 0.
798+
input (Tensor): The input variable which is an N-D Tensor, data type being float32, float64, int32 or int64.
799+
axis (int32|int64, optional): A scalar with type ``int32|int64`` shape [1]. The dimension along which to unbind.
800+
If :math:`axis < 0`, the dimension to unbind along is :math:`rank(input) + axis`. Default is 0.
803801
Returns:
804-
list(Variable): The list of segmented Tensor variables.
802+
list(Tensor): The list of segmented Tensor variables.
805803
806804
Example:
807805
.. code-block:: python
806+
808807
import paddle
808+
import numpy as np
809809
# input is a variable which shape is [3, 4, 5]
810-
input = paddle.fluid.data(
811-
name="input", shape=[3, 4, 5], dtype="float32")
812-
[x0, x1, x2] = paddle.tensor.unbind(input, axis=0)
810+
np_input = np.random.rand(3, 4, 5).astype('float32')
811+
input = paddle.to_tensor(np_input)
812+
[x0, x1, x2] = paddle.unbind(input, axis=0)
813813
# x0.shape [4, 5]
814814
# x1.shape [4, 5]
815815
# x2.shape [4, 5]
816-
[x0, x1, x2, x3] = paddle.tensor.unbind(input, axis=1)
816+
[x0, x1, x2, x3] = paddle.unbind(input, axis=1)
817817
# x0.shape [3, 5]
818818
# x1.shape [3, 5]
819819
# x2.shape [3, 5]
@@ -837,6 +837,8 @@ def unbind(input, axis=0):
837837
helper.create_variable_for_type_inference(dtype=helper.input_dtype())
838838
for i in range(num)
839839
]
840+
if in_dygraph_mode():
841+
return core.ops.unbind(input, num, 'axis', axis)
840842

841843
helper.append_op(
842844
type="unbind",

0 commit comments

Comments
 (0)