| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifndef INTERPOLATION_KERNEL |
| | #define INTERPOLATION_KERNEL |
| |
|
| | #include "math_functions.hpp" |
| |
|
| | #include <limits> |
| |
|
| | namespace minkowski { |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | template <typename Dtype, typename Wtype, typename Itype> |
| | void InterpolationForwardKernelCPU(Dtype const *const p_in_feat, |
| | Dtype *p_out_feat, |
| | uint32_t const nchannel, |
| | Itype const *const in_maps, |
| | Itype const *const out_maps, |
| | Wtype const *const weights, |
| | uint32_t const nnz) { |
| | const Dtype *p_curr_in; |
| | Dtype *p_curr_out; |
| |
|
| | |
| | |
| |
|
| | |
| | for (uint32_t i = 0; i < nnz; ++i) { |
| | |
| | p_curr_in = p_in_feat + in_maps[i] * nchannel; |
| | p_curr_out = p_out_feat + out_maps[i] * nchannel; |
| | cpu_axpy<Dtype>(nchannel, (Dtype)weights[i], p_curr_in, p_curr_out); |
| | } |
| | } |
| |
|
| | template <typename Dtype, typename Wtype, typename Itype> |
| | void InterpolationBackwardKernelCPU(Dtype *p_grad_in_feat, |
| | uint32_t const in_nrows, |
| | uint32_t const nchannel, |
| | Dtype const *const p_grad_out_feat, |
| | Itype const *const in_maps, |
| | Itype const *const out_maps, |
| | Wtype const *const weights, |
| | uint32_t const nnz) { |
| | Dtype *p_curr_grad_in; |
| | Dtype const *p_curr_grad_out; |
| |
|
| | |
| | |
| |
|
| | for (uint32_t i = 0; i < nnz; ++i) { |
| | |
| | p_curr_grad_in = p_grad_in_feat + in_maps[i] * nchannel; |
| | p_curr_grad_out = p_grad_out_feat + out_maps[i] * nchannel; |
| |
|
| | cpu_axpy<Dtype>(nchannel, (Dtype)weights[i], p_curr_grad_out, |
| | p_curr_grad_in); |
| | } |
| | } |
| |
|
| | template void |
| | InterpolationForwardKernelCPU<float, float, int>(float const *const p_in_feat, |
| | float *p_out_feat, |
| | uint32_t const nchannel, |
| | int const *const in_maps, |
| | int const *const out_maps, |
| | float const *const weights, |
| | uint32_t const nnz); |
| |
|
| | template void |
| | InterpolationForwardKernelCPU<double, float, int>(double const *const p_in_feat, |
| | double *p_out_feat, |
| | uint32_t const nchannel, |
| | int const *const in_maps, |
| | int const *const out_maps, |
| | float const *const weights, |
| | uint32_t const nnz); |
| |
|
| | template void InterpolationBackwardKernelCPU<float, float, int>( |
| | float *p_grad_in_feat, |
| | uint32_t const in_nrows, |
| | uint32_t const nchannel, |
| | float const *const p_grad_out_feat, |
| | int const *const in_maps, |
| | int const *const out_maps, |
| | float const *const weights, |
| | uint32_t const nnz); |
| |
|
| | template void InterpolationBackwardKernelCPU<double, float, int>( |
| | double *p_grad_in_feat, |
| | uint32_t const in_nrows, |
| | uint32_t const nchannel, |
| | double const *const p_grad_out_feat, |
| | int const *const in_maps, |
| | int const *const out_maps, |
| | float const *const weights, |
| | uint32_t const nnz); |
| |
|
| | } |
| |
|
| | #endif |
| |
|