diff --git a/paddle/phi/kernels/funcs/broadcast_function.h b/paddle/phi/kernels/funcs/broadcast_function.h index 40dfb76586189ee0eac7a4790ed08b7c93514091..952ad90fc0686ec96d618837ba2ba3f37e2280ab 100644 --- a/paddle/phi/kernels/funcs/broadcast_function.h +++ b/paddle/phi/kernels/funcs/broadcast_function.h @@ -213,9 +213,10 @@ struct DimensionsTransform { } } }; - int swap_idx = 0; - bool has_seq_one = FindSequentialOneDim(&swap_idx); - if (has_seq_one) { + for (auto i = 0; i < dim_size; ++i) { + int swap_idx = 0; + bool has_seq_one = FindSequentialOneDim(&swap_idx); + if (!has_seq_one) break; merge_ptr = merge_sequential_one_dims; MergeDimensions(merge_ptr, N); std::swap(in_dims[swap_idx], in_dims[0]); @@ -508,7 +509,6 @@ void BroadcastKernelForDifferentVecSize( "functions is %d.", outs->size(), NumOuts)); - // mergedim and get vec_size const auto merge_dims = DimensionsTransform(ins, (*outs)[0]->dims(), axis); phi::Array configs; diff --git a/paddle/phi/kernels/primitive/datamover_primitives.h b/paddle/phi/kernels/primitive/datamover_primitives.h index 3f6148c7efd8000fb5d014a7e3433b2b756b2a96..d6139501b4e3c95b9304873d66ccfec34afe1529 100644 --- a/paddle/phi/kernels/primitive/datamover_primitives.h +++ b/paddle/phi/kernels/primitive/datamover_primitives.h @@ -85,7 +85,7 @@ struct FastDivMod { struct BroadcastConfig { FastDivMod divmoders[phi::DDim::kMaxRank]; uint32_t strides[phi::DDim::kMaxRank]; - int kDims; + int kDims{0}; HOSTDEVICE BroadcastConfig() {} HOSTDEVICE BroadcastConfig(const std::vector& out_dims,