Skip to content

Commit

Permalink
Add SYCL enable parameter to list_devices
Browse files Browse the repository at this point in the history
  • Loading branch information
lumurillo committed Nov 5, 2024
1 parent 278295c commit aa437b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions python/test/open3d_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def torch_available():
return True


def list_devices():
def list_devices(enable_sycl=False):
"""
If Open3D is built with CUDA support:
- If cuda device is available, returns [Device("CPU:0"), Device("CUDA:0")].
Expand All @@ -39,7 +39,7 @@ def list_devices():
import open3d as o3d
if o3d.core.cuda.device_count() > 0:
return [o3d.core.Device("CPU:0"), o3d.core.Device("CUDA:0")]
elif o3d.core.sycl.is_available():
elif enable_sycl and o3d.core.sycl.is_available():
return [o3d.core.Device("CPU:0"), o3d.core.Device("SYCL:0")]
else:
return [o3d.core.Device("CPU:0")]
Expand Down
18 changes: 9 additions & 9 deletions python/test/t/geometry/test_raycasting_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


# test intersection with a single triangle
@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
def test_cast_rays(device):
vertices = o3d.core.Tensor([[0, 0, 0], [1, 0, 0], [1, 1, 0]],
dtype=o3d.core.float32,
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_cast_rays(device):

# cast lots of random rays to test the internal batching
# we expect no errors for this test
@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
def test_cast_lots_of_rays(device):
vertices = o3d.core.Tensor([[0, 0, 0], [1, 0, 0], [1, 1, 0]],
dtype=o3d.core.float32,
Expand All @@ -65,7 +65,7 @@ def test_cast_lots_of_rays(device):


# test occlusion with a single triangle
@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
def test_test_occlusions(device):
vertices = o3d.core.Tensor([[0, 0, 0], [1, 0, 0], [1, 1, 0]],
dtype=o3d.core.float32,
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_test_occlusions(device):

# test lots of random rays for occlusions to test the internal batching
# we expect no errors for this test
@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
def test_test_lots_of_occlusions(device):
vertices = o3d.core.Tensor([[0, 0, 0], [1, 0, 0], [1, 1, 0]],
dtype=o3d.core.float32,
Expand All @@ -118,7 +118,7 @@ def test_test_lots_of_occlusions(device):
_ = scene.test_occlusions(rays)


@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
def test_add_triangle_mesh(device):
cube = o3d.t.geometry.TriangleMesh.from_legacy(
o3d.geometry.TriangleMesh.create_box())
Expand All @@ -140,7 +140,7 @@ def test_add_triangle_mesh(device):
np.testing.assert_equal(ans.cpu().numpy(), [2, 1, 0])


@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
def test_count_intersections(device):
cube = o3d.t.geometry.TriangleMesh.from_legacy(
o3d.geometry.TriangleMesh.create_box())
Expand All @@ -164,7 +164,7 @@ def test_count_intersections(device):

# count lots of random ray intersections to test the internal batching
# we expect no errors for this test
@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
def test_count_lots_of_intersections(device):
cube = o3d.t.geometry.TriangleMesh.from_legacy(
o3d.geometry.TriangleMesh.create_box())
Expand All @@ -184,7 +184,7 @@ def test_count_lots_of_intersections(device):
_ = scene.count_intersections(rays)


@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
def test_list_intersections(device):
cube = o3d.t.geometry.TriangleMesh.from_legacy(
o3d.geometry.TriangleMesh.create_box())
Expand All @@ -211,7 +211,7 @@ def test_list_intersections(device):

# list lots of random ray intersections to test the internal batching
# we expect no errors for this test
@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
def test_list_lots_of_intersections(device):
cube = o3d.t.geometry.TriangleMesh.from_legacy(
o3d.geometry.TriangleMesh.create_box())
Expand Down

0 comments on commit aa437b6

Please sign in to comment.