learning3d 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. {learning3d/data_utils → data_utils}/dataloaders.py +16 -14
  2. examples/test_curvenet.py +118 -0
  3. {learning3d/examples → examples}/test_dcp.py +3 -5
  4. {learning3d/examples → examples}/test_deepgmr.py +3 -5
  5. {learning3d/examples → examples}/test_masknet.py +1 -3
  6. {learning3d/examples → examples}/test_masknet2.py +1 -3
  7. {learning3d/examples → examples}/test_pcn.py +2 -4
  8. {learning3d/examples → examples}/test_pcrnet.py +1 -3
  9. {learning3d/examples → examples}/test_pnlk.py +1 -3
  10. {learning3d/examples → examples}/test_pointconv.py +1 -3
  11. {learning3d/examples → examples}/test_pointnet.py +1 -3
  12. {learning3d/examples → examples}/test_prnet.py +3 -5
  13. {learning3d/examples → examples}/test_rpmnet.py +1 -3
  14. {learning3d/examples → examples}/train_PointNetLK.py +2 -4
  15. {learning3d/examples → examples}/train_dcp.py +2 -4
  16. {learning3d/examples → examples}/train_deepgmr.py +2 -4
  17. {learning3d/examples → examples}/train_masknet.py +2 -4
  18. {learning3d/examples → examples}/train_pcn.py +2 -4
  19. {learning3d/examples → examples}/train_pcrnet.py +2 -4
  20. {learning3d/examples → examples}/train_pointconv.py +2 -4
  21. {learning3d/examples → examples}/train_pointnet.py +2 -4
  22. {learning3d/examples → examples}/train_prnet.py +2 -4
  23. {learning3d/examples → examples}/train_rpmnet.py +2 -4
  24. {learning3d-0.1.0.dist-info → learning3d-0.2.0.dist-info}/METADATA +56 -11
  25. learning3d-0.2.0.dist-info/RECORD +70 -0
  26. {learning3d-0.1.0.dist-info → learning3d-0.2.0.dist-info}/WHEEL +1 -1
  27. learning3d-0.2.0.dist-info/top_level.txt +6 -0
  28. {learning3d/models → models}/__init__.py +7 -1
  29. models/curvenet.py +130 -0
  30. {learning3d/models → models}/dgcnn.py +1 -35
  31. {learning3d/models → models}/prnet.py +5 -39
  32. utils/__init__.py +23 -0
  33. utils/curvenet_util.py +540 -0
  34. utils/model_common_utils.py +156 -0
  35. learning3d/losses/cuda/chamfer_distance/__init__.py +0 -1
  36. learning3d/losses/cuda/chamfer_distance/chamfer_distance.cpp +0 -185
  37. learning3d/losses/cuda/chamfer_distance/chamfer_distance.cu +0 -209
  38. learning3d/losses/cuda/chamfer_distance/chamfer_distance.py +0 -66
  39. learning3d/losses/cuda/emd_torch/pkg/emd_loss_layer.py +0 -41
  40. learning3d/losses/cuda/emd_torch/pkg/include/cuda/emd.cuh +0 -347
  41. learning3d/losses/cuda/emd_torch/pkg/include/cuda_helper.h +0 -18
  42. learning3d/losses/cuda/emd_torch/pkg/include/emd.h +0 -54
  43. learning3d/losses/cuda/emd_torch/pkg/layer/__init__.py +0 -1
  44. learning3d/losses/cuda/emd_torch/pkg/layer/emd_loss_layer.py +0 -40
  45. learning3d/losses/cuda/emd_torch/pkg/src/cuda/emd.cu +0 -70
  46. learning3d/losses/cuda/emd_torch/pkg/src/emd.cpp +0 -1
  47. learning3d/losses/cuda/emd_torch/setup.py +0 -29
  48. learning3d/ops/__init__.py +0 -0
  49. learning3d/utils/__init__.py +0 -4
  50. learning3d-0.1.0.dist-info/RECORD +0 -80
  51. learning3d-0.1.0.dist-info/top_level.txt +0 -1
  52. {learning3d/data_utils → data_utils}/__init__.py +0 -0
  53. {learning3d/data_utils → data_utils}/user_data.py +0 -0
  54. {learning3d-0.1.0.dist-info → learning3d-0.2.0.dist-info}/LICENSE +0 -0
  55. {learning3d/losses → losses}/__init__.py +0 -0
  56. {learning3d/losses → losses}/chamfer_distance.py +0 -0
  57. {learning3d/losses → losses}/classification.py +0 -0
  58. {learning3d/losses → losses}/correspondence_loss.py +0 -0
  59. {learning3d/losses → losses}/emd.py +0 -0
  60. {learning3d/losses → losses}/frobenius_norm.py +0 -0
  61. {learning3d/losses → losses}/rmse_features.py +0 -0
  62. {learning3d/models → models}/classifier.py +0 -0
  63. {learning3d/models → models}/dcp.py +0 -0
  64. {learning3d/models → models}/deepgmr.py +0 -0
  65. {learning3d/models → models}/masknet.py +0 -0
  66. {learning3d/models → models}/masknet2.py +0 -0
  67. {learning3d/models → models}/pcn.py +0 -0
  68. {learning3d/models → models}/pcrnet.py +0 -0
  69. {learning3d/models → models}/pointconv.py +0 -0
  70. {learning3d/models → models}/pointnet.py +0 -0
  71. {learning3d/models → models}/pointnetlk.py +0 -0
  72. {learning3d/models → models}/pooling.py +0 -0
  73. {learning3d/models → models}/ppfnet.py +0 -0
  74. {learning3d/models → models}/rpmnet.py +0 -0
  75. {learning3d/models → models}/segmentation.py +0 -0
  76. {learning3d → ops}/__init__.py +0 -0
  77. {learning3d/ops → ops}/data_utils.py +0 -0
  78. {learning3d/ops → ops}/invmat.py +0 -0
  79. {learning3d/ops → ops}/quaternion.py +0 -0
  80. {learning3d/ops → ops}/se3.py +0 -0
  81. {learning3d/ops → ops}/sinc.py +0 -0
  82. {learning3d/ops → ops}/so3.py +0 -0
  83. {learning3d/ops → ops}/transform_functions.py +0 -0
  84. {learning3d/utils → utils}/pointconv_util.py +0 -0
  85. {learning3d/utils → utils}/ppfnet_util.py +0 -0
  86. {learning3d/utils → utils}/svd.py +0 -0
  87. {learning3d/utils → utils}/transformer.py +0 -0
@@ -1,347 +0,0 @@
1
- #ifndef EMD_CUH_
2
- #define EMD_CUH_
3
-
4
- #include "cuda_helper.h"
5
-
6
- template<typename T>
7
- __global__ void approxmatch(const int b, const int n, const int m, const T * __restrict__ xyz1, const T * __restrict__ xyz2, T * __restrict__ match, T * temp){
8
- T * remainL=temp+blockIdx.x*(n+m)*2, * remainR=temp+blockIdx.x*(n+m)*2+n,*ratioL=temp+blockIdx.x*(n+m)*2+n+m,*ratioR=temp+blockIdx.x*(n+m)*2+n+m+n;
9
- T multiL,multiR;
10
- if (n>=m){
11
- multiL=1;
12
- multiR=n/m;
13
- }else{
14
- multiL=m/n;
15
- multiR=1;
16
- }
17
- const int Block=1024;
18
- __shared__ T buf[Block*4];
19
- for (int i=blockIdx.x;i<b;i+=gridDim.x){
20
- for (int j=threadIdx.x;j<n*m;j+=blockDim.x)
21
- match[i*n*m+j]=0;
22
- for (int j=threadIdx.x;j<n;j+=blockDim.x)
23
- remainL[j]=multiL;
24
- for (int j=threadIdx.x;j<m;j+=blockDim.x)
25
- remainR[j]=multiR;
26
- __syncthreads();
27
- for (int j=7;j>=-2;j--){
28
- T level=-powf(4.0f,j);
29
- if (j==-2){
30
- level=0;
31
- }
32
- for (int k0=0;k0<n;k0+=blockDim.x){
33
- int k=k0+threadIdx.x;
34
- T x1=0,y1=0,z1=0;
35
- if (k<n){
36
- x1=xyz1[i*n*3+k*3+0];
37
- y1=xyz1[i*n*3+k*3+1];
38
- z1=xyz1[i*n*3+k*3+2];
39
- }
40
- T suml=T(1e-9f);
41
- for (int l0=0;l0<m;l0+=Block){
42
- int lend=min(m,l0+Block)-l0;
43
- for (int l=threadIdx.x;l<lend;l+=blockDim.x){
44
- T x2=xyz2[i*m*3+l0*3+l*3+0];
45
- T y2=xyz2[i*m*3+l0*3+l*3+1];
46
- T z2=xyz2[i*m*3+l0*3+l*3+2];
47
- buf[l*4+0]=x2;
48
- buf[l*4+1]=y2;
49
- buf[l*4+2]=z2;
50
- buf[l*4+3]=remainR[l0+l];
51
- }
52
- __syncthreads();
53
- for (int l=0;l<lend;l++){
54
- T x2=buf[l*4+0];
55
- T y2=buf[l*4+1];
56
- T z2=buf[l*4+2];
57
- T d=level*((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
58
- T w=__expf(d)*buf[l*4+3];
59
- suml+=w;
60
- }
61
- __syncthreads();
62
- }
63
- if (k<n)
64
- ratioL[k]=remainL[k]/suml;
65
- }
66
- /*for (int k=threadIdx.x;k<n;k+=gridDim.x){
67
- T x1=xyz1[i*n*3+k*3+0];
68
- T y1=xyz1[i*n*3+k*3+1];
69
- T z1=xyz1[i*n*3+k*3+2];
70
- T suml=1e-9f;
71
- for (int l=0;l<m;l++){
72
- T x2=xyz2[i*m*3+l*3+0];
73
- T y2=xyz2[i*m*3+l*3+1];
74
- T z2=xyz2[i*m*3+l*3+2];
75
- T w=expf(level*((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)))*remainR[l];
76
- suml+=w;
77
- }
78
- ratioL[k]=remainL[k]/suml;
79
- }*/
80
- __syncthreads();
81
- for (int l0=0;l0<m;l0+=blockDim.x){
82
- int l=l0+threadIdx.x;
83
- T x2=0,y2=0,z2=0;
84
- if (l<m){
85
- x2=xyz2[i*m*3+l*3+0];
86
- y2=xyz2[i*m*3+l*3+1];
87
- z2=xyz2[i*m*3+l*3+2];
88
- }
89
- T sumr=0;
90
- for (int k0=0;k0<n;k0+=Block){
91
- int kend=min(n,k0+Block)-k0;
92
- for (int k=threadIdx.x;k<kend;k+=blockDim.x){
93
- buf[k*4+0]=xyz1[i*n*3+k0*3+k*3+0];
94
- buf[k*4+1]=xyz1[i*n*3+k0*3+k*3+1];
95
- buf[k*4+2]=xyz1[i*n*3+k0*3+k*3+2];
96
- buf[k*4+3]=ratioL[k0+k];
97
- }
98
- __syncthreads();
99
- for (int k=0;k<kend;k++){
100
- T x1=buf[k*4+0];
101
- T y1=buf[k*4+1];
102
- T z1=buf[k*4+2];
103
- T w=__expf(level*((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)))*buf[k*4+3];
104
- sumr+=w;
105
- }
106
- __syncthreads();
107
- }
108
- if (l<m){
109
- sumr*=remainR[l];
110
- T consumption=fminf(remainR[l]/(sumr+1e-9f),1.0f);
111
- ratioR[l]=consumption*remainR[l];
112
- remainR[l]=fmaxf(0.0f,remainR[l]-sumr);
113
- }
114
- }
115
- /*for (int l=threadIdx.x;l<m;l+=blockDim.x){
116
- T x2=xyz2[i*m*3+l*3+0];
117
- T y2=xyz2[i*m*3+l*3+1];
118
- T z2=xyz2[i*m*3+l*3+2];
119
- T sumr=0;
120
- for (int k=0;k<n;k++){
121
- T x1=xyz1[i*n*3+k*3+0];
122
- T y1=xyz1[i*n*3+k*3+1];
123
- T z1=xyz1[i*n*3+k*3+2];
124
- T w=expf(level*((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)))*ratioL[k];
125
- sumr+=w;
126
- }
127
- sumr*=remainR[l];
128
- T consumption=fminf(remainR[l]/(sumr+1e-9f),1.0f);
129
- ratioR[l]=consumption*remainR[l];
130
- remainR[l]=fmaxf(0.0f,remainR[l]-sumr);
131
- }*/
132
- __syncthreads();
133
- for (int k0=0;k0<n;k0+=blockDim.x){
134
- int k=k0+threadIdx.x;
135
- T x1=0,y1=0,z1=0;
136
- if (k<n){
137
- x1=xyz1[i*n*3+k*3+0];
138
- y1=xyz1[i*n*3+k*3+1];
139
- z1=xyz1[i*n*3+k*3+2];
140
- }
141
- T suml=0;
142
- for (int l0=0;l0<m;l0+=Block){
143
- int lend=min(m,l0+Block)-l0;
144
- for (int l=threadIdx.x;l<lend;l+=blockDim.x){
145
- buf[l*4+0]=xyz2[i*m*3+l0*3+l*3+0];
146
- buf[l*4+1]=xyz2[i*m*3+l0*3+l*3+1];
147
- buf[l*4+2]=xyz2[i*m*3+l0*3+l*3+2];
148
- buf[l*4+3]=ratioR[l0+l];
149
- }
150
- __syncthreads();
151
- T rl=ratioL[k];
152
- if (k<n){
153
- for (int l=0;l<lend;l++){
154
- T x2=buf[l*4+0];
155
- T y2=buf[l*4+1];
156
- T z2=buf[l*4+2];
157
- T w=__expf(level*((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)))*rl*buf[l*4+3];
158
- match[i*n*m+(l0+l)*n+k]+=w;
159
- suml+=w;
160
- }
161
- }
162
- __syncthreads();
163
- }
164
- if (k<n)
165
- remainL[k]=fmaxf(0.0f,remainL[k]-suml);
166
- }
167
- /*for (int k=threadIdx.x;k<n;k+=blockDim.x){
168
- T x1=xyz1[i*n*3+k*3+0];
169
- T y1=xyz1[i*n*3+k*3+1];
170
- T z1=xyz1[i*n*3+k*3+2];
171
- T suml=0;
172
- for (int l=0;l<m;l++){
173
- T x2=xyz2[i*m*3+l*3+0];
174
- T y2=xyz2[i*m*3+l*3+1];
175
- T z2=xyz2[i*m*3+l*3+2];
176
- T w=expf(level*((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)))*ratioL[k]*ratioR[l];
177
- match[i*n*m+l*n+k]+=w;
178
- suml+=w;
179
- }
180
- remainL[k]=fmaxf(0.0f,remainL[k]-suml);
181
- }*/
182
- __syncthreads();
183
- }
184
- }
185
- }
186
-
187
- void approxmatchLauncher(const int b, const int n, const int m, const at::Tensor xyz1, const at::Tensor xyz2, at::Tensor match, at::Tensor temp){
188
- AT_DISPATCH_FLOATING_TYPES(match.type(), "approxmatch", ([&] {
189
- approxmatch
190
- <<<32, 512>>>(
191
- b, n, m,
192
- xyz1.data<scalar_t>(),
193
- xyz2.data<scalar_t>(),
194
- match.data<scalar_t>(),
195
- temp.data<scalar_t>());
196
- }));
197
- cudaDeviceSynchronize();
198
- CUDA_CHECK(cudaGetLastError())
199
- }
200
-
201
- template<typename T>
202
- __global__ void matchcost(const int b, const int n, const int m, const T * __restrict__ xyz1, const T * __restrict__ xyz2, const T * __restrict__ match, T * __restrict__ out){
203
- __shared__ T allsum[512];
204
- const int Block=1024;
205
- __shared__ T buf[Block*3];
206
- for (int i=blockIdx.x;i<b;i+=gridDim.x){
207
- T subsum=0;
208
- for (int k0=0;k0<n;k0+=blockDim.x){
209
- int k=k0+threadIdx.x;
210
- T x1=0,y1=0,z1=0;
211
- if (k<n){
212
- x1=xyz1[i*n*3+k*3+0];
213
- y1=xyz1[i*n*3+k*3+1];
214
- z1=xyz1[i*n*3+k*3+2];
215
- }
216
- for (int l0=0;l0<m;l0+=Block){
217
- int lend=min(m,l0+Block)-l0;
218
- for (int l=threadIdx.x;l<lend*3;l+=blockDim.x)
219
- buf[l]=xyz2[i*m*3+l0*3+l];
220
- __syncthreads();
221
- if (k<n){
222
- for (int l=0;l<lend;l++){
223
- T x2=buf[l*3+0];
224
- T y2=buf[l*3+1];
225
- T z2=buf[l*3+2];
226
- T d=sqrtf((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
227
- subsum+=d*match[i*n*m+(l0+l)*n+k];
228
- }
229
- }
230
- __syncthreads();
231
- }
232
- }
233
- allsum[threadIdx.x]=subsum;
234
- for (int j=1;j<blockDim.x;j<<=1){
235
- __syncthreads();
236
- if ((threadIdx.x&j)==0 && threadIdx.x+j<blockDim.x){
237
- allsum[threadIdx.x]+=allsum[threadIdx.x+j];
238
- }
239
- }
240
- if (threadIdx.x==0)
241
- out[i]=allsum[0];
242
- __syncthreads();
243
- }
244
- }
245
-
246
- void matchcostLauncher(const int b, const int n, const int m, const at::Tensor xyz1, const at::Tensor xyz2, const at::Tensor match, at::Tensor out){
247
- AT_DISPATCH_FLOATING_TYPES(xyz1.type(), "matchcost", ([&] {
248
- matchcost<<<32, 512>>>(
249
- b, n, m,
250
- xyz1.data<scalar_t>(),
251
- xyz2.data<scalar_t>(),
252
- match.data<scalar_t>(),
253
- out.data<scalar_t>());
254
- }));
255
- CUDA_CHECK(cudaGetLastError())
256
- }
257
-
258
- template <typename T>
259
- __global__ void matchcostgrad2(const int b, const int n, const int m,const T * __restrict__ xyz1, const T * __restrict__ xyz2, const T * __restrict__ match, T * __restrict__ grad2){
260
- __shared__ T sum_grad[256*3];
261
- for (int i=blockIdx.x;i<b;i+=gridDim.x){
262
- int kbeg=m*blockIdx.y/gridDim.y;
263
- int kend=m*(blockIdx.y+1)/gridDim.y;
264
- for (int k=kbeg;k<kend;k++){
265
- T x2=xyz2[(i*m+k)*3+0];
266
- T y2=xyz2[(i*m+k)*3+1];
267
- T z2=xyz2[(i*m+k)*3+2];
268
- T subsumx=0,subsumy=0,subsumz=0;
269
- for (int j=threadIdx.x;j<n;j+=blockDim.x){
270
- T x1=x2-xyz1[(i*n+j)*3+0];
271
- T y1=y2-xyz1[(i*n+j)*3+1];
272
- T z1=z2-xyz1[(i*n+j)*3+2];
273
- T d=match[i*n*m+k*n+j]*rsqrtf(fmaxf(x1*x1+y1*y1+z1*z1,1e-20f));
274
- subsumx+=x1*d;
275
- subsumy+=y1*d;
276
- subsumz+=z1*d;
277
- }
278
- sum_grad[threadIdx.x*3+0]=subsumx;
279
- sum_grad[threadIdx.x*3+1]=subsumy;
280
- sum_grad[threadIdx.x*3+2]=subsumz;
281
- for (int j=1;j<blockDim.x;j<<=1){
282
- __syncthreads();
283
- int j1=threadIdx.x;
284
- int j2=threadIdx.x+j;
285
- if ((j1&j)==0 && j2<blockDim.x){
286
- sum_grad[j1*3+0]+=sum_grad[j2*3+0];
287
- sum_grad[j1*3+1]+=sum_grad[j2*3+1];
288
- sum_grad[j1*3+2]+=sum_grad[j2*3+2];
289
- }
290
- }
291
- if (threadIdx.x==0){
292
- grad2[(i*m+k)*3+0]=sum_grad[0];
293
- grad2[(i*m+k)*3+1]=sum_grad[1];
294
- grad2[(i*m+k)*3+2]=sum_grad[2];
295
- }
296
- __syncthreads();
297
- }
298
- }
299
- }
300
-
301
- template <typename T>
302
- __global__ void matchcostgrad1(const int b, const int n, const int m, const T * __restrict__ xyz1, const T * __restrict__ xyz2, const T * __restrict__ match, T * __restrict__ grad1){
303
- for (int i=blockIdx.x;i<b;i+=gridDim.x){
304
- for (int l=threadIdx.x;l<n;l+=blockDim.x){
305
- T x1=xyz1[i*n*3+l*3+0];
306
- T y1=xyz1[i*n*3+l*3+1];
307
- T z1=xyz1[i*n*3+l*3+2];
308
- T dx=0,dy=0,dz=0;
309
- for (int k=0;k<m;k++){
310
- T x2=xyz2[i*m*3+k*3+0];
311
- T y2=xyz2[i*m*3+k*3+1];
312
- T z2=xyz2[i*m*3+k*3+2];
313
- T d=match[i*n*m+k*n+l]*rsqrtf(fmaxf((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2),1e-20f));
314
- dx+=(x1-x2)*d;
315
- dy+=(y1-y2)*d;
316
- dz+=(z1-z2)*d;
317
- }
318
- grad1[i*n*3+l*3+0]=dx;
319
- grad1[i*n*3+l*3+1]=dy;
320
- grad1[i*n*3+l*3+2]=dz;
321
- }
322
- }
323
- }
324
-
325
- void matchcostgradLauncher(const int b, const int n, const int m, const at::Tensor xyz1, const at::Tensor xyz2, const at::Tensor match, at::Tensor grad1, at::Tensor grad2){
326
- AT_DISPATCH_FLOATING_TYPES(xyz1.type(), "matchcostgrad1", ([&] {
327
- matchcostgrad1<<<32,512>>>(
328
- b, n, m,
329
- xyz1.data<scalar_t>(),
330
- xyz2.data<scalar_t>(),
331
- match.data<scalar_t>(),
332
- grad1.data<scalar_t>());
333
- }));
334
- CUDA_CHECK(cudaGetLastError())
335
-
336
- AT_DISPATCH_FLOATING_TYPES(xyz1.type(), "matchcostgrad2", ([&] {
337
- matchcostgrad2<<<dim3(32,32),256>>>(
338
- b, n, m,
339
- xyz1.data<scalar_t>(),
340
- xyz2.data<scalar_t>(),
341
- match.data<scalar_t>(),
342
- grad2.data<scalar_t>());
343
- }));
344
- CUDA_CHECK(cudaGetLastError())
345
- }
346
-
347
- #endif
@@ -1,18 +0,0 @@
1
- #ifndef CUDA_HELPER_H_
2
- #define CUDA_HELPER_H_
3
-
4
- #define CUDA_CHECK(err) \
5
- if (cudaSuccess != err) \
6
- { \
7
- fprintf(stderr, "CUDA kernel failed: %s (%s:%d)\n", \
8
- cudaGetErrorString(err), __FILE__, __LINE__); \
9
- std::exit(-1); \
10
- }
11
-
12
- #define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), \
13
- #x " must be a CUDA tensor")
14
- #define CHECK_CONTIGUOUS(x) AT_CHECK(x.is_contiguous(), \
15
- #x " must be contiguous")
16
- #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)
17
-
18
- #endif
@@ -1,54 +0,0 @@
1
- #ifndef EMD_H_
2
- #define EMD_H_
3
-
4
- #include <torch/extension.h>
5
- #include <vector>
6
-
7
- #include "cuda_helper.h"
8
-
9
-
10
- std::vector<at::Tensor> emd_forward_cuda(
11
- at::Tensor xyz1,
12
- at::Tensor xyz2);
13
-
14
- std::vector<at::Tensor> emd_backward_cuda(
15
- at::Tensor xyz1,
16
- at::Tensor xyz2,
17
- at::Tensor match);
18
-
19
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
20
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
21
- // CALL FUNCTION IMPLEMENTATIONS
22
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
23
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
24
-
25
- std::vector<at::Tensor> emd_forward(
26
- at::Tensor xyz1,
27
- at::Tensor xyz2)
28
- {
29
- CHECK_INPUT(xyz1);
30
- CHECK_INPUT(xyz2);
31
-
32
- return emd_forward_cuda(xyz1, xyz2);
33
- }
34
-
35
- std::vector<at::Tensor> emd_backward(
36
- at::Tensor xyz1,
37
- at::Tensor xyz2,
38
- at::Tensor match)
39
- {
40
- CHECK_INPUT(xyz1);
41
- CHECK_INPUT(xyz2);
42
- CHECK_INPUT(match);
43
-
44
- return emd_backward_cuda(xyz1, xyz2, match);
45
- }
46
-
47
- PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
48
- m.def("emd_forward", &emd_forward, "Compute Earth Mover's Distance");
49
- m.def("emd_backward", &emd_backward, "Compute Gradients for Earth Mover's Distance");
50
- }
51
-
52
-
53
-
54
- #endif
@@ -1 +0,0 @@
1
- from .emd_loss_layer import EMDLoss
@@ -1,40 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- import _emd_ext._emd as emd
5
-
6
-
7
- class EMDFunction(torch.autograd.Function):
8
- @staticmethod
9
- def forward(self, xyz1, xyz2):
10
- cost, match = emd.emd_forward(xyz1, xyz2)
11
- self.save_for_backward(xyz1, xyz2, match)
12
- return cost
13
-
14
-
15
- @staticmethod
16
- def backward(self, grad_output):
17
- xyz1, xyz2, match = self.saved_tensors
18
- grad_xyz1, grad_xyz2 = emd.emd_backward(xyz1, xyz2, match)
19
- return grad_xyz1, grad_xyz2
20
-
21
-
22
-
23
-
24
- class EMDLoss(nn.Module):
25
- '''
26
- Computes the (approximate) Earth Mover's Distance between two point sets.
27
-
28
- IMPLEMENTATION LIMITATIONS:
29
- - Double tensors must have <=11 dimensions
30
- - Float tensors must have <=23 dimensions
31
- This is due to the use of CUDA shared memory in the computation. This shared memory is limited by the hardware to 48kB.
32
- '''
33
-
34
- def __init__(self):
35
- super(EMDLoss, self).__init__()
36
-
37
- def forward(self, xyz1, xyz2):
38
-
39
- assert xyz1.shape[-1] == xyz2.shape[-1], 'Both point sets must have the same dimensionality'
40
- return EMDFunction.apply(xyz1, xyz2)
@@ -1,70 +0,0 @@
1
- #include <ATen/ATen.h>
2
-
3
- #include <vector>
4
-
5
- #include "cuda/emd.cuh"
6
-
7
-
8
- std::vector<at::Tensor> emd_forward_cuda(
9
- at::Tensor xyz1, // B x N1 x D
10
- at::Tensor xyz2) // B x N2 x D
11
- {
12
- // Some useful values
13
- const int batch_size = xyz1.size(0);
14
- const int num_pts_1 = xyz1.size(1);
15
- const int num_pts_2 = xyz2.size(1);
16
-
17
- // Allocate necessary data structures
18
- at::Tensor match = at::zeros({batch_size, num_pts_1, num_pts_2},
19
- xyz1.options());
20
- at::Tensor cost = at::zeros({batch_size}, xyz1.options());
21
- at::Tensor temp = at::zeros({batch_size, 2 * (num_pts_1 + num_pts_2)},
22
- xyz1.options());
23
-
24
- // Find the approximate matching
25
- approxmatchLauncher(
26
- batch_size, num_pts_1, num_pts_2,
27
- xyz1,
28
- xyz2,
29
- match,
30
- temp
31
- );
32
-
33
- // Compute the matching cost
34
- matchcostLauncher(
35
- batch_size, num_pts_1, num_pts_2,
36
- xyz1,
37
- xyz2,
38
- match,
39
- cost
40
- );
41
-
42
- return {cost, match};
43
- }
44
-
45
- std::vector<at::Tensor> emd_backward_cuda(
46
- at::Tensor xyz1,
47
- at::Tensor xyz2,
48
- at::Tensor match)
49
- {
50
- // Some useful values
51
- const int batch_size = xyz1.size(0);
52
- const int num_pts_1 = xyz1.size(1);
53
- const int num_pts_2 = xyz2.size(1);
54
-
55
- // Allocate necessary data structures
56
- at::Tensor grad_xyz1 = at::zeros_like(xyz1);
57
- at::Tensor grad_xyz2 = at::zeros_like(xyz2);
58
-
59
- // Compute the gradient with respect to the two inputs (xyz1 and xyz2)
60
- matchcostgradLauncher(
61
- batch_size, num_pts_1, num_pts_2,
62
- xyz1,
63
- xyz2,
64
- match,
65
- grad_xyz1,
66
- grad_xyz2
67
- );
68
-
69
- return {grad_xyz1, grad_xyz2};
70
- }
@@ -1 +0,0 @@
1
- #include "emd.h"
@@ -1,29 +0,0 @@
1
- from setuptools import setup
2
- from torch.utils.cpp_extension import BuildExtension, CUDAExtension
3
-
4
-
5
- setup(
6
- name='PyTorch EMD',
7
- version='0.0',
8
- author='Vinit Sarode',
9
- author_email='vinitsarode5@gmail.com',
10
- description='A PyTorch module for the earth mover\'s distance loss',
11
- ext_package='_emd_ext',
12
- ext_modules=[
13
- CUDAExtension(
14
- name='_emd',
15
- sources=[
16
- 'pkg/src/emd.cpp',
17
- 'pkg/src/cuda/emd.cu',
18
- ],
19
- include_dirs=['pkg/include'],
20
- ),
21
- ],
22
- packages=[
23
- 'emd',
24
- ],
25
- package_dir={
26
- 'emd' : 'pkg/layer'
27
- },
28
- cmdclass={'build_ext': BuildExtension},
29
- )
File without changes
@@ -1,4 +0,0 @@
1
- from .svd import SVDHead
2
- from .transformer import Transformer, Identity
3
- from .ppfnet_util import angle_difference, square_distance, index_points, farthest_point_sample, query_ball_point, sample_and_group, sample_and_group_multi
4
- from .pointconv_util import PointConvDensitySetAbstraction
@@ -1,80 +0,0 @@
1
- learning3d/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- learning3d/data_utils/__init__.py,sha256=iYAVh0FThnVlG42QIgmDYrC3NGVYuzKX8s1oRqAI1YU,261
3
- learning3d/data_utils/dataloaders.py,sha256=QlRd7c7ir19bMliZXq9PF-iNrQ_BtNTonpBCpmjYiFU,14675
4
- learning3d/data_utils/user_data.py,sha256=ADDGeCUCr6TcXhcxvAFncIeLO71xoRHYi4H418ktvQs,4828
5
- learning3d/examples/test_dcp.py,sha256=EYXgCz0yh2-bjJE9s8XEUY96LfUE9_hZcdMffyrW3x0,5783
6
- learning3d/examples/test_deepgmr.py,sha256=f9nv7Y5se9_iZ3UGasTUDnErBZh3FX0fRNY4IqeqjCk,5774
7
- learning3d/examples/test_masknet.py,sha256=-xiGaaG9SN_u1POh51sM358QFsyx9QoYIhaNWtBNCXY,6558
8
- learning3d/examples/test_masknet2.py,sha256=ABNDRa9R6Sp9S_H1euj2bx3LnLt6ONKRNvp5bat0jAQ,7012
9
- learning3d/examples/test_pcn.py,sha256=rvKsqbCRmj4CLU1xWI-VzUh63t89QY6sIHi-39uhzmM,4519
10
- learning3d/examples/test_pcrnet.py,sha256=JTq7rQN5cFxucVD-0gQ6t0K0ASuX4b_sNI7uxgUKsdg,4519
11
- learning3d/examples/test_pnlk.py,sha256=WhZfD9s-YUg-nne_JCOSIcs0akJJV30G19QBkMVK2gc,4609
12
- learning3d/examples/test_pointconv.py,sha256=CA-Z3KLGXtqkCWIUi1IIlpaHCyTMMd5QuNyi37D8Iz8,4826
13
- learning3d/examples/test_pointnet.py,sha256=Cd0h-x4UcuiV-hDVMeriOYN75-uc_ZQ34mn2ikLEIbg,4477
14
- learning3d/examples/test_prnet.py,sha256=F5Ju6BafuDocPa3qMa9ZDASaE9zP_5vgp1hgRkpIvso,5078
15
- learning3d/examples/test_rpmnet.py,sha256=dKORbcOuil2qlUrY5VdHtaUUOGxDc8Paj7FVYmcHqEs,4629
16
- learning3d/examples/train_PointNetLK.py,sha256=MnYJuU1ThTLRSuylqXZp6Eakeggk2Xd99BJuTyVIvxI,8950
17
- learning3d/examples/train_dcp.py,sha256=QcyFKKCKwUH3RDUQU7-eET7Q3tIc5hLGlBBrMwv4ans,9688
18
- learning3d/examples/train_deepgmr.py,sha256=I9GBE78u5tVrKo0zmRDjrTk0Lq-R8TRH27mEKYJU5us,9574
19
- learning3d/examples/train_masknet.py,sha256=MRlySX4Llfp_0Eu8jwkHg3FdLlWLtlB4tVUNFbSsBbM,9066
20
- learning3d/examples/train_pcn.py,sha256=QKJLY31Hcx8w2K4XhmY3U3zho5vFePEWr7xHo4fAUvY,7719
21
- learning3d/examples/train_pcrnet.py,sha256=pUBYK1gtDFhBBon1UBF2yB5-2cGhILkntmplOYRBqiQ,8375
22
- learning3d/examples/train_pointconv.py,sha256=Vn_WghOFYOOiL-U7yJQ3TB7osYTLbwEQ1WVWTvBhPVs,9116
23
- learning3d/examples/train_pointnet.py,sha256=bpPMt0QtUoJlVgoMoPX191sO25VCk14pIKdBTCPS62I,9017
24
- learning3d/examples/train_prnet.py,sha256=aruTiJB8WCad0cbsu5XdfhMSybdibWSGRPilbzi6xWI,8550
25
- learning3d/examples/train_rpmnet.py,sha256=Q_kB7UnRdcIpFk_w47oNcuhIsmHLLij4dS7vz2GzTIY,8707
26
- learning3d/losses/__init__.py,sha256=zjjZeA_NvAhZlxiYBbtgjEsvMyLFhFWXlZioitrlGWw,425
27
- learning3d/losses/chamfer_distance.py,sha256=UTZ6x5cGwL3L5hJZOWoC35gTzcKh1S0yCg8vGuGXU1w,2121
28
- learning3d/losses/classification.py,sha256=QgDHC5VgSga6BiuD4Ee70t6vvchlE97BY0KExevhdgk,374
29
- learning3d/losses/correspondence_loss.py,sha256=Tcq2o5eLY7j50pibAuH0vBcUTjwZ-wHNzGZD4H6mAe0,583
30
- learning3d/losses/emd.py,sha256=DqP77dN6lPkpGGgBz10oO6YNYxt889weYbVYj6bZFUM,389
31
- learning3d/losses/frobenius_norm.py,sha256=IuKr0DT9aPBlc5fjIy6lJ082yOh9F8xiNoXF6FvWZtY,682
32
- learning3d/losses/rmse_features.py,sha256=_KMqIWqH9-lH2P6YSeGfSOIbP7plUAwWWBh2Cu7cpXA,453
33
- learning3d/losses/cuda/chamfer_distance/__init__.py,sha256=5nz6Ui4PVKru4HLGovFue3M-eumQlovMYP6Qfk3O6SE,46
34
- learning3d/losses/cuda/chamfer_distance/chamfer_distance.cpp,sha256=rcknAz6oYPhlTVjGnAga2c4bMz2rz_UU9ch7zrcmWoc,6260
35
- learning3d/losses/cuda/chamfer_distance/chamfer_distance.cu,sha256=7-UQ8QVcSQ1tbN7xwDNQQfpbG-S5b7KuSv0nCBYlhI8,5070
36
- learning3d/losses/cuda/chamfer_distance/chamfer_distance.py,sha256=vzF4GdkgdD5Rr3F6pk1u1kF1LpiFKpLTZcd-H1IVu3s,1926
37
- learning3d/losses/cuda/emd_torch/setup.py,sha256=AUvCT6EI2fOcCbyzrGscvCKu5gLhjofmZ-PfNBY2dNw,574
38
- learning3d/losses/cuda/emd_torch/pkg/emd_loss_layer.py,sha256=FMfOoT8VF05Ns6_BaF6tquT5B9T7man0WtKJ9lPRfk8,1116
39
- learning3d/losses/cuda/emd_torch/pkg/include/cuda_helper.h,sha256=8uVFZEr7YWVMPqHqfu_5lLUHCDjgwE0bJc-MUhmbLRk,469
40
- learning3d/losses/cuda/emd_torch/pkg/include/emd.h,sha256=5TF1_V_OFywM8ftegQGw0YpdgPAzg6UolJ4OOFG5rVM,1215
41
- learning3d/losses/cuda/emd_torch/pkg/include/cuda/emd.cuh,sha256=XliqHIePtL73Kdh0eDlRLalNmP3KqzwAEcgWysAOnNs,9826
42
- learning3d/losses/cuda/emd_torch/pkg/layer/__init__.py,sha256=aDpfP0iZyg3Uu-ppa33u2imCsmlvKSf5S8QhLnGfwyI,35
43
- learning3d/losses/cuda/emd_torch/pkg/layer/emd_loss_layer.py,sha256=yCEEfafLZ1Ia_BCrE7mcnDRDaaEj6je3Rj8cnQ_Zrts,1019
44
- learning3d/losses/cuda/emd_torch/pkg/src/emd.cpp,sha256=lQ4q2XO5K2CldYmnRJnGhKTR9hVRFTwO305bHT3Cauo,17
45
- learning3d/losses/cuda/emd_torch/pkg/src/cuda/emd.cu,sha256=DJXALRWyiVDzaKWsD2tQnEXrIT9GpIldkvIJ9fZMGbI,1462
46
- learning3d/models/__init__.py,sha256=WgAx7FlaUbijjl3qjQCvwyrbdhxvKHV7HbqBlq47ux8,473
47
- learning3d/models/classifier.py,sha256=_LUNXbLrpKNXmCkO2R1mz64dbwfrze7f_4SYT1Z6SYo,1205
48
- learning3d/models/dcp.py,sha256=LZFgtk9f9f9s3QvX65nFXGgC33yGIZuy4XjviwH8OGE,3377
49
- learning3d/models/deepgmr.py,sha256=vIxOQrZjvOCHLElJCjZ8EcZ-vm0-v71IKsPGuSF-elE,5298
50
- learning3d/models/dgcnn.py,sha256=Bt-dP2NwpOy4AcWrspXfVV1EKL-ZQElYUp2uaWNvE_Q,3057
51
- learning3d/models/masknet.py,sha256=ElMF3b-JgYmgwSEf1taGQvhA7Xy7_MiHEofzc03VCd8,2705
52
- learning3d/models/masknet2.py,sha256=6lgukurfzUOY-6xdCpMljOYFtvADLSczAXJzRC3Jkh4,9063
53
- learning3d/models/pcn.py,sha256=FvpjLR6t3kFQ1I4Fhpbsaj_P8Ml6S912x36JAZ1dUKs,5346
54
- learning3d/models/pcrnet.py,sha256=6C6iM3XkDNdgihtPIdy09RgFD2KKDCnDzLvFfp6X-Tg,2755
55
- learning3d/models/pointconv.py,sha256=lJ3_3uslE29lO3roZiE5vxr5971AWV5ExeVTzbEl858,5151
56
- learning3d/models/pointnet.py,sha256=qgSWLJ4N5Y7ObAwKiJH29Pcl67jm3sfqbXqi3tQbUQg,3238
57
- learning3d/models/pointnetlk.py,sha256=Zl66LjDX1vLdZRgCdY2oQJnpWpqPEx6BH8GbcVCsw68,5805
58
- learning3d/models/pooling.py,sha256=vOzJMambeG7kf1pnox5p5FE2CVH2iMDGU_DgWRw15WQ,412
59
- learning3d/models/ppfnet.py,sha256=aBzWvtNHFo-eu1kWoZmPI9xJOFHyxYHjdapb6cN2Aso,2894
60
- learning3d/models/prnet.py,sha256=KSTTMEUgEvE2PX59Mqas48LQUYyh8O6PwOHvP8zEYHU,18499
61
- learning3d/models/rpmnet.py,sha256=eMVqJ6BalY96TSB8VFXjCJIA15J0XAB3BEpMB-6CMdM,11517
62
- learning3d/models/segmentation.py,sha256=CjlINj5M0Y6C-CejrieIu9ZkuwEoCFNjq_hr5SX9umU,1166
63
- learning3d/ops/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
- learning3d/ops/data_utils.py,sha256=qW8FOQWgcHjuuiSaAayJ3nKJnDW_GDv3ujE-uFvWsPE,1764
65
- learning3d/ops/invmat.py,sha256=m1Mm2mQNn4KgQv54w-ek0xLkZuKnfDlF2ooylXeXvAw,4154
66
- learning3d/ops/quaternion.py,sha256=D00IL6VHitYy4CINFAilD0t0kyBjc_JHfKuMrJGJ1Cw,6793
67
- learning3d/ops/se3.py,sha256=x6oLbQzLOXiM0xDJsVUCUE1liZ_TaJzkkHQvIyjqCqI,3957
68
- learning3d/ops/sinc.py,sha256=A_Ffu07RXGx3daZn4zOGdnW10_l06cmhFdAiU4NKhcw,5228
69
- learning3d/ops/so3.py,sha256=b0tX5nHyF2Qtp8V0ejGKaPaHJQ_G38ifQ7gSJzRU1ts,5166
70
- learning3d/ops/transform_functions.py,sha256=hvNjZO-uJodsGYtQwtAtDxtQ6uBpA7Lv9t-_yAg6wxo,12806
71
- learning3d/utils/__init__.py,sha256=lwMtW0H4LEZJuoVCi7qmfaWdOVrL2YmP_YP-ZfUoSlc,286
72
- learning3d/utils/pointconv_util.py,sha256=kJxGztai7X15YsGuorMOc50SPtj_k1yfkP4XCTzIWdM,14331
73
- learning3d/utils/ppfnet_util.py,sha256=HEoxkgUBlawKZLWspfQm3caWUyAMIrW-ECtStNYbe2Y,7989
74
- learning3d/utils/svd.py,sha256=yCYQt2SKqeIzCBnBEr_8xFR79m4fIoNVFnp77epn1dM,1936
75
- learning3d/utils/transformer.py,sha256=UDgJvnh7ekWyijaAn-a3ckeFeMxlK_chXzWlhAGDiPM,8974
76
- learning3d-0.1.0.dist-info/LICENSE,sha256=3qY3_NeQIvalbLlsHFtOfuUKjs_U2k6u7rf6YVx6ac0,1098
77
- learning3d-0.1.0.dist-info/METADATA,sha256=kKzkNAYiiVf_t_gv-_OGGr3C1QZWQ5BCKh5sPZUbLts,15813
78
- learning3d-0.1.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
79
- learning3d-0.1.0.dist-info/top_level.txt,sha256=nTmYW8NhbNV1_15DGNpl_OvvSFtQP98sy3qrrHr0eLo,11
80
- learning3d-0.1.0.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- learning3d
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes