Skip to content

Commit 25ff0e5

Browse files
committed
use reshape
1 parent 89cd532 commit 25ff0e5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

python/paddle/nn/functional/conv.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,11 @@ def _conv_nd(x,
127127
x, weight, stride, padding, padding_algorithm, groups, dilation,
128128
data_format, False, -1, False)
129129
if bias is not None:
130-
tmp_bias = _C_ops.final_state_unsqueeze(
131-
bias, [i for i in range(channel_dim)])[1]
130+
channel_dim = channel_dim + len(
131+
x.shape) if channel_dim < 0 else channel_dim
132+
tmp_bias = _C_ops.final_state_reshape(
133+
bias, bias.shape +
134+
[1 for i in range(len(x.shape) - channel_dim - 1)])
132135
return _C_ops.final_state_add(pre_bias, tmp_bias)
133136
else:
134137
return pre_bias

0 commit comments

Comments
 (0)