| 8 | namespace cuda { |
| 9 | |
| 10 | void ROIAlignForwardImpl::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 | int nthreads = dst.layout.total_nr_elems(); |
| 16 | float spatial_scale = param().spatial_scale; |
| 17 | float offset = param().offset; |
| 18 | int sample_height = param().sample_height; |
| 19 | int sample_width = param().sample_width; |
| 20 | int channels = src.layout.shape[1]; |
| 21 | int height = src.layout.shape[2]; |
| 22 | int width = src.layout.shape[3]; |
| 23 | int pooled_height = dst.layout.shape[2]; |
| 24 | int pooled_width = dst.layout.shape[3]; |
| 25 | using namespace ::megdnn::roi_align; |
| 26 | using namespace ::megdnn::cuda::roi_align; |
| 27 | #define cb(DType) \ |
| 28 | if (src.layout.dtype == DType()) { \ |
| 29 | using T = typename DTypeTrait<DType>::ctype; \ |
| 30 | switch (param().mode) { \ |
| 31 | case param::ROIAlign::Mode::MAX: \ |
| 32 | forward_proxy<T, MaxPooler<T>>( \ |
| 33 | nthreads, src.ptr<T>(), spatial_scale, offset, channels, \ |
| 34 | height, width, pooled_height, pooled_width, sample_height, \ |
| 35 | sample_width, rois.ptr<T>(), dst.ptr<T>(), \ |
| 36 | index.ptr<dt_int32>(), stream); \ |
| 37 | break; \ |
| 38 | case param::ROIAlign::Mode::AVERAGE: \ |
| 39 | forward_proxy<T, AveragePooler<T>>( \ |
| 40 | nthreads, src.ptr<T>(), spatial_scale, offset, channels, \ |
| 41 | height, width, pooled_height, pooled_width, sample_height, \ |
| 42 | sample_width, rois.ptr<T>(), dst.ptr<T>(), \ |
| 43 | index.ptr<dt_int32>(), stream); \ |
| 44 | break; \ |
| 45 | default: \ |
| 46 | megdnn_assert_internal(false); \ |
| 47 | } \ |
| 48 | } |
| 49 | MEGDNN_FOREACH_COMPUTING_DTYPE_FLOAT(cb) |
| 50 | #undef cb |
| 51 | } |
| 52 | |
| 53 | void ROIAlignBackwardImpl::exec( |
| 54 | _megdnn_tensor_in diff, _megdnn_tensor_in rois, _megdnn_tensor_in index, |
nothing calls this directly
no test coverage detected