mirror of
https://github.com/wassname/Pointnet2_PyTorch.git
synced 2026-08-12 11:40:13 +08:00
Some updates
This commit is contained in:
@@ -4,3 +4,6 @@ __pycache__
|
|||||||
runs
|
runs
|
||||||
build
|
build
|
||||||
checkpoints
|
checkpoints
|
||||||
|
*.prof
|
||||||
|
.lvimrc
|
||||||
|
.vimtags
|
||||||
|
|||||||
@@ -88,9 +88,8 @@ class Pointnet2MSG(nn.Module):
|
|||||||
npoint=512,
|
npoint=512,
|
||||||
radii=[0.1, 0.2, 0.4],
|
radii=[0.1, 0.2, 0.4],
|
||||||
nsamples=[32, 64, 128],
|
nsamples=[32, 64, 128],
|
||||||
mlps=[[input_channels, 32, 32,
|
mlps=[[input_channels, 64], [input_channels, 128],
|
||||||
64], [input_channels, 64, 64, 128],
|
[input_channels, 128]]
|
||||||
[input_channels, 64, 96, 128]]
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -100,9 +99,8 @@ class Pointnet2MSG(nn.Module):
|
|||||||
npoint=128,
|
npoint=128,
|
||||||
radii=[0.2, 0.4, 0.8],
|
radii=[0.2, 0.4, 0.8],
|
||||||
nsamples=[16, 32, 64],
|
nsamples=[16, 32, 64],
|
||||||
mlps=[[input_channels, 64, 64,
|
mlps=[[input_channels, 128], [input_channels, 256],
|
||||||
128], [input_channels, 128, 128, 256],
|
[input_channels, 256]]
|
||||||
[input_channels, 128, 128, 256]]
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.SA_modules.append(
|
self.SA_modules.append(
|
||||||
@@ -136,7 +134,6 @@ if __name__ == "__main__":
|
|||||||
model = Pointnet2MSG(3)
|
model = Pointnet2MSG(3)
|
||||||
model.cuda()
|
model.cuda()
|
||||||
|
|
||||||
|
|
||||||
optimizer = optim.Adam(model.parameters(), lr=1e-2)
|
optimizer = optim.Adam(model.parameters(), lr=1e-2)
|
||||||
|
|
||||||
model_fn = model_fn_decorator(nn.CrossEntropyLoss())
|
model_fn = model_fn_decorator(nn.CrossEntropyLoss())
|
||||||
|
|||||||
@@ -1,24 +1,12 @@
|
|||||||
#ifndef _CUDA_UTILS_H
|
#ifndef _CUDA_UTILS_H
|
||||||
#define _CUDA_UTILS_H
|
#define _CUDA_UTILS_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#include <cmath>
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline int opt_n_threads(int work_size) {
|
inline int opt_n_threads(int work_size) {
|
||||||
unsigned int n_threads = work_size;
|
const int pow_2 = std::log(static_cast<double>(work_size)) / std::log(2.0);
|
||||||
n_threads--;
|
|
||||||
n_threads |= n_threads >> 1;
|
|
||||||
n_threads |= n_threads >> 2;
|
|
||||||
n_threads |= n_threads >> 4;
|
|
||||||
n_threads |= n_threads >> 8;
|
|
||||||
n_threads |= n_threads >> 16;
|
|
||||||
n_threads++;
|
|
||||||
|
|
||||||
return max(min(n_threads / 2, 512), 2);
|
return max(min(1 << pow_2, 512), 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ __global__ void gather_points_kernel(int b, int n, int c, int m,
|
|||||||
for (int i = blockIdx.x; i < b; i += gridDim.x) {
|
for (int i = blockIdx.x; i < b; i += gridDim.x) {
|
||||||
for (int j = blockIdx.y * blockDim.x + threadIdx.x; j < m;
|
for (int j = blockIdx.y * blockDim.x + threadIdx.x; j < m;
|
||||||
j += blockDim.x * gridDim.y) {
|
j += blockDim.x * gridDim.y) {
|
||||||
int a = idx[i * m + j];
|
const int jj = idx[i * m + j];
|
||||||
memcpy(out + (i * m + j) * c, points + (i * n + a) * c,
|
for (int l = 0; l < c; ++l) {
|
||||||
sizeof(float) * c);
|
out[(i * m + j) * c + l] = points[(i * n + jj) * c + l];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +26,7 @@ void gather_points_kernel_wrapper(int b, int n, int c, int npoints,
|
|||||||
float *out, cudaStream_t stream) {
|
float *out, cudaStream_t stream) {
|
||||||
|
|
||||||
cudaError_t err;
|
cudaError_t err;
|
||||||
gather_points_kernel<<<dim3(2, 8, 1), opt_n_threads(npoints) / 4, 0,
|
gather_points_kernel<<<dim3(b, 8, 1), opt_n_threads(npoints), 0,
|
||||||
stream>>>(b, n, c, npoints, points, idx, out);
|
stream>>>(b, n, c, npoints, points, idx, out);
|
||||||
|
|
||||||
err = cudaGetLastError();
|
err = cudaGetLastError();
|
||||||
|
|||||||
Reference in New Issue
Block a user