-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Roialign fix and half_pixel mode support #3482
base: develop
Are you sure you want to change the base?
Conversation
…ng in a dimension of size 1
…X into stride_ordering_for_mlir
…code. Tests need to be completed, including updating generated onnx test files.
…_half_pixel_verify_test for first roi but fails for second
…k in progress with debug code.
…ive correct result only for ROI in bounds.
Reviewers: This PR isn't quite ready for review as I'm still working on the GPU implementation. I'm just opening it to activate the Jenkins testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a small wording change but it's neither a big change nor a mandatory one.
… but in mixed up order.
…st_roialign* cases. still contains output index workaround
Co-authored-by: spolifroni-amd <[email protected]>
This PR is finally ready to begin review. Note that I left a "todo" about recalculating the indexing order in the Reference op. If we come up with a way to iterate through the array in correct order the first time through, great. But getting the order right to this point (just to obtain correct test values) has been very time-consuming and if a fix doesn't present itself, it may be better to stick with the workaround. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, just a few small things. I haven't been able to fully wrap my head around all the math in the ref and gpu impl, the index changes look reasonable. Do we have a way to directly test against ORT (without maunally extracting gold outputs)? If so, I think it would be worthwhile to add a few more tests comparing with ORT
EXPECT(p == prog); | ||
|
||
// Opset 12 program |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest making this a separate test so if there is a failure you know which one of the two opsets had the problem
This build is not recommended to merge 🔴 |
🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output |
mm->add_return({r}); | ||
|
||
return p; | ||
} | ||
}; | ||
|
||
template struct test_roialign_half_pixel<migraphx::shape::float_type>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any point in adding other data types for the half_pixel (i.e. the "real" ROIAlign) test?
|
||
pp["rois"] = migraphx::argument(srois, rois_data.data()); | ||
pp["batch_ind"] = migraphx::argument(sbi, bi_data.data()); | ||
pp["y"] = migraphx::argument(s, data.data()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me whether Y, the output, is even needed for this test. What role does it play?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely because roialign_half_pixel_test.onnx
expects it as input. I am not sure why its configured like that. Maybe it needs an allocated buffer to write the output to?
I am not very familiar with the verify onnx tests, I would check if this is common in other tests also
@@ -41,7 +41,7 @@ TEST_CASE(roialign_test) | |||
{{"coordinate_transformation_mode", "output_half_pixel"}, | |||
{"spatial_scale", 2.0f}, | |||
{"output_height", 5}, | |||
{"output_width", 5}, | |||
{"output_width", 3}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular change was a big deal, btw, since the old code appeared to work fine until I gave it an output_height and output_width that were not the same.
migraphx::shape srois{migraphx::shape::float_type, {2, 4}}; | ||
std::vector<float> rois_data = {1.1, 0.73, 1.7, 1.13, 1.1, 0.73, 2.6, 1.13}; | ||
migraphx::shape sbi{migraphx::shape::int64_type, {2}}; // batch_index | ||
std::vector<int64_t> bi_data = {0, 1}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for good measure, can you add a tests with the following cases:
- Repeated batch indices
- Missing batch indices (ie. not all batch items are computed on)
- Number of ROIs != batch_size
You can probably just create one test case to get all these. Make the input batch_size 3 and the batch_indices something like {1,2,2,1} (and hence the rois shape will be {4,4})
Would be good to have a gpu verify test for this same case too just to be sure gpu impl matches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A whitespace in the table needs to be removed.
@@ -697,7 +697,7 @@ Operator Support Matrix | |||
| | | | functions are | | |||
| | | | not enabled | | |||
+--------------------------+-----------+-----------------+------------------------------+ | |||
| RoiAlign | ✅ | FP8, FP16, | | | |||
| RoiAlign | ✅ | FP8, FP16, | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra whitespace at the end of this row is causing the table to be improperly formatted and not appear on the doc page.
| RoiAlign | ✅ | FP8, FP16, | | | |
| RoiAlign | ✅ | FP8, FP16, | | |
Fix bugs in the implementation of ROIAlign operation which were found when attempting to run it with the
half_pixel
coordinate conversion mode, to include more thorough tests. Some bugs are mode-specific and some are not.The ROIAlign operation was first proposed in a paper at https://arxiv.org/abs/1703.06870v3 which introduced the
Mask R-CNN
model. It was a variant of the ROIPool operation which was found to give significantly better accuracy. In the implementations in Torch, Onnxruntime, and Migraphx, ROIPool and ROIAlign are implemented in the same op. with different choices for the mode attribute, withoutput_half_pixel
for ROIPool andhalf_pixel
for ROIAlign; thus, there is no ROIAlign op without fixing thehalf_pixel
mode.Note, by the way, that these same coordinate conversion modes are also attributes of the
Resize
op.MIGraphX uses the Onnxruntime implementation of ROIAlign as its functional specification and should give identical results.
This change is prerequisite for torch-migraphx PR #143 but does not close it.