Skip to content

Commit 70a18ae

Browse files
committed
Fix
1 parent c1d8752 commit 70a18ae

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

paddle/phi/infermeta/binary.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2969,7 +2969,12 @@ void MatmulInferMeta(const MetaTensor& x,
29692969
} else {
29702970
new_dims.reserve(ndims_x);
29712971
for (size_t i = 0; i < ndims_x - 2; ++i) {
2972-
new_dims.push_back(std::max(dims_x[i], dims_y[i]));
2972+
// If one of them is 0, choose 0.
2973+
if (dims_x[i] == 0 || dims_y[i] == 0) {
2974+
new_dims.push_back(0);
2975+
} else {
2976+
new_dims.push_back(std::max(dims_x[i], dims_y[i]));
2977+
}
29732978
}
29742979
}
29752980
if (!x_broadcasted) {

0 commit comments

Comments
 (0)