提交 69217a24 编写于 作者: J juncaipeng 提交者: GitHub

fix elementwise_op bug when the shape of input y is 1, test=develop (#1924)

* fix elementwise_op bug when the shape of input y is 1, test=develop

* fix elementwise ops bug when the shape of input y is 1, test=develop
上级 c096de0e
...@@ -35,7 +35,7 @@ inline DDim trim_trailing_singular_dims(const DDim& dims) { ...@@ -35,7 +35,7 @@ inline DDim trim_trailing_singular_dims(const DDim& dims) {
trim_dims[i] = dims[i]; trim_dims[i] = dims[i];
} }
if (trim_dims.size() == 0) { if (trim_dims.size() == 0) {
return DDim({1}); return DDim();
} }
return DDim(trim_dims); return DDim(trim_dims);
} }
...@@ -50,6 +50,7 @@ inline bool is_broadcast(const DDim& x_dims, ...@@ -50,6 +50,7 @@ inline bool is_broadcast(const DDim& x_dims,
axis = x_dims.size() - y_dims.size(); axis = x_dims.size() - y_dims.size();
} }
DDim y_dim_trim = trim_trailing_singular_dims(y_dims); DDim y_dim_trim = trim_trailing_singular_dims(y_dims);
axis = (y_dim_trim.size() == 0) ? x_dims.size() : axis;
if (x_dims.size() == y_dim_trim.size()) { if (x_dims.size() == y_dim_trim.size()) {
return false; return false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册