1 #ifndef CAFFE2_OPERATORS_GENERATE_PROPOSALS_OP_H_ 2 #define CAFFE2_OPERATORS_GENERATE_PROPOSALS_OP_H_ 4 #include "caffe2/core/context.h" 5 #include "caffe2/core/operator.h" 6 #include "caffe2/utils/eigen_utils.h" 7 #include "caffe2/utils/math.h" 9 C10_DECLARE_CAFFE2_OPERATOR(GenerateProposals);
21 : data_(data), dims_(dims) {}
26 const std::vector<int>& dims()
const {
29 int dim(
int i)
const {
30 DCHECK_LE(i, dims_.size());
33 const T* data()
const {
37 return std::accumulate(
38 dims_.begin(), dims_.end(), 1, std::multiplies<size_t>());
42 const T* data_ =
nullptr;
43 std::vector<int> dims_;
51 CAFFE2_API ERMatXf ComputeAllAnchors(
61 CAFFE2_API ERArrXXf ComputeSortedAnchors(
62 const Eigen::Map<const ERArrXXf>& anchors,
66 const vector<int>& order);
77 template <
class Context>
80 USE_OPERATOR_CONTEXT_FUNCTIONS;
81 template<
class... Args>
85 this->
template GetSingleArgument<float>(
"spatial_scale", 1.0 / 16)),
86 feat_stride_(1.0 / spatial_scale_),
88 this->
template GetSingleArgument<int>(
"pre_nms_topN", 6000)),
90 this->
template GetSingleArgument<int>(
"post_nms_topN", 300)),
92 this->
template GetSingleArgument<float>(
"nms_thresh", 0.7f)),
93 rpn_min_size_(this->
template GetSingleArgument<float>(
"min_size", 16)),
95 this->
template GetSingleArgument<bool>(
"angle_bound_on",
true)),
97 this->
template GetSingleArgument<int>(
"angle_bound_lo", -90)),
99 this->
template GetSingleArgument<int>(
"angle_bound_hi", 90)),
101 this->
template GetSingleArgument<float>(
"clip_angle_thresh", 1.0)) {}
103 ~GenerateProposalsOp() {}
105 bool RunOnDevice()
override;
114 void ProposalsForOneImage(
115 const Eigen::Array3f& im_info,
116 const Eigen::Map<const ERArrXXf>& anchors,
120 EArrXf* out_probs)
const;
124 float spatial_scale_{1.0};
125 float feat_stride_{1.0};
128 int rpn_pre_nms_topN_{6000};
130 int rpn_post_nms_topN_{300};
132 float rpn_nms_thresh_{0.7};
134 float rpn_min_size_{16};
137 bool angle_bound_on_{
true};
138 int angle_bound_lo_{-90};
139 int angle_bound_hi_{90};
143 float clip_angle_thresh_{1.0};
147 Tensor dev_cub_sort_buffer_{Context::GetDeviceType()};
148 Tensor dev_cub_select_buffer_{Context::GetDeviceType()};
149 Tensor dev_image_offset_{Context::GetDeviceType()};
150 Tensor dev_conv_layer_indexes_{Context::GetDeviceType()};
151 Tensor dev_sorted_conv_layer_indexes_{Context::GetDeviceType()};
152 Tensor dev_sorted_scores_{Context::GetDeviceType()};
153 Tensor dev_boxes_{Context::GetDeviceType()};
154 Tensor dev_boxes_keep_flags_{Context::GetDeviceType()};
157 Tensor dev_image_prenms_boxes_{Context::GetDeviceType()};
158 Tensor dev_image_prenms_scores_{Context::GetDeviceType()};
159 Tensor dev_prenms_nboxes_{Context::GetDeviceType()};
160 Tensor host_prenms_nboxes_{CPU};
162 Tensor dev_image_boxes_keep_list_{Context::GetDeviceType()};
165 Tensor dev_nms_mask_{Context::GetDeviceType()};
166 Tensor host_nms_mask_{CPU};
169 Tensor dev_postnms_rois_{Context::GetDeviceType()};
170 Tensor dev_postnms_rois_probs_{Context::GetDeviceType()};
175 #endif // CAFFE2_OPERATORS_GENERATE_PROPOSALS_OP_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...