Created by: LutaoChu
PR types
Bug fixes
PR changes
OPs
Describe
When the parameter k is Tensor in static mode, shapes of Topk outputs should be -1 rather than 1. For example,
import paddle
errors = paddle.static.data(name='e', shape=[100, 1])
k = paddle.shape(errors)[0]
errors_sorted, perm = paddle.topk(errors, k=k, axis=0)
print(errors_sorted.shape)
# before is [1, 1]
# now is [-1, 1]
y = paddle.slice(errors_sorted, axes=[0], starts=[0], ends=[-1])
# before raise error
# now run successfully