add auto_grown_mutex for selected rows #11012
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
project: #10868
为什么mutex要放到 unique_ptr中?
https://stackoverflow.com/questions/30340029/copy-class-with-stdmutex
https://stackoverflow.com/questions/37172050/copy-or-move-constructor-for-a-class-with-a-member-stdmutex-or-other-non-copy
Paddle/paddle/fluid/operators/math/selected_rows_functor.h
Lines 70 to 86 in 654f5d3
上面的代码,会在函数内部构造一个selected_rows, 然后return回来,如果selected rows里面有个成员是mutex,他不会生成一个默认的移动构造函数,编译上述functor的时候会挂,如果放到一个unique_prt里边,他会默认调用移动构造函数,把unique_ptr中的指针移动出来。