Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support numpy.array/asarray(tensor) -> ndarray, test=develop #32300

Merged
merged 1 commit into from
Apr 20, 2021

Conversation

lyuwenyu
Copy link
Contributor

PR types

New features

PR changes

OPs

Describe

  • paddle

  • GPU / CPU

  • 2.01 / 2.1 (develop)

  • Before

In [1]: import paddle

In [2]: paddle.__version__
Out[2]: '2.1.0'

In [3]: data = paddle.rand((2, 3))

In [4]: import numpy as np

In [5]: np.array(data).shape
Out[5]:
(2,
 3,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1)

In [6]: np.array(data)
Out[6]:
array([[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Tensor(shape=[1], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
       [0.85678869])]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
       ...

        [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Tensor(shape=[1], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
       [0.04641196])]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
       ...

        [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Tensor(shape=[1], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
       [0.35171834])]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
       ...

       [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Tensor(shape=[1], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
       [0.79624861])]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
       ...

        [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Tensor(shape=[1], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
       [0.71793634])]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
       ...

        [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Tensor(shape=[1], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
       [0.50397265])]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], dtype=object)
  • After
In [8]: type(data)
Out[8]: paddle.VarBase

In [9]: np.array(data).shape
Out[9]: (2, 3)

In [10]: np.array(data)
Out[10]:
array([[0.8567887 , 0.04641196, 0.35171834],
       [0.7962486 , 0.71793634, 0.50397265]], dtype=float32)

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@lyuwenyu lyuwenyu changed the title support numpy.array/asarray(tensor) -> ndarray, test=develop support numpy.array/asarray(tensor) -> ndarray, test=develop Apr 15, 2021
Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qingqing01 qingqing01 merged commit 43926c8 into PaddlePaddle:develop Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants