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

[Zero-Dim] support input 0D Tensor for std/var #49735

Merged
merged 54 commits into from
Feb 10, 2023
Merged
Changes from 11 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
64a886f
add test_std
mhy-666 Jan 11, 2023
380a1b0
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 11, 2023
a029888
add test_var
mhy-666 Jan 11, 2023
de4dfde
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 11, 2023
373d03e
fix std/var assertequal
mhy-666 Jan 11, 2023
c116647
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 12, 2023
6fab348
fix std/var assertequal
mhy-666 Jan 12, 2023
d39de8c
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 12, 2023
eaed3a7
fix std/var assertequal
mhy-666 Jan 12, 2023
a3a486d
Merge branch '0dtensor_1' of /~https://github.com/mhy-666/Paddle into 0…
mhy-666 Jan 12, 2023
38e7724
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 13, 2023
1d8dc7a
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 16, 2023
3154340
-madd api name to reduce_api
mhy-666 Jan 16, 2023
5911cb3
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 16, 2023
baec185
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 16, 2023
c79aefd
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 18, 2023
cc022cb
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 19, 2023
ebfdc82
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 19, 2023
3a91dc3
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 20, 2023
e349f10
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 30, 2023
97009f6
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 31, 2023
2611aef
fix
mhy-666 Jan 31, 2023
8626b1a
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Jan 31, 2023
9296a2e
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 6, 2023
e30f034
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 6, 2023
b005c17
fix var
mhy-666 Feb 6, 2023
ff6d429
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 6, 2023
c0f87a0
fix
mhy-666 Feb 6, 2023
e5b34a8
fix
mhy-666 Feb 6, 2023
a543037
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 7, 2023
f85a832
fix stat
mhy-666 Feb 7, 2023
46a13b5
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 7, 2023
fb2a2b3
fix unitest
mhy-666 Feb 7, 2023
dd3d037
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 7, 2023
3648616
fix stat/var
mhy-666 Feb 7, 2023
213b1fb
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 7, 2023
0960e51
fix stat/var, unittest
mhy-666 Feb 7, 2023
8f50034
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 8, 2023
e4d19ad
fix stat/std, unittest
mhy-666 Feb 8, 2023
e851491
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 8, 2023
0e29ffc
add unittest of var,std, fix stat/var,std
mhy-666 Feb 8, 2023
4f9723a
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 9, 2023
369ccd8
fix stat/var, unittest
mhy-666 Feb 9, 2023
150ffbc
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 9, 2023
590aa02
fix
mhy-666 Feb 9, 2023
97c0838
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 9, 2023
e7de555
fix unittest
mhy-666 Feb 9, 2023
cddb91b
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 9, 2023
06db74b
fix
mhy-666 Feb 9, 2023
0f3cfdf
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 9, 2023
f10e396
fix
mhy-666 Feb 9, 2023
a610318
fix
mhy-666 Feb 9, 2023
8d154e4
Merge branch 'PaddlePaddle:develop' into 0dtensor_1
mhy-666 Feb 9, 2023
664023b
fix unittest
mhy-666 Feb 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,30 @@ def test_mode(self):
self.assertEqual(x.grad.shape, [])
self.assertTrue(x.grad.numpy() == 1)

def test_std(self):
x = paddle.full([], 1, 'float32')
x.stop_gradient = False
out = paddle.std(x)
out.backward()

# checkout shape of out
self.assertEqual(out.shape, [])

# checkout value of out
self.assertEqual(out, 0)

def test_var(self):
x = paddle.full([], 1, 'float32')
x.stop_gradient = False
out = paddle.var(x)
out.backward()

# checkout shape of out
self.assertEqual(out.shape, [])

# checkout value of out
self.assertEqual(out, 0)

def test_flatten(self):
x = paddle.rand([])
x.stop_gradient = False
Expand Down Expand Up @@ -1472,6 +1496,26 @@ def test_mode(self):
self.assertEqual(res[2].shape, ())
self.assertTrue(res[2] == 1.0)

@prog_scope()
def test_std(self):
x = paddle.full([], 1, 'float32')
out = paddle.std(x)
paddle.static.append_backward(out)

prog = paddle.static.default_main_program()
res = self.exe.run(prog, fetch_list=[out])
self.assertEqual(res[0].shape, (1,))

@prog_scope()
def test_var(self):
x = paddle.full([], 1, 'float32')
out = paddle.var(x)
paddle.static.append_backward(out)

prog = paddle.static.default_main_program()
res = self.exe.run(prog, fetch_list=[out])
self.assertEqual(res[0].shape, (1,))

@prog_scope()
def test_flatten(self):
x = paddle.full([], 1, 'float32')
Expand Down