Update Instant-NGP & Density Grid with CUDA supports. Much faster and better PSNR. (#193)

This commit is contained in:
Ruilong Li(李瑞龙) authored and GitHub committed 2022-07-24 22:22:44 -07:00
1 parent 31b52ae186
commit 12cd321e1a
39 files changed
+1721 -650

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
"""
Code to test the density grid.
"""
# import torch
# from pyrad.fields.density_fields.density_grid import DensityGrid
def test_density_grid():
"""For testing the density grid."""
# TODO(ruilongli): currently the DensityGrid only supports GPU init.
# after we support for CPU init then we re-enable this test
# device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# num_cascades = 1
# resolution = 128
# aabb = torch.tensor([[-1, -1, -1], [1, 1, 1]], dtype=torch.float32).to(device)
# grid = DensityGrid(num_cascades, resolution, aabb)
# grid.to(device)
# density_eval_func = lambda x: x[..., 0:1] # xyz (..., 3) => density (...,)
# grid.update_density_grid(density_eval_func=density_eval_func, step=0)
if __name__ == "__main__":
test_density_grid()
@@ -1,22 +0,0 @@
"""
Code to test the occupancy grid.
"""
import torch
from pyrad.fields.occupancy_fields.occupancy_grid import OccupancyGrid
def test_occupancy_grid():
"""For testing the occupancy grid."""
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
num_cascades = 1
resolution = 128
aabb = torch.tensor([[-1, -1, -1], [1, 1, 1]], dtype=torch.float32).to(device)
grid = OccupancyGrid(num_cascades, resolution, aabb)
grid.to(device)
density_fn = lambda x: x[..., 0:1] # xyz (..., 3) => density (...,)
grid.update_occupancy_grid(density_fn=density_fn)
if __name__ == "__main__":
test_occupancy_grid()