From 69217a244ab3ee0a76577d343d1d8637f6d80504 Mon Sep 17 00:00:00 2001 From: juncaipeng <52520497+juncaipeng@users.noreply.github.com> Date: Mon, 2 Sep 2019 11:19:03 +0800 Subject: [PATCH] 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 --- lite/kernels/arm/elementwise_compute.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lite/kernels/arm/elementwise_compute.cc b/lite/kernels/arm/elementwise_compute.cc index 41b5965548..0a3963f8f4 100644 --- a/lite/kernels/arm/elementwise_compute.cc +++ b/lite/kernels/arm/elementwise_compute.cc @@ -35,7 +35,7 @@ inline DDim trim_trailing_singular_dims(const DDim& dims) { trim_dims[i] = dims[i]; } if (trim_dims.size() == 0) { - return DDim({1}); + return DDim(); } return DDim(trim_dims); } @@ -50,6 +50,7 @@ inline bool is_broadcast(const DDim& x_dims, axis = x_dims.size() - y_dims.size(); } 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()) { return false; } -- GitLab