Skip to content

Commit b52da8f

Browse files
authored
add comment for nvdiffrast usage in dibr example, add option for skipping tests with nvdiffrast (NVIDIAGameWorks#569)
Signed-off-by: Clement Fuji Tsang <[email protected]>
1 parent 006fbf6 commit b52da8f

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "third_party/cub"]
22
path = third_party/cub
33
url = https://github.com/NVIDIA/cub
4-
[submodule "third_party/nvdiffrast"]
5-
path = third_party/nvdiffrast
6-
url = https://github.com/NVlabs/nvdiffrast

ci/gitlab_jenkins_templates/ubuntu_test_CI.jenkins

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ spec:
4141
}
4242
}, "Pytest": {
4343
stage("Pytest") {
44-
sh 'pytest -s --cov=/kaolin/kaolin /kaolin/tests/python/kaolin'
44+
sh '''
45+
export KAOLIN_TEST_NVIDIFFRAST=1
46+
pytest -s --cov=/kaolin/kaolin /kaolin/tests/python/kaolin
47+
'''
4548
}
4649
}, "Doc examples": {
4750
if (arch == "TITAN_RTX") {

examples/tutorial/dibr_tutorial.ipynb

+4-1
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,12 @@
331331
" torch.ones((batch_size, nb_faces, 3, 1), device='cuda')\n",
332332
" ]\n",
333333
"\n",
334+
" # If you have nvdiffrast installed you can change rast_backend to\n",
335+
" # nvdiffrast or nvdiffrast_fwd\n",
334336
" image_features, soft_mask, face_idx = kal.render.mesh.dibr_rasterization(\n",
335337
" gt_image.shape[1], gt_image.shape[2], face_vertices_camera[:, :, :, -1],\n",
336-
" face_vertices_image, face_attributes, face_normals[:, :, -1])\n",
338+
" face_vertices_image, face_attributes, face_normals[:, :, -1],\n",
339+
" rast_backend='cuda')\n",
337340
"\n",
338341
" # image_features is a tuple in composed of the interpolated attributes of face_attributes\n",
339342
" texture_coords, mask = image_features\n",

tests/python/kaolin/render/mesh/test_dibr.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,11 @@ def face_uvs(self, mesh, batch_size, dtype, flip):
488488
def test_dibr_rasterization(self, height, width, face_vertices_z,
489489
face_vertices_image, face_uvs, face_normals_z,
490490
sigmainv, boxlen, knum, multiplier, rast_backend):
491-
if rast_backend in {'nvdiffrast_fwd', 'nvdiffrast'} and face_vertices_z.dtype == torch.double:
492-
pytest.skip("nvdiffrast not compatible with double")
491+
if rast_backend in {'nvdiffrast_fwd', 'nvdiffrast'}:
492+
if os.getenv('KAOLIN_TEST_NVDIFFRAST', '0') == '0':
493+
pytest.skip(f'test is ignored as KAOLIN_TEST_NVDIFFRAST is not set')
494+
if face_vertices_z.dtype == torch.double:
495+
pytest.skip("nvdiffrast not compatible with double")
493496
gt_interpolated_features, gt_face_idx = rasterize(
494497
height, width,
495498
face_vertices_z,

tests/python/kaolin/render/mesh/test_rasterization.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ def test_nvdiffrast_fwd_forward(
293293
self, batch_size, height, width, pixel_coords,
294294
render_ranges, face_vertices_z, face_vertices_image,
295295
face_uvs, with_valid_faces, valid_faces):
296+
if os.getenv('KAOLIN_TEST_NVDIFFRAST', '0') == '0':
297+
pytest.skip(f'test is ignored as KAOLIN_TEST_NVDIFFRAST is not set')
296298
if face_vertices_image.dtype == torch.double:
297299
pytest.skip("nvdiffrast not compatible with double")
298300
kwargs = {}
@@ -328,6 +330,8 @@ def test_nvdiffrast_fwd_forward_with_list(
328330
render_ranges, face_vertices_z, face_vertices_image,
329331
face_uvs, with_valid_faces, valid_faces, dtype):
330332
"""Test with list of tensors as features"""
333+
if os.getenv('KAOLIN_TEST_NVDIFFRAST', '0') == '0':
334+
pytest.skip(f'test is ignored as KAOLIN_TEST_NVDIFFRAST is not set')
331335
if face_vertices_image.dtype == torch.double:
332336
pytest.skip("nvdiffrast not compatible with double")
333337
kwargs = {}
@@ -370,6 +374,8 @@ def test_nvdiffrast_fwd_backward(
370374
self, batch_size, height, width, pixel_coords,
371375
render_ranges, face_vertices_z, face_vertices_image,
372376
face_uvs, with_valid_faces, valid_faces):
377+
if os.getenv('KAOLIN_TEST_NVDIFFRAST', '0') == '0':
378+
pytest.skip(f'test is ignored as KAOLIN_TEST_NVDIFFRAST is not set')
373379
if face_vertices_image.dtype == torch.double:
374380
pytest.skip("nvdiffrast not compatible with double")
375381
kwargs = {}
@@ -422,6 +428,8 @@ def test_nvdiffrast_fwd_backward_with_mask(
422428
self, batch_size, height, width, pixel_coords,
423429
render_ranges, face_vertices_z, face_vertices_image,
424430
face_uvs, with_valid_faces, valid_faces):
431+
if os.getenv('KAOLIN_TEST_NVDIFFRAST', '0') == '0':
432+
pytest.skip(f'test is ignored as KAOLIN_TEST_NVDIFFRAST is not set')
425433
if face_vertices_image.dtype == torch.double:
426434
pytest.skip("nvdiffrast not compatible with double")
427435
kwargs = {}
@@ -482,6 +490,8 @@ def test_nvdiffrast_fwd_backward_with_mask(
482490
def test_nvdiffrast_forward(
483491
self, batch_size, height, width, face_vertices_z,
484492
face_vertices_image, face_uvs, with_valid_faces, valid_faces):
493+
if os.getenv('KAOLIN_TEST_NVDIFFRAST', '0') == '0':
494+
pytest.skip(f'test is ignored as KAOLIN_TEST_NVDIFFRAST is not set')
485495
if face_vertices_image.dtype == torch.double:
486496
pytest.skip("nvdiffrast not compatible with double")
487497
kwargs = {}
@@ -509,6 +519,8 @@ def test_nvdiffrast_forward_with_list(
509519
self, batch_size, height, width, face_vertices_z,
510520
face_vertices_image, face_uvs, with_valid_faces, valid_faces):
511521
"""Test with list of tensors as features"""
522+
if os.getenv('KAOLIN_TEST_NVDIFFRAST', '0') == '0':
523+
pytest.skip(f'test is ignored as KAOLIN_TEST_NVDIFFRAST is not set')
512524
if face_vertices_image.dtype == torch.double:
513525
pytest.skip("nvdiffrast not compatible with double")
514526
kwargs = {}
@@ -537,6 +549,8 @@ def test_nvdiffrast_forward_with_list(
537549
def test_nvdiffrast_backward(
538550
self, batch_size, height, width, face_vertices_z,
539551
face_vertices_image, face_uvs, with_valid_faces, valid_faces):
552+
if os.getenv('KAOLIN_TEST_NVDIFFRAST', '0') == '0':
553+
pytest.skip(f'test is ignored as KAOLIN_TEST_NVDIFFRAST is not set')
540554
if face_vertices_image.dtype == torch.double:
541555
pytest.skip("nvdiffrast not compatible with double")
542556
kwargs = {}
@@ -577,4 +591,3 @@ def test_nvdiffrast_backward(
577591
assert torch.allclose(face_uvs.grad,
578592
face_uvs2.grad,
579593
rtol=1e-2, atol=1e-2)
580-

third_party/nvdiffrast

-1
This file was deleted.

0 commit comments

Comments
 (0)