未验证 提交 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():
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)
......
......@@ -350,7 +350,7 @@ class TestBinaryAPI(unittest.TestCase):
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()
......@@ -377,15 +377,19 @@ class TestBinaryAPI(unittest.TestCase):
# 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()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册