Enhance concat op to support empty input.#17015
Enhance concat op to support empty input.#17015jerrywgz merged 3 commits intoPaddlePaddle:developfrom
Conversation
qingqing01
left a comment
There was a problem hiding this comment.
@chengduoZH Please also help to review. Thanks!
paddle/fluid/operators/concat_op.h
Outdated
| if (axis == 0 && ins.size() < 10) { | ||
| size_t output_offset = 0; | ||
| for (auto* in : ins) { | ||
| if (in->numel() == 0UL) { |
There was a problem hiding this comment.
Maybe better to check:
if (!in || in->numel() == 0UL) {
}| continue; | ||
| } else { | ||
| inputs.push_back(*ins[j]); | ||
| } |
There was a problem hiding this comment.
if (ins[j] || in->numel() > 0) {
inputs.push_back(*ins[j]);
} else {
continue;
}There was a problem hiding this comment.
Done, but here should be || or &&?
|
@jerrywgz You should add unit test for this change. |
Done |
| self.axis = 0 | ||
|
|
||
| def test_check_grad(self): | ||
| pass |
There was a problem hiding this comment.
Because it will meet fetch error when there is a null grad
|
@jerrywgz Why the inputs have some empty argument? |
In FPN detection model, we need to divide rois into four parts and it may produce empty rois in one part. Concat op in caffe2 can support empty argument. |
| continue; | ||
| } else { | ||
| inputs.push_back(*ins[j]); | ||
| } |
Enhance concat op to allow empty variable in inputs.
For example, In Faster-RCNN-FPN model, RoIs are distributed onto different levels and get roi features by roi_align. In such case, the number of rois in one level might be 0, then causes empty input and output in roi_align. As result, we should support empty variable when use concat op to concatenate roi features.