Created
October 10, 2017 15:42
-
-
Save harveyslash/612e6d00f10a7892c2f8a311dacd4b74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__global__ void upSample_kernel(unsigned int * ann, unsigned int * ann_tmp,int * params, int aw_half,int ah_half) { | |
int ax = blockIdx.x*blockDim.x + threadIdx.x; | |
int ay = blockIdx.y*blockDim.y + threadIdx.y; | |
int ah = params[1]; | |
int aw = params[2]; | |
int bh = params[3]; | |
int bw = params[4]; | |
float aw_ratio = (float)aw / (float)aw_half; | |
float ah_ratio = (float)ah / (float)ah_half; | |
int ax_half = (ax+0.5) / aw_ratio; | |
int ay_half = (ay+0.5) / ah_ratio; | |
ax_half = clamp(ax_half, aw_half - 1, 0); | |
ay_half = clamp(ay_half, ah_half - 1, 0); | |
if (ax < aw&&ay < ah) { | |
unsigned int v_half = ann[ay_half*aw_half + ax_half]; | |
int bx_half = INT_TO_X(v_half); | |
int by_half = INT_TO_Y(v_half); | |
int bx = ax + (bx_half - ax_half)*aw_ratio + 0.5; | |
int by = ay + (by_half - ay_half)*ah_ratio + 0.5; | |
bx = clamp(bx, bw-1, 0); | |
by = clamp(by, bh-1, 0); | |
ann_tmp[ay*aw + ax] = XY_TO_INT(bx, by); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment