Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
76e870f1
Unverified
Commit
76e870f1
authored
Mar 07, 2022
by
Wenhao Wu
Committed by
GitHub
Mar 07, 2022
Browse files
[Fix] Fix bugs in Voxelization op (#1746)
* Fix bugs in Voxelization op * fix comments * fix lint * add comments
parent
09b64a60
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
mmcv/ops/csrc/pytorch/cpu/voxelization.cpp
mmcv/ops/csrc/pytorch/cpu/voxelization.cpp
+23
-7
No files found.
mmcv/ops/csrc/pytorch/cpu/voxelization.cpp
View file @
76e870f1
...
@@ -26,13 +26,22 @@ void dynamic_voxelize_forward_cpu_kernel(
...
@@ -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(
...
@@ -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
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment