mirror of
https://github.com/open-mmlab/mmcv.git
synced 2025-06-03 21:54:52 +08:00
[Fix] Fix bugs in Voxelization op (#1746)
* Fix bugs in Voxelization op * fix comments * fix lint * add comments
This commit is contained in:
parent
09b64a60b0
commit
76e870f17c
@ -26,13 +26,22 @@ void dynamic_voxelize_forward_cpu_kernel(
|
|||||||
coor[ndim_minus_1 - j] = c;
|
coor[ndim_minus_1 - j] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failed)
|
// memcpy and memset will cause problem because of the memory distribution
|
||||||
memset(&coors[i][0], -1, NDim * sizeof(T_int));
|
// discontinuity of TensorAccessor, so here using loops to replace memcpy
|
||||||
else
|
// or memset
|
||||||
memcpy(&coors[i][0], &coor[0], NDim * sizeof(T_int));
|
if (failed) {
|
||||||
|
for (int k = 0; k < NDim; ++k) {
|
||||||
|
coors[i][k] = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int k = 0; k < NDim; ++k) {
|
||||||
|
coors[i][k] = coor[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] coor;
|
delete[] coor;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename T_int>
|
template <typename T, typename T_int>
|
||||||
@ -72,14 +81,21 @@ void hard_voxelize_forward_cpu_kernel(
|
|||||||
voxel_num += 1;
|
voxel_num += 1;
|
||||||
|
|
||||||
coor_to_voxelidx[coor[i][0]][coor[i][1]][coor[i][2]] = voxelidx;
|
coor_to_voxelidx[coor[i][0]][coor[i][1]][coor[i][2]] = voxelidx;
|
||||||
memcpy(&coors[voxelidx][0], &coor[i][0], NDim * sizeof(T_int));
|
// memcpy will cause problem because of the memory distribution
|
||||||
|
// discontinuity of TensorAccessor, so here using loops to replace memcpy
|
||||||
|
for (int k = 0; k < NDim; ++k) {
|
||||||
|
coors[voxelidx][k] = coor[i][k];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// put points into voxel
|
// put points into voxel
|
||||||
num = num_points_per_voxel[voxelidx];
|
num = num_points_per_voxel[voxelidx];
|
||||||
if (max_points == -1 || num < max_points) {
|
if (max_points == -1 || num < max_points) {
|
||||||
memcpy(&voxels[voxelidx][num][0], &points[i][0],
|
// memcpy will cause problem because of the memory distribution
|
||||||
num_features * sizeof(T));
|
// discontinuity of TensorAccessor, so here using loops to replace memcpy
|
||||||
|
for (int k = 0; k < num_features; ++k) {
|
||||||
|
voxels[voxelidx][num][k] = points[i][k];
|
||||||
|
}
|
||||||
num_points_per_voxel[voxelidx] += 1;
|
num_points_per_voxel[voxelidx] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user