Skip to content
Open
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
7 changes: 4 additions & 3 deletions cpp/open3d/ml/paddle/PaddleHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
#include "paddle/phi/core/allocator.h"

// Macros for checking tensor properties
#define CHECK_CUDA(x) \
do { \
PD_CHECK(x.is_gpu(), #x " must be a CUDA tensor"); \
#define CHECK_CUDA(x) \
do { \
PD_CHECK(x.is_gpu() || x.is_custom_device(), \
#x " must be a CUDA tensor"); \
} while (0)

// NOTE: The input Tensor will be preprocessed into a contiguous Tensor within
Expand Down
4 changes: 2 additions & 2 deletions cpp/open3d/ml/paddle/continuous_conv/ContinuousConvOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ std::vector<paddle::Tensor> ContinuousConvForward(
return {out_features}; \
}

if (inp_features.is_gpu()) {
if (inp_features.is_gpu() || inp_features.is_custom_device()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于非cuda兼容的 custom device 设备,不应该走到 CUDA kernel

#ifdef BUILD_CUDA_MODULE
CALL(float, float, float, int32_t, ::ContinuousConvCUDA)
#else
Expand Down Expand Up @@ -189,7 +189,7 @@ std::vector<paddle::Tensor> ContinuousConvBackward(
}

bool dispatch_success = false;
if (inp_features.is_gpu()) {
if (inp_features.is_gpu() || inp_features.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
CALL(float, float, float, int32_t, CUDA)
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ std::vector<paddle::Tensor> ContinuousConvTransposeForward(
return {out_features}; \
}

if (inp_features.is_gpu()) {
if (inp_features.is_gpu() || inp_features.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
CALL(float, float, float, int32_t, ::ContinuousConvTransposeCUDA)
#else
Expand Down Expand Up @@ -206,7 +206,7 @@ std::vector<paddle::Tensor> ContinuousConvTransposeBackward(
}

bool dispatch_success = false;
if (inp_features.is_gpu()) {
if (inp_features.is_gpu() || inp_features.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
CALL(float, float, float, int32_t, CUDA)
#else
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/ml/paddle/misc/BuildSpatialHashTableOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ std::vector<paddle::Tensor> BuildSpatialHashTable(
return {hash_table_index, hash_table_cell_splits, \
out_hash_table_splits}; \
}
if (points.is_gpu()) {
if (points.is_gpu() || points.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
// pass to cuda function
CALL(float, BuildSpatialHashTableCUDA)
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/ml/paddle/misc/FixedRadiusSearchOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ std::vector<paddle::Tensor> FixedRadiusSearch(
metric, ignore_query_point, return_distances, neighbors_index, \
neighbors_row_splits, neighbors_distance

if (points.is_gpu()) {
if (points.is_gpu() || points.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
// pass to cuda function
if (ComparePaddleDtype<float>(point_type)) {
Expand Down
3 changes: 2 additions & 1 deletion cpp/open3d/ml/paddle/misc/InvertNeighborsListOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ std::vector<paddle::Tensor> InvertNeighborsList(

CHECK_SAME_DEVICE_TYPE(inp_neighbors_index, inp_neighbors_row_splits,
inp_neighbors_attributes);
if (inp_neighbors_index.is_gpu()) {
if (inp_neighbors_index.is_gpu() ||
inp_neighbors_index.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
// pass to cuda function
CALL(int32_t, uint8_t, InvertNeighborsListCUDA)
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/ml/paddle/misc/KnnSearchOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ std::vector<paddle::Tensor> KnnSearch(paddle::Tensor& points,
ignore_query_point, return_distances, neighbors_index, \
neighbors_row_splits, neighbors_distance

if (points.is_gpu()) {
if (points.is_gpu() || points.is_custom_device()) {
PD_CHECK(false, "KnnSearch does not support CUDA");
} else {
if (ComparePaddleDtype<float>(point_type)) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/ml/paddle/misc/NmsOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ std::vector<paddle::Tensor> Nms(paddle::Tensor& boxes,
CHECK_TYPE(scores, phi::DataType::FLOAT32);

std::vector<int64_t> keep_indices_blob;
if (boxes.is_gpu()) {
if (boxes.is_gpu() || boxes.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
keep_indices_blob = open3d::ml::contrib::NmsCUDAKernel(
boxes.data<float>(), scores.data<float>(), boxes.shape()[0],
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/ml/paddle/misc/RadiusSearchOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ std::vector<paddle::Tensor> MultiRadiusSearch(
ignore_query_point, return_distances, normalize_distances, \
neighbors_index, neighbors_row_splits, neighbors_distance

if (points.is_gpu()) {
if (points.is_gpu() || points.is_custom_device()) {
PD_CHECK(false, "MultiRadiusSearch does not support CUDA");
} else {
if (ComparePaddleDtype<float>(point_type)) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/ml/paddle/misc/RaggedToDenseOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ std::vector<paddle::Tensor> RaggedToDense(paddle::Tensor& values,
return {fn<value_t>(values, row_splits, out_col_size, default_value)}; \
}

if (values.is_gpu()) {
if (values.is_gpu() || values.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
// pass to cuda function
CALL(uint8_t, RaggedToDenseCUDA)
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/ml/paddle/misc/ReduceSubarraysSumOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::vector<paddle::Tensor> ReduceSubarraysSum(paddle::Tensor& values,

CHECK_SAME_DEVICE_TYPE(values, row_splits);

if (values.is_gpu()) {
if (values.is_gpu() || values.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
// pass to cuda function
CALL(int32_t, ReduceSubarraysSumCUDA)
Expand Down
4 changes: 2 additions & 2 deletions cpp/open3d/ml/paddle/misc/VoxelPoolingOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ std::vector<paddle::Tensor> VoxelPoolingForward(
}

CHECK_SAME_DEVICE_TYPE(positions, features);
if (positions.is_gpu()) {
if (positions.is_gpu() || positions.is_custom_device()) {
PD_CHECK(false, "VoxelPooling does not support CUDA");
} else {
CALL(float, float, VoxelPoolingCPU)
Expand Down Expand Up @@ -170,7 +170,7 @@ std::vector<paddle::Tensor> VoxelPoolingBackward(
}

CHECK_SAME_DEVICE_TYPE(positions, features);
if (positions.is_gpu()) {
if (positions.is_gpu() || positions.is_custom_device()) {
PD_CHECK(false, "VoxelPooling backward does not support CUDA");
} else {
CALL(float, float, VoxelPoolingGradCPU)
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/ml/paddle/misc/VoxelizeOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ std::vector<paddle::Tensor> Voxelize(paddle::Tensor& points,
voxel_batch_splits}; \
}

if (points.is_gpu()) {
if (points.is_gpu() || points.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
// pass to cuda function
CALL(float, VoxelizeCUDA)
Expand Down
4 changes: 2 additions & 2 deletions cpp/open3d/ml/paddle/sparse_conv/SparseConvOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ std::vector<paddle::Tensor> SparseConvForward(
return {out_features}; \
}

if (inp_features.is_gpu()) {
if (inp_features.is_gpu() || inp_features.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
CALL(float, float, int32_t, uint8_t, ::SparseConvCUDA)
#else
Expand Down Expand Up @@ -166,7 +166,7 @@ std::vector<paddle::Tensor> SparseConvBackward(
}

bool dispatch_success = false;
if (inp_features.is_gpu()) {
if (inp_features.is_gpu() || inp_features.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
CALL(float, float, int32_t, uint8_t, CUDA)
#else
Expand Down
4 changes: 2 additions & 2 deletions cpp/open3d/ml/paddle/sparse_conv/SparseConvTransposeOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ std::vector<paddle::Tensor> SparseConvTransposeForward(
return {out_features}; \
}

if (inp_features.is_gpu()) {
if (inp_features.is_gpu() || inp_features.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
CALL(float, float, int32_t, uint8_t, ::SparseConvTransposeCUDA)
#else
Expand Down Expand Up @@ -176,7 +176,7 @@ std::vector<paddle::Tensor> SparseConvTransposeBackward(
}

bool dispatch_success = false;
if (inp_features.is_gpu()) {
if (inp_features.is_gpu() || inp_features.is_custom_device()) {
#ifdef BUILD_CUDA_MODULE
CALL(float, float, int32_t, uint8_t, CUDA)
#else
Expand Down