Exemplo n.º 1
0
def test_binary_ew_ops(benchmark, size, dtype, op):
    np_a = np.array(np.random.uniform(1, 127, size),
                    dtype=to_numpy_dtype(dtype))
    np_b = np.array(np.random.uniform(1, 127, size),
                    dtype=to_numpy_dtype(dtype))
    a = o3c.Tensor(np_a, dtype=dtype, device=o3c.Device("CPU:0"))
    b = o3c.Tensor(np_b, dtype=dtype, device=o3c.Device("CPU:0"))
    benchmark(op, a, b)
Exemplo n.º 2
0
def test_knn_index():
    dtype = o3c.Dtype.Float64
    device = o3c.Device("CPU:0")

    t = o3c.Tensor.zeros((10, 3), dtype, device=device)
    nns = o3c.nns.NearestNeighborSearch(t)
    assert nns.knn_index()
    assert nns.multi_radius_index()
    assert nns.fixed_radius_index()
    assert nns.hybrid_index()
Exemplo n.º 3
0
def test_registration_result_constructor(device):
    dtype = o3c.Dtype.Float64

    # Constructor.
    registration_result = o3d.t.pipelines.registration.RegistrationResult()

    # Checking default values.
    assert registration_result.inlier_rmse == 0.0
    assert registration_result.fitness == 0.0
    assert registration_result.transformation.allclose(
        o3c.Tensor.eye(4, dtype, o3c.Device("CPU:0")))
Exemplo n.º 4
0
def test_device():
    device = o3c.Device()
    assert device.get_type() == o3c.Device.DeviceType.CPU
    assert device.get_id() == 0

    device = o3c.Device("CUDA", 1)
    assert device.get_type() == o3c.Device.DeviceType.CUDA
    assert device.get_id() == 1

    device = o3c.Device("CUDA:2")
    assert device.get_type() == o3c.Device.DeviceType.CUDA
    assert device.get_id() == 2

    assert o3c.Device("CUDA", 1) == o3c.Device("CUDA:1")
    assert o3c.Device("CUDA", 1) != o3c.Device("CUDA:0")

    assert o3c.Device("CUDA", 1).__str__() == "CUDA:1"
Exemplo n.º 5
0
def test_fixed_radius_search():
    dtype = o3c.Dtype.Float64
    device = o3c.Device("CPU:0")

    dataset_points = o3c.Tensor(
        [[0.0, 0.0, 0.0], [0.0, 0.0, 0.1], [0.0, 0.0, 0.2], [0.0, 0.1, 0.0],
         [0.0, 0.1, 0.1], [0.0, 0.1, 0.2], [0.0, 0.2, 0.0], [0.0, 0.2, 0.1],
         [0.0, 0.2, 0.2], [0.1, 0.0, 0.0]],
        dtype=dtype,
        device=device)
    nns = o3c.nns.NearestNeighborSearch(dataset_points)
    nns.fixed_radius_index()

    # Single query point.
    query_points = o3c.Tensor([[0.064705, 0.043921, 0.087843]],
                              dtype=dtype,
                              device=device)
    indices, distances, num_neighbors = nns.fixed_radius_search(
        query_points, 0.1)
    np.testing.assert_equal(indices.cpu().numpy(),
                            np.array([1, 4], dtype=np.int64))
    np.testing.assert_allclose(distances.cpu().numpy(),
                               np.array([0.00626358, 0.00747938],
                                        dtype=np.float64),
                               rtol=1e-5,
                               atol=0)
    np.testing.assert_equal(num_neighbors.cpu().numpy(),
                            np.array([2], dtype=np.int64))

    # Multiple query points.
    query_points = o3c.Tensor(
        [[0.064705, 0.043921, 0.087843], [0.064705, 0.043921, 0.087843]],
        dtype=dtype,
        device=device)
    indices, distances, num_neighbors = nns.fixed_radius_search(
        query_points, 0.1)
    np.testing.assert_equal(indices.cpu().numpy(),
                            np.array([1, 4, 1, 4], dtype=np.int64))
    np.testing.assert_allclose(
        distances.cpu().numpy(),
        np.array([0.00626358, 0.00747938, 0.00626358, 0.00747938],
                 dtype=np.float64),
        rtol=1e-5,
        atol=0)
    np.testing.assert_equal(num_neighbors.cpu().numpy(),
                            np.array([2, 2], dtype=np.int64))
Exemplo n.º 6
0
    def _on_start(self):
        max_points = self.est_point_count_slider.int_value

        pcd_placeholder = o3d.t.geometry.PointCloud(
            o3c.Tensor(np.zeros((max_points, 3), dtype=np.float32)))
        pcd_placeholder.point['colors'] = o3c.Tensor(
            np.zeros((max_points, 3), dtype=np.float32))
        mat = rendering.MaterialRecord()
        mat.shader = 'defaultUnlit'
        mat.sRGB_color = True
        self.widget3d.scene.scene.add_geometry('points', pcd_placeholder, mat)

        self.model = o3d.t.pipelines.slam.Model(
            self.voxel_size_slider.double_value, 16,
            self.est_block_count_slider.int_value, o3c.Tensor(np.eye(4)),
            o3c.Device(self.config.device))
        self.is_started = True

        set_enabled(self.fixed_prop_grid, False)
        set_enabled(self.adjustable_prop_grid, True)
Exemplo n.º 7
0
def list_devices():
    devices = [o3c.Device("CPU:0")]
    if o3c.cuda.is_available():
        devices.append(o3c.Device("CUDA:0"))
    return devices
Exemplo n.º 8
0
def test_float_unary_ew_ops(benchmark, size, dtype, op):
    # Set upper bound to 88 to avoid overflow for exp() op.
    np_a = np.array(np.random.uniform(1, 88, size),
                    dtype=to_numpy_dtype(dtype))
    a = o3c.Tensor(np_a, dtype=dtype, device=o3c.Device("CPU:0"))
    benchmark(op, a)