未验证 提交 60c9f97c 编写于 作者: L liym27 提交者: GitHub

Get exact value of dim in advance for slice op (#33300)

上级 6c110344
......@@ -22,6 +22,8 @@ import paddle.fluid as fluid
import paddle.fluid.layers as layers
import paddle
paddle.enable_static()
# Situation 1: starts(list, no tensor), ends(list, no tensor)
# 1.1 without attr(decrease)
......@@ -683,6 +685,16 @@ class TestImperativeVarBaseGetItem(unittest.TestCase):
self.assertRaises(Exception, test_float_in_index)
class TestInferShape(unittest.TestCase):
def test(self):
x = paddle.ones(shape=[3, 4, 5])
x.desc.set_shape([3, -1, 5])
self.assertEqual(x.shape, (3, -1, 5))
out0 = paddle.slice(x, axes=[1], starts=[0], ends=[3])
self.assertEqual(out0.shape, (3, 3, 5))
@unittest.skipIf(not core.is_compiled_with_cuda(),
"core is not compiled with CUDA")
class TestImperativeCUDAPinnedInput(unittest.TestCase):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册