diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index 778b670769a3cbc6dc2eb6f6fe0b156a766850a7..9930acff00ad72b8aa19aa30701fdb6d44cfd60b 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -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__", diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index c6af97ffcac15094d4f91d5ca1393a9fcbd38530..99f5bf7ba0ad1b973a9a988e36a2a0c46f52ccb9 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -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) diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index d6f40d80a760348e7aaab7216a2f94299696af13..40a8fdb7ef0954b1eac183fdb4b06af4b4b3dc66 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -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",