mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-07 00:13:17 +00:00
ROIAlign: fix bilinear interpolate in 'max' mode (#1821)
This commit is contained in:
parent
a1eecd8087
commit
8a9c4cd936
2 changed files with 13 additions and 11 deletions
|
|
@ -249,13 +249,15 @@ void RoiAlignForward(
|
|||
for (int64_t iy = 0; iy < roi_bin_grid_h; iy++) {
|
||||
for (int64_t ix = 0; ix < roi_bin_grid_w; ix++) {
|
||||
PreCalc<T> pc = pre_calc[pre_calc_index];
|
||||
T val = std::max(std::max(std::max(pc.w1 * offset_bottom_data[pc.pos1],
|
||||
pc.w2 * offset_bottom_data[pc.pos2]),
|
||||
pc.w3 * offset_bottom_data[pc.pos3]),
|
||||
pc.w4 * offset_bottom_data[pc.pos4]);
|
||||
if (!max_flag) {
|
||||
output_val = pc.w1 * offset_bottom_data[pc.pos1];
|
||||
output_val = val;
|
||||
max_flag = true;
|
||||
} else {
|
||||
output_val = std::max(std::max(std::max(output_val, pc.w2 * offset_bottom_data[pc.pos2]),
|
||||
pc.w3 * offset_bottom_data[pc.pos3]),
|
||||
pc.w4 * offset_bottom_data[pc.pos4]);
|
||||
output_val = std::max(output_val, val);
|
||||
}
|
||||
|
||||
pre_calc_index += 1;
|
||||
|
|
|
|||
|
|
@ -124,13 +124,13 @@ TEST(RoiAlignTest, MaxModePositive) {
|
|||
25.f,25.f,25.f,25.f,25.f,50.f,50.f,50.f,50.f,50.f,50.f,50.f,50.f,50.f,50.f,50.f,50.f,5.625f,5.625f,5.625f,4.57031f,
|
||||
8.95833f,8.95833f,8.95833f,7.27865f,9.375f,9.375f,9.375f,7.61719f,19.6875f,19.6875f,19.6875f,15.9961f,
|
||||
31.3542f,31.3542f,31.3542f,25.4753f,32.8125f,32.8125f,32.8125f,26.6602f,33.75f,33.75f,33.75f,27.4219f,
|
||||
53.75f,53.75f,53.75f,43.6719f,56.25f,56.25f,56.25f,45.7031f,4.5f,3.9375f,2.8125f,3.9375f,5.5f,4.125f,
|
||||
3.20833f,4.8125f,4.58333f,4.01042f,2.86458f,3.9375f,23.25f,20.3438f,14.5313f,18.f,28.4167f,21.3125f,
|
||||
14.6667f,22.f,15.8229f,20.3437f,14.5312f,18.f,42.f,36.75f,26.25f,32.0625f,51.3333f,38.5f,26.125f,39.1875f,
|
||||
28.5833f,36.75f,26.25f,32.0625f,4.375f,4.375f,4.375f,4.375f,7.70833f,7.70833f,7.70833f,7.70833f,9.375f,
|
||||
9.375f,9.375f,8.78906f,21.875f,21.875f,21.875f,21.875f,26.9792f,26.9792f,26.9792f,26.9792f,32.8125f,
|
||||
32.8125f,32.8125f,30.7617f,40.1042f,40.1042f,40.1042f,40.1042f,46.25f,46.25f,46.25f,46.25f,56.25f,56.25f,
|
||||
56.25f,52.7344f});
|
||||
53.75f,53.75f,53.75f,43.6719f,56.25f,56.25f,56.25f,45.7031f,4.5f,3.9375f,2.8125f,3.9375f,5.5f,4.8125f,
|
||||
3.4375f,4.8125f,4.58333f,4.01042f,2.86458f,3.9375f,23.25f,20.3438f,14.5313f,18.f,28.4167f,24.86458f,
|
||||
17.76042f,22.f,23.25f,20.3437f,14.5312f,18.f,42.f,36.75f,26.25f,32.0625f,51.3333f,44.9167f,32.08333f,39.1875f,
|
||||
42.f,36.75f,26.25f,32.0625f,4.375f,4.375f,4.375f,4.375f,7.70833f,7.70833f,7.70833f,7.70833f,9.375f,
|
||||
9.375f,9.375f,9.375f,21.875f,21.875f,21.875f,21.875f,26.9792f,26.9792f,26.9792f,26.9792f,32.8125f,
|
||||
32.8125f,32.8125f,32.8125f,40.1042f,40.1042f,40.1042f,40.1042f,46.25f,46.25f,46.25f,46.25f,56.25f,56.25f,
|
||||
56.25f,56.25f});
|
||||
|
||||
test.Run();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue