compound model (wip) (#427)

* compound model now uses compound field, passing num_images in the config, working on passing image indices through ngp sampler

* renaming cuda func, adding torch compound support

* removing unused imports

* getting num images from dataloader instead of config

* fixing pylint and adding todo

* undoing base config change

* adding cone angle and near plane to compound model config
This commit is contained in:
Terrance Wang authored and GitHub committed 2022-09-16 14:38:25 -07:00
1 parent 2495cfe1ee
commit 84024a4e73
10 files changed
+170 -31

No files matched your search

+1
View File
@@ -37,6 +37,7 @@ raymarching = _make_lazy_cuda("raymarching")
volumetric_rendering_forward = _make_lazy_cuda("volumetric_rendering_forward")
volumetric_rendering_backward = _make_lazy_cuda("volumetric_rendering_backward")
occupancy_query = _make_lazy_cuda("occupancy_query")
get_camera_indices = _make_lazy_cuda("get_camera_indices")
# pylint: disable=abstract-method,arguments-differ
class VolumeRenderer(torch.autograd.Function):
+6
View File
@@ -59,6 +59,12 @@ std::vector<torch::Tensor> volumetric_rendering_backward(
torch::Tensor opacities
) {};
torch::Tensor get_camera_indices(
const int* packed_info,
const int* camera_indices,
torch::Tensor mapping
) {};
std::vector<torch::Tensor> occupancy_query(
// samples
const torch::Tensor positions,
+7
View File
@@ -59,6 +59,12 @@ std::vector<torch::Tensor> volumetric_rendering_backward(
torch::Tensor opacities
);
torch::Tensor get_camera_indices(
torch::Tensor packed_info,
torch::Tensor camera_indices,
torch::Tensor mapping
);
std::vector<torch::Tensor> occupancy_query(
// samples
const torch::Tensor positions,
@@ -81,4 +87,5 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
m.def("volumetric_rendering_forward", &volumetric_rendering_forward);
m.def("volumetric_rendering_backward", &volumetric_rendering_backward);
m.def("occupancy_query", &occupancy_query);
m.def("get_camera_indices", &get_camera_indices);
}
+34
View File
@@ -428,6 +428,40 @@ std::vector<torch::Tensor> raymarching(
return {packed_info, origins, dirs, starts, ends};
}
__global__ void kernel_get_camera_indices(
const uint32_t n_rays,
const int* packed_info,
const long* camera_indices,
long* mapping
) {
CUDA_GET_THREAD_ID(thread_id, n_rays);
const int i = packed_info[thread_id * 3 + 0]; // ray idx in {rays_o, rays_d}
const int base = packed_info[thread_id * 3 + 1]; // point idx start.
const int numsteps = packed_info[thread_id * 3 + 2]; // point idx shift.
const long camera_index = camera_indices[i];
int j = 0;
for (; j < numsteps; ++j) {
mapping[base + j] = camera_index;
}
return;
}
torch::Tensor get_camera_indices(
const torch::Tensor packed_info,
const torch::Tensor camera_indices,
torch::Tensor mapping
) {
const int n_rays = packed_info.size(0);
const int threads = 256;
const int blocks = CUDA_N_BLOCKS_NEEDED(n_rays, threads);
kernel_get_camera_indices<<<blocks, threads>>>(n_rays, packed_info.data_ptr<int>(), camera_indices.data_ptr<long>(), mapping.data_ptr<long>());
return mapping;
}
std::vector<torch::Tensor> occupancy_query(
// samples