[BUG?] GridEncoder doesn't give correct gradient with respect to the coordinate
zjumsj opened this issue · comments
@ashawkey My recent project requires the gradient with respect to the coordinate (inputs in code, BxD, D=3). However, the gradient returned seems incorrect. Only the first channel of grad_inputs has non-zero value. I guess the mistake is at line 143 in gridencoder.cu where only the first element of array pos_deriv is set to 1.0f. Hope that you can fix it if it's really a mistake.
// calculate coordinate (always use float for precision!)
float pos[D];
float pos_deriv[D] = {1.0f}; // linear deriv is default to 1
uint32_t pos_grid[D];
Thanks, I think it gives reasonable results now.