Skip to content

Commit d7f704c

Browse files
committed
fixed C++ warning and python flake8 style
1 parent 1111319 commit d7f704c

File tree

4 files changed

+540
-442
lines changed

4 files changed

+540
-442
lines changed

csrc/cpu/radius_cpu.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ torch::Tensor radius_cpu(torch::Tensor query, torch::Tensor support,
1515

1616
AT_DISPATCH_ALL_TYPES(query.scalar_type(), "radius_cpu", [&] {
1717

18-
auto data_q = query.DATA_PTR<scalar_t>();
19-
auto data_s = support.DATA_PTR<scalar_t>();
18+
auto data_q = query.data_ptr<scalar_t>();
19+
auto data_s = support.data_ptr<scalar_t>();
2020
std::vector<scalar_t> queries_stl = std::vector<scalar_t>(data_q,
2121
data_q + query.size(0)*query.size(1));
2222
std::vector<scalar_t> supports_stl = std::vector<scalar_t>(data_s,
@@ -34,13 +34,7 @@ torch::Tensor radius_cpu(torch::Tensor query, torch::Tensor support,
3434
out = torch::from_blob(neighbors_indices_ptr, {tsize, 2}, options=options);
3535
out = out.t();
3636

37-
auto result = torch::zeros_like(out);
38-
39-
auto index = torch::tensor({0,1});
40-
41-
result.index_copy_(0, index, out);
42-
43-
return result;
37+
return out.clone();
4438
}
4539

4640

@@ -49,7 +43,7 @@ void get_size_batch(const vector<long>& batch, vector<long>& res){
4943
res.resize(batch[batch.size()-1]-batch[0]+1, 0);
5044
long ind = batch[0];
5145
long incr = 1;
52-
for(int i=1; i < batch.size(); i++){
46+
for(unsigned long i=1; i < batch.size(); i++){
5347

5448
if(batch[i] == ind)
5549
incr++;
@@ -81,8 +75,7 @@ torch::Tensor batch_radius_cpu(torch::Tensor query,
8175
auto options = torch::TensorOptions().dtype(torch::kLong).device(torch::kCPU);
8276
int max_count = 0;
8377

84-
85-
AT_DISPATCH_ALL_TYPES(query.scalar_type(), "batch_radius_search", [&] {
78+
AT_DISPATCH_ALL_TYPES(query.scalar_type(), "batch_radius_cpu", [&] {
8679
auto data_q = query.data_ptr<scalar_t>();
8780
auto data_s = support.data_ptr<scalar_t>();
8881
std::vector<scalar_t> queries_stl = std::vector<scalar_t>(data_q,

csrc/cpu/utils/neighbors.cpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,18 @@ int batch_nanoflann_neighbors (vector<scalar_t>& queries,
127127
// Initiate variables
128128
// ******************
129129
// indices
130-
int i0 = 0;
130+
size_t i0 = 0;
131131

132132
// Square radius
133133
const scalar_t r2 = static_cast<scalar_t>(radius*radius);
134134

135135
// Counting vector
136-
int max_count = 0;
137-
float d2;
138-
136+
size_t max_count = 0;
139137

140138
// batch index
141-
long b = 0;
142-
long sum_qb = 0;
143-
long sum_sb = 0;
139+
size_t b = 0;
140+
size_t sum_qb = 0;
141+
size_t sum_sb = 0;
144142

145143
float eps = 0.000001;
146144
// Nanoflann related variables
@@ -173,16 +171,9 @@ int batch_nanoflann_neighbors (vector<scalar_t>& queries,
173171
for (auto& p0 : query_pcd.pts){
174172
// Check if we changed batch
175173

176-
scalar_t query_pt[dim];
174+
scalar_t* query_pt = new scalar_t[dim];
177175
std::copy(p0.begin(), p0.end(), query_pt);
178176

179-
/*
180-
std::cout << "\n ========== \n";
181-
for(int i=0; i < dim; i++)
182-
std::cout << query_pt[i] << '\n';
183-
std::cout << "\n ========== \n";
184-
*/
185-
186177
if (i0 == sum_qb + q_batches[b]){
187178
sum_qb += q_batches[b];
188179
sum_sb += s_batches[b];
@@ -218,7 +209,7 @@ int batch_nanoflann_neighbors (vector<scalar_t>& queries,
218209
}
219210
// Reserve the memory
220211

221-
int size = 0; // total number of edges
212+
size_t size = 0; // total number of edges
222213
for (auto& inds_dists : all_inds_dists){
223214
if(inds_dists.size() <= max_count)
224215
size += inds_dists.size();
@@ -230,14 +221,14 @@ int batch_nanoflann_neighbors (vector<scalar_t>& queries,
230221
sum_sb = 0;
231222
sum_qb = 0;
232223
b = 0;
233-
int u = 0;
224+
size_t u = 0;
234225
for (auto& inds_dists : all_inds_dists){
235226
if (i0 == sum_qb + q_batches[b]){
236227
sum_qb += q_batches[b];
237228
sum_sb += s_batches[b];
238229
b++;
239230
}
240-
for (int j = 0; j < max_count; j++){
231+
for (size_t j = 0; j < max_count; j++){
241232
if (j < inds_dists.size()){
242233
neighbors_indices[u] = inds_dists[j].first + sum_sb;
243234
neighbors_indices[u + 1] = i0;

0 commit comments

Comments
 (0)