| 8 | namespace cuda { |
| 9 | |
| 10 | void ROIPoolingForwardImpl::exec( |
| 11 | _megdnn_tensor_in src, _megdnn_tensor_in rois, _megdnn_tensor_out dst, |
| 12 | _megdnn_tensor_out index, _megdnn_workspace workspace) { |
| 13 | check_exec(src.layout, rois.layout, dst.layout, index.layout, workspace.size); |
| 14 | auto stream = cuda_stream(handle()); |
| 15 | auto nthreads = dst.layout.total_nr_elems(); |
| 16 | auto spatial_scale = m_param.scale; |
| 17 | auto channels = src.layout.shape[1]; |
| 18 | auto height = src.layout.shape[2]; |
| 19 | auto width = src.layout.shape[3]; |
| 20 | auto pooled_height = dst.layout.shape[2]; |
| 21 | auto pooled_width = dst.layout.shape[3]; |
| 22 | using namespace ::megdnn::roi_pooling; |
| 23 | using namespace ::megdnn::cuda::roi_pooling; |
| 24 | #define cb(DType) \ |
| 25 | if (src.layout.dtype == DType()) { \ |
| 26 | using T = typename DTypeTrait<DType>::ctype; \ |
| 27 | switch (param().mode) { \ |
| 28 | case param::ROIPooling::Mode::MAX: \ |
| 29 | forward_proxy<T, MaxPooler<T>>( \ |
| 30 | nthreads, src.ptr<T>(), spatial_scale, channels, height, \ |
| 31 | width, pooled_height, pooled_width, rois.ptr<T>(), \ |
| 32 | dst.ptr<T>(), index.ptr<dt_int32>(), stream); \ |
| 33 | break; \ |
| 34 | case param::ROIPooling::Mode::AVERAGE: \ |
| 35 | forward_proxy<T, AveragePooler<T>>( \ |
| 36 | nthreads, src.ptr<T>(), spatial_scale, channels, height, \ |
| 37 | width, pooled_height, pooled_width, rois.ptr<T>(), \ |
| 38 | dst.ptr<T>(), index.ptr<dt_int32>(), stream); \ |
| 39 | break; \ |
| 40 | default: \ |
| 41 | megdnn_assert_internal(false); \ |
| 42 | } \ |
| 43 | } |
| 44 | MEGDNN_FOREACH_COMPUTING_DTYPE_FLOAT(cb) |
| 45 | #undef cb |
| 46 | } |
| 47 | |
| 48 | void ROIPoolingBackwardImpl::exec( |
| 49 | _megdnn_tensor_in diff, _megdnn_tensor_in src, _megdnn_tensor_in rois, |
nothing calls this directly
no test coverage detected