Skip to content

Commit f1479fe

Browse files
Merge pull request #17 from nicolas-chaulet/formating
Formating
2 parents c5d928e + 071e8b5 commit f1479fe

21 files changed

+838
-863
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ build
3636

3737
.vscode/
3838
dist/
39-
torch_points.egg-info/
39+
torch_points.egg-info/

.pre-commit-config.yaml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
exclude: "build|egg-info|dist"
22

33
repos:
4-
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v1.2.3
6-
hooks:
7-
- id: trailing-whitespace
8-
- id: check-added-large-files
9-
- id: end-of-file-fixer
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v1.2.3
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: check-added-large-files
9+
- id: end-of-file-fixer
1010

11-
- repo: https://github.com/ambv/black
12-
rev: stable
13-
hooks:
14-
- id: black
15-
language_version: python3.6
11+
- repo: https://github.com/ambv/black
12+
rev: stable
13+
hooks:
14+
- id: black
15+
language_version: python3.6
16+
- repo: local
17+
hooks:
18+
- id: clang-format
19+
name: Run clang-format
20+
entry: clang-format --style google -i
21+
types: [text]
22+
files: '.*\.cpp$|.*\.h$|.*\.cu$|.*\.hpp$'
23+
language: system

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ python -m unittest
2525

2626
## Projects using those kernels.
2727

28-
[```Pytorch Point Cloud Benchmark```](https://github.com/nicolas-chaulet/deeppointcloud-benchmarks) by
28+
[```Pytorch Point Cloud Benchmark```](https://github.com/nicolas-chaulet/deeppointcloud-benchmarks) by
2929
* [Thomas Chaton](https://github.com/tchaton)
3030
* Nicolas Chaulet
3131
* [Tristan Heywood](https://github.com/tristanheywood)

cpu/include/ball_query.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
#pragma once
22
#include <torch/extension.h>
33
std::pair<at::Tensor, at::Tensor> ball_query(at::Tensor query,
4-
at::Tensor support,
5-
float radius, int max_num, int mode);
4+
at::Tensor support, float radius,
5+
int max_num, int mode);
66

7-
std::pair<at::Tensor, at::Tensor> batch_ball_query(at::Tensor query,
8-
at::Tensor support,
9-
at::Tensor query_batch,
10-
at::Tensor support_batch,
11-
float radius, int max_num, int mode);
7+
std::pair<at::Tensor, at::Tensor> batch_ball_query(
8+
at::Tensor query, at::Tensor support, at::Tensor query_batch,
9+
at::Tensor support_batch, float radius, int max_num, int mode);
1210

1311
std::pair<at::Tensor, at::Tensor> dense_ball_query(at::Tensor query,
14-
at::Tensor support,
15-
float radius, int max_num, int mode);
12+
at::Tensor support,
13+
float radius, int max_num,
14+
int mode);

cpu/include/cloud.h

100755100644
Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -16,78 +16,77 @@
1616
// Hugues THOMAS - 10/02/2017
1717
//
1818

19+
#pragma once
1920

20-
# pragma once
21-
21+
#include <algorithm>
2222
#include <cmath>
23-
#include <vector>
24-
#include <unordered_map>
23+
#include <iomanip>
24+
#include <iostream>
2525
#include <map>
26-
#include <algorithm>
2726
#include <numeric>
28-
#include <iostream>
29-
#include <iomanip>
27+
#include <unordered_map>
28+
#include <vector>
3029

3130
#include <time.h>
3231

33-
34-
template<typename scalar_t>
35-
struct PointCloud
36-
{
37-
struct PointXYZ {
38-
scalar_t x,y,z;
39-
};
40-
41-
std::vector<PointXYZ> pts;
42-
43-
void set(std::vector<scalar_t> new_pts){
44-
45-
// pts = std::vector<PointXYZ>((PointXYZ*)new_pts, (PointXYZ*)new_pts+new_pts.size()/3);
46-
std::vector<PointXYZ> temp(new_pts.size()/3);
47-
for(unsigned int i=0; i < new_pts.size(); i++){
48-
if(i%3 == 0){
49-
50-
PointXYZ point;
51-
point.x = new_pts[i];
52-
point.y = new_pts[i+1];
53-
point.z = new_pts[i+2];
54-
temp[i/3] = point;
55-
}
56-
}
57-
pts = temp;
58-
}
59-
void set_batch(std::vector<scalar_t> new_pts, int begin, int size){
60-
61-
std::vector<PointXYZ> temp(size);
62-
for(int i=0; i < size; i++){
63-
PointXYZ point;
64-
point.x = new_pts[3*(begin+i)];
65-
point.y = new_pts[3*(begin+i) + 1];
66-
point.z = new_pts[3*(begin+i) + 2];
67-
temp[i] = point;
68-
69-
}
70-
pts = temp;
71-
}
72-
73-
// Must return the number of data points
74-
inline size_t kdtree_get_point_count() const { return pts.size(); }
75-
76-
// Returns the dim'th component of the idx'th point in the class:
77-
// Since this is inlined and the "dim" argument is typically an immediate value, the
78-
// "if/else's" are actually solved at compile time.
79-
inline scalar_t kdtree_get_pt(const size_t idx, const size_t dim) const
80-
{
81-
if (dim == 0) return pts[idx].x;
82-
else if (dim == 1) return pts[idx].y;
83-
else return pts[idx].z;
84-
}
85-
86-
// Optional bounding-box computation: return false to default to a standard bbox computation loop.
87-
// Return true if the BBOX was already computed by the class and returned in "bb" so it can be avoided to redo it again.
88-
// Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 for point clouds)
89-
template <class BBOX>
90-
bool kdtree_get_bbox(BBOX& /* bb */) const { return false; }
91-
92-
32+
template <typename scalar_t>
33+
struct PointCloud {
34+
struct PointXYZ {
35+
scalar_t x, y, z;
36+
};
37+
38+
std::vector<PointXYZ> pts;
39+
40+
void set(std::vector<scalar_t> new_pts) {
41+
// pts = std::vector<PointXYZ>((PointXYZ*)new_pts,
42+
// (PointXYZ*)new_pts+new_pts.size()/3);
43+
std::vector<PointXYZ> temp(new_pts.size() / 3);
44+
for (unsigned int i = 0; i < new_pts.size(); i++) {
45+
if (i % 3 == 0) {
46+
PointXYZ point;
47+
point.x = new_pts[i];
48+
point.y = new_pts[i + 1];
49+
point.z = new_pts[i + 2];
50+
temp[i / 3] = point;
51+
}
52+
}
53+
pts = temp;
54+
}
55+
void set_batch(std::vector<scalar_t> new_pts, int begin, int size) {
56+
std::vector<PointXYZ> temp(size);
57+
for (int i = 0; i < size; i++) {
58+
PointXYZ point;
59+
point.x = new_pts[3 * (begin + i)];
60+
point.y = new_pts[3 * (begin + i) + 1];
61+
point.z = new_pts[3 * (begin + i) + 2];
62+
temp[i] = point;
63+
}
64+
pts = temp;
65+
}
66+
67+
// Must return the number of data points
68+
inline size_t kdtree_get_point_count() const { return pts.size(); }
69+
70+
// Returns the dim'th component of the idx'th point in the class:
71+
// Since this is inlined and the "dim" argument is typically an immediate
72+
// value, the
73+
// "if/else's" are actually solved at compile time.
74+
inline scalar_t kdtree_get_pt(const size_t idx, const size_t dim) const {
75+
if (dim == 0)
76+
return pts[idx].x;
77+
else if (dim == 1)
78+
return pts[idx].y;
79+
else
80+
return pts[idx].z;
81+
}
82+
83+
// Optional bounding-box computation: return false to default to a standard
84+
// bbox computation loop.
85+
// Return true if the BBOX was already computed by the class and returned in
86+
// "bb" so it can be avoided to redo it again. Look at bb.size() to find out
87+
// the expected dimensionality (e.g. 2 or 3 for point clouds)
88+
template <class BBOX>
89+
bool kdtree_get_bbox(BBOX& /* bb */) const {
90+
return false;
91+
}
9392
};

cpu/include/group_points.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include <torch/extension.h>
2+
#include <torch/extension.h>
33

44
at::Tensor group_points(at::Tensor points, at::Tensor idx);
55
at::Tensor group_points_grad(at::Tensor grad_out, at::Tensor idx, const int n);

0 commit comments

Comments
 (0)