[Fix] Apply kernel loop for bicubic interpolate (#271)

This commit is contained in:
AllentDan 2021-12-09 12:56:32 +08:00 committed by GitHub
parent c213879103
commit d5c3be9739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,10 +89,7 @@ __global__ void resize_cubic_kernel_torch(const int num_elements, const scalar_t
int srcHeight, scalar_t *dst, int dstWidth, int dstHeight, int srcHeight, scalar_t *dst, int dstWidth, int dstHeight,
bool align_corners, float height_scale, bool align_corners, float height_scale,
float width_scale) { float width_scale) {
int index = threadIdx.x + blockIdx.x * blockDim.x; CUDA_1D_KERNEL_LOOP(index, num_elements) {
if (index >= num_elements) {
return;
}
// Special case: input and output are the same size, just copy // Special case: input and output are the same size, just copy
const int output_x = index % dstWidth; const int output_x = index % dstWidth;
const int output_y = index / dstWidth; const int output_y = index / dstWidth;
@ -141,6 +138,7 @@ __global__ void resize_cubic_kernel_torch(const int num_elements, const scalar_t
coefficients[3], t_y)); coefficients[3], t_y));
} }
} }
}
} }
template <typename scalar_t> template <typename scalar_t>