Add 'aligned' param to ExperimentalDetectronROIFeatureExtractor for CPU plugin and MO

This commit is contained in:
Ilya-Krylov authored and GitHub committed 2020-06-03 17:52:40 +03:00
1 parent 53927034da
commit cfb5f27899
3 files changed
+12 -5

No files matched your search

@@ -140,6 +140,7 @@ void ROIAlignForward_cpu_kernel(
const int pooled_width,
const int sampling_ratio,
const T* bottom_rois,
const bool aligned,
T* top_data) {
int roi_cols = 4;
@@ -156,11 +157,12 @@ void ROIAlignForward_cpu_kernel(
offset_bottom_rois++;
}
T offset = aligned ? (T)0.5 : (T)0.0;
// Do not using rounding; this implementation detail is critical
T roi_start_w = offset_bottom_rois[0] * spatial_scale;
T roi_start_h = offset_bottom_rois[1] * spatial_scale;
T roi_end_w = offset_bottom_rois[2] * spatial_scale;
T roi_end_h = offset_bottom_rois[3] * spatial_scale;
T roi_start_w = offset_bottom_rois[0] * spatial_scale - offset;
T roi_start_h = offset_bottom_rois[1] * spatial_scale - offset;
T roi_end_w = offset_bottom_rois[2] * spatial_scale - offset;
T roi_end_h = offset_bottom_rois[3] * spatial_scale - offset;
// Force malformed ROIs to be 1x1
T roi_width = (std::max)(roi_end_w - roi_start_w, (T)1.);
@@ -321,6 +323,7 @@ public:
output_dim_ = layer->GetParamAsInt("output_size");
pyramid_scales_ = layer->GetParamAsInts("pyramid_scales");
sampling_ratio_ = layer->GetParamAsInt("sampling_ratio");
aligned_ = layer->GetParamAsBool("aligned");
pooled_height_ = output_dim_;
pooled_width_ = output_dim_;
@@ -374,6 +377,7 @@ public:
pooled_width_,
sampling_ratio_,
&reordered_rois[4 * level_rois_offset],
aligned_,
&output_rois_features_temp[feaxels_per_roi * level_rois_offset]);
}
}
@@ -394,6 +398,7 @@ private:
int pooled_width_ = 0;
std::vector<int> pyramid_scales_;
int sampling_ratio_ = 0;
bool aligned_ = false;
};
REG_FACTORY_FOR(ExperimentalDetectronROIFeatureExtractorImpl, ExperimentalDetectronROIFeatureExtractor);
@@ -31,6 +31,7 @@ class ExperimentalDetectronROIFeatureExtractorFrontExtractor(FrontExtractorOp):
sampling_ratio=onnx_attr(node, 'sampling_ratio', 'i', 2),
distribute_rois_between_levels=onnx_attr(node, 'distribute_rois_between_levels', 'i', 1),
preserve_rois_order=onnx_attr(node, 'preserve_rois_order', 'i', 1),
aligned=onnx_attr(node, 'aligned', 'i', 0),
num_classes=onnx_attr(node, 'num_classes', 'i', 81),
post_nms_count=onnx_attr(node, 'post_nms_count', 'i', 2000),
score_threshold=onnx_attr(node, 'score_threshold', 'f', 0.05),
@@ -41,7 +41,8 @@ class ExperimentalDetectronROIFeatureExtractor(Op):
'image_id',
'output_size',
'sampling_ratio',
'preserve_rois_order']
'preserve_rois_order',
'aligned']
@staticmethod
def infer(node):