!9332 fix get_broadcast_shape, support broadcasting dynamic shape

From: @TFbunny
Reviewed-by: @tom__chen,@robingrosman
Signed-off-by: @robingrosman
This commit is contained in:
mindspore-ci-bot 2020-12-16 04:21:30 +08:00 committed by Gitee
commit 94cfd5a57f
1 changed files with 2 additions and 0 deletions

View File

@ -54,6 +54,8 @@ def get_broadcast_shape(x_shape, y_shape, prim_name):
broadcast_shape_back.append(x_shape[i])
elif x_shape[i] == y_shape[i]:
broadcast_shape_back.append(x_shape[i])
elif x_shape[i] == -1 or y_shape[i] == -1:
broadcast_shape_back.append(-1)
else:
raise ValueError(f"For '{prim_name}', the x_shape {x_shape} and y_shape {y_shape} can not broadcast.")