Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/open3d/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ open3d_sycl_target_sources(core_impl PRIVATE
linalg/LeastSquaresSYCL.cpp
linalg/LUSYCL.cpp
linalg/MatmulSYCL.cpp
nns/KnnSearchOpsSYCL.cpp
linalg/SolveSYCL.cpp
linalg/SVDSYCL.cpp
linalg/TriSYCL.cpp
Expand Down
34 changes: 31 additions & 3 deletions cpp/open3d/core/nns/FixedRadiusIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,16 @@ bool FixedRadiusIndex::SetTensorData(const Tensor &dataset_points,
CALL_BUILD(double, BuildSpatialHashTableCUDA)
#else
utility::LogError(
"-DBUILD_CUDA_MODULE=OFF. Please compile Open3d with "
"-DBUILD_CUDA_MODULE=OFF. Please compile Open3D with "
"-DBUILD_CUDA_MODULE=ON.");
#endif
} else if (device.IsSYCL()) {
#ifdef BUILD_SYCL_MODULE
return true;
#else
utility::LogError(
"-DBUILD_SYCL_MODULE=OFF. Please compile Open3D with "
"-DBUILD_SYCL_MODULE=ON.");
#endif
} else {
CALL_BUILD(float, BuildSpatialHashTableCPU)
Expand Down Expand Up @@ -171,8 +179,18 @@ std::tuple<Tensor, Tensor, Tensor> FixedRadiusIndex::SearchRadius(
});
#else
utility::LogError(
"-DBUILD_CUDA_MODULE=OFF. Please compile Open3d with "
"-DBUILD_CUDA_MODULE=OFF. Please compile Open3D with "
"-DBUILD_CUDA_MODULE=ON.");
#endif
} else if (device.IsSYCL()) {
#ifdef BUILD_SYCL_MODULE
DISPATCH_FLOAT_INT_DTYPE_TO_TEMPLATE(dtype, index_dtype, [&]() {
FixedRadiusSearchSYCL<scalar_t, int_t>(RADIUS_PARAMETERS);
});
#else
utility::LogError(
"-DBUILD_SYCL_MODULE=OFF. Please compile Open3D with "
"-DBUILD_SYCL_MODULE=ON.");
#endif
} else {
DISPATCH_FLOAT_INT_DTYPE_TO_TEMPLATE(dtype, index_dtype, [&]() {
Expand Down Expand Up @@ -240,8 +258,18 @@ std::tuple<Tensor, Tensor, Tensor> FixedRadiusIndex::SearchHybrid(
});
#else
utility::LogError(
"-DBUILD_CUDA_MODULE=OFF. Please compile Open3d with "
"-DBUILD_CUDA_MODULE=OFF. Please compile Open3D with "
"-DBUILD_CUDA_MODULE=ON.");
#endif
} else if (device.IsSYCL()) {
#ifdef BUILD_SYCL_MODULE
DISPATCH_FLOAT_INT_DTYPE_TO_TEMPLATE(dtype, index_dtype, [&]() {
HybridSearchSYCL<scalar_t, int_t>(HYBRID_PARAMETERS);
});
#else
utility::LogError(
"-DBUILD_SYCL_MODULE=OFF. Please compile Open3D with "
"-DBUILD_SYCL_MODULE=ON.");
#endif
} else {
DISPATCH_FLOAT_INT_DTYPE_TO_TEMPLATE(dtype, index_dtype, [&]() {
Expand Down
34 changes: 34 additions & 0 deletions cpp/open3d/core/nns/FixedRadiusIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,40 @@ void HybridSearchCUDA(const Tensor& points,
Tensor& neighbors_distance);
#endif

#ifdef BUILD_SYCL_MODULE
template <class T, class TIndex>
void FixedRadiusSearchSYCL(const Tensor& points,
const Tensor& queries,
double radius,
const Tensor& points_row_splits,
const Tensor& queries_row_splits,
const Tensor& hash_table_splits,
const Tensor& hash_table_index,
const Tensor& hash_table_cell_splits,
const Metric metric,
const bool ignore_query_point,
const bool return_distances,
const bool sort,
Tensor& neighbors_index,
Tensor& neighbors_row_splits,
Tensor& neighbors_distance);

template <class T, class TIndex>
void HybridSearchSYCL(const Tensor& points,
const Tensor& queries,
double radius,
int max_knn,
const Tensor& points_row_splits,
const Tensor& queries_row_splits,
const Tensor& hash_table_splits,
const Tensor& hash_table_index,
const Tensor& hash_table_cell_splits,
const Metric metric,
Tensor& neighbors_index,
Tensor& neighbors_count,
Tensor& neighbors_distance);
#endif

/// \class FixedRadiusIndex
///
/// \brief FixedRadiusIndex for nearest neighbor range search.
Expand Down
28 changes: 25 additions & 3 deletions cpp/open3d/core/nns/KnnIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ bool KnnIndex::SetTensorData(const Tensor& dataset_points,
utility::LogError(
"GPU Tensor is not supported when -DBUILD_CUDA_MODULE=OFF. "
"Please recompile Open3d With -DBUILD_CUDA_MODULE=ON.");
#endif
} else if (dataset_points.IsSYCL()) {
#ifdef BUILD_SYCL_MODULE
dataset_points_ = dataset_points.Contiguous();
points_row_splits_ = points_row_splits.Contiguous();
index_dtype_ = index_dtype;
return true;
#else
utility::LogError(
"SYCL Tensor is not supported when -DBUILD_SYCL_MODULE=OFF. "
"Please recompile Open3D with -DBUILD_SYCL_MODULE=ON.");
#endif
} else {
utility::LogError(
Expand Down Expand Up @@ -124,13 +135,24 @@ std::pair<Tensor, Tensor> KnnIndex::SearchKnn(const Tensor& query_points,
});
#else
utility::LogError(
"-DBUILD_CUDA_MODULE=OFF. Please compile Open3d with "
"-DBUILD_CUDA_MODULE=OFF. Please compile Open3D with "
"-DBUILD_CUDA_MODULE=ON.");
#endif
} else if (device.IsSYCL()) {
#ifdef BUILD_SYCL_MODULE
const Dtype index_dtype = GetIndexDtype();
DISPATCH_FLOAT_INT_DTYPE_TO_TEMPLATE(dtype, index_dtype, [&]() {
KnnSearchSYCL<scalar_t, int_t>(KNN_PARAMETERS);
});
#else
utility::LogError(
"-DBUILD_SYCL_MODULE=OFF. Please compile Open3D with "
"-DBUILD_SYCL_MODULE=ON.");
#endif
} else {
utility::LogError(
"-DBUILD_CUDA_MODULE=OFF. Please compile Open3d with "
"-DBUILD_CUDA_MODULE=ON.");
"KnnIndex only supports CUDA and SYCL tensors. Please use "
"NanoFlannIndex instead for CPU tensors.");
}
return std::make_pair(neighbors_index, neighbors_distance);
}
Expand Down
18 changes: 16 additions & 2 deletions cpp/open3d/core/nns/KnnIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,28 @@ void KnnSearchCUDA(const Tensor& points,
Tensor& neighbors_distance);
#endif

#ifdef BUILD_SYCL_MODULE
template <class T, class TIndex>
void KnnSearchSYCL(const Tensor& points,
const Tensor& points_row_splits,
const Tensor& queries,
const Tensor& queries_row_splits,
int knn,
Tensor& neighbors_index,
Tensor& neighbors_row_splits,
Tensor& neighbors_distance);
#endif

class KnnIndex : public NNSIndex {
public:
KnnIndex();

/// \brief Parameterized Constructor.
///
/// \param dataset_points Provides a set of data points as Tensor for KDTree
/// construction.
/// \param dataset_points Provides a set of data points as Tensor for
/// nearest neighbor search. CPU tensors use NanoFlann through
/// open3d::core::nns::NearestNeighborSearch, while CUDA and SYCL tensors
/// are handled by this class.
KnnIndex(const Tensor& dataset_points);
KnnIndex(const Tensor& dataset_points, const Dtype& index_dtype);
~KnnIndex();
Expand Down
Loading
Loading