Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion python/paddle/fluid/layers/math_op_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def create_tensor(block, value, dtype, shape):
return var

def create_scalar(block, value, dtype):
return create_tensor(block, value, dtype, shape=[])
# TODO(zhouwei): will change to [] which is 0-D Tensor
return create_tensor(block, value, dtype, shape=[1])

def create_tensor_with_batchsize(ref_var, value, dtype):
assert isinstance(ref_var, Variable)
Expand Down
6 changes: 5 additions & 1 deletion python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def test_dygraph_binary(self):

paddle.enable_static()

def test_static_unary(self):
def test_static_binary(self):
paddle.enable_static()
for api in binary_api_list + binary_api_list_without_grad:
main_prog = fluid.Program()
Expand All @@ -377,15 +377,19 @@ def test_static_unary(self):
# Test runtime shape
self.assertEqual(out_np.shape, ())

# TODO(zhouwei): will open when create_scalar is []
# 2) x is 0D , y is scalar
'''
x = paddle.rand([])
y = 0.5
x.stop_gradient = False
print(api)
if isinstance(api, dict):
out = getattr(paddle.static.Variable, api['cls_method'])(
x, y
)
self.assertEqual(out.shape, ())
'''

for api in binary_int_api_list_without_grad:
main_prog = fluid.Program()
Expand Down