diff --git a/paddle/fluid/operators/reverse_op.h b/paddle/fluid/operators/reverse_op.h index d3c54b731883fe6352790d1ed36849c7b0e76987..9063cd59bba5c6307b55a500455908a5fd278390 100644 --- a/paddle/fluid/operators/reverse_op.h +++ b/paddle/fluid/operators/reverse_op.h @@ -24,8 +24,8 @@ struct ReverseFunctor { void operator()(const DeviceContext& context, const framework::LoDTensor& in, framework::LoDTensor* out, const std::vector& axis) { Eigen::array reverse_axis; - for (auto& i : reverse_axis) { - i = false; + for (int i = 0; i < Rank; ++i) { + reverse_axis[i] = false; } for (int a : axis) { reverse_axis[a] = true;