未验证 提交 4f57da5f 编写于 作者: zhouweiwei2014's avatar zhouweiwei2014 提交者: GitHub

[Zero-Dim] temporarily revert create_scalar due to input 0D is not fully supported (#48058)

上级 ccbd03d5
...@@ -99,7 +99,8 @@ def monkey_patch_variable(): ...@@ -99,7 +99,8 @@ def monkey_patch_variable():
return var return var
def create_scalar(block, value, dtype): 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): def create_tensor_with_batchsize(ref_var, value, dtype):
assert isinstance(ref_var, Variable) assert isinstance(ref_var, Variable)
......
...@@ -350,7 +350,7 @@ class TestBinaryAPI(unittest.TestCase): ...@@ -350,7 +350,7 @@ class TestBinaryAPI(unittest.TestCase):
paddle.enable_static() paddle.enable_static()
def test_static_unary(self): def test_static_binary(self):
paddle.enable_static() paddle.enable_static()
for api in binary_api_list + binary_api_list_without_grad: for api in binary_api_list + binary_api_list_without_grad:
main_prog = fluid.Program() main_prog = fluid.Program()
...@@ -377,15 +377,19 @@ class TestBinaryAPI(unittest.TestCase): ...@@ -377,15 +377,19 @@ class TestBinaryAPI(unittest.TestCase):
# Test runtime shape # Test runtime shape
self.assertEqual(out_np.shape, ()) self.assertEqual(out_np.shape, ())
# TODO(zhouwei): will open when create_scalar is []
# 2) x is 0D , y is scalar # 2) x is 0D , y is scalar
'''
x = paddle.rand([]) x = paddle.rand([])
y = 0.5 y = 0.5
x.stop_gradient = False x.stop_gradient = False
print(api)
if isinstance(api, dict): if isinstance(api, dict):
out = getattr(paddle.static.Variable, api['cls_method'])( out = getattr(paddle.static.Variable, api['cls_method'])(
x, y x, y
) )
self.assertEqual(out.shape, ()) self.assertEqual(out.shape, ())
'''
for api in binary_int_api_list_without_grad: for api in binary_int_api_list_without_grad:
main_prog = fluid.Program() main_prog = fluid.Program()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册