From b19b01af18fcbf4e8484cbd3ff11950fb8d245ac Mon Sep 17 00:00:00 2001 From: MRXLT Date: Wed, 14 Oct 2020 12:15:21 +0800 Subject: [PATCH] add dygraph code for unstack (#27881) --- python/paddle/fluid/layers/nn.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 91cce50f3fe..4a0f361d9a0 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -10238,6 +10238,11 @@ def unstack(x, axis=0, num=None): y = paddle.unstack(x, axis=1) # unstack with second axis, which results 3 tensors with shape=[2, 5] """ + if in_dygraph_mode(): + if num == None: + num = x.shape[axis] + return core.ops.unstack(x, num, 'axis', int(axis), 'num', num) + helper = LayerHelper('unstack', **locals()) if num is None: if axis is None or x.shape[axis] <= 0: -- GitLab