Skip to content

Commit

Permalink
c10::optional -> std::optional (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-barnes authored Jan 10, 2025
1 parent 4126a52 commit 4ba8cf8
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 42 deletions.
10 changes: 5 additions & 5 deletions csrc/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ CLUSTER_API torch::Tensor fps(torch::Tensor src, torch::Tensor ptr, torch::Tenso
bool random_start);

CLUSTER_API torch::Tensor graclus(torch::Tensor rowptr, torch::Tensor col,
torch::optional<torch::Tensor> optional_weight);
std::optional<torch::Tensor> optional_weight);

CLUSTER_API torch::Tensor grid(torch::Tensor pos, torch::Tensor size,
torch::optional<torch::Tensor> optional_start,
torch::optional<torch::Tensor> optional_end);
std::optional<torch::Tensor> optional_start,
std::optional<torch::Tensor> optional_end);

CLUSTER_API torch::Tensor knn(torch::Tensor x, torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, int64_t k, bool cosine,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, int64_t k, bool cosine,
int64_t num_workers);

CLUSTER_API torch::Tensor nearest(torch::Tensor x, torch::Tensor y, torch::Tensor ptr_x,
Expand Down
2 changes: 1 addition & 1 deletion csrc/cpu/graclus_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "utils.h"

torch::Tensor graclus_cpu(torch::Tensor rowptr, torch::Tensor col,
torch::optional<torch::Tensor> optional_weight) {
std::optional<torch::Tensor> optional_weight) {
CHECK_CPU(rowptr);
CHECK_CPU(col);
CHECK_INPUT(rowptr.dim() == 1 && col.dim() == 1);
Expand Down
2 changes: 1 addition & 1 deletion csrc/cpu/graclus_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#include "../extensions.h"

torch::Tensor graclus_cpu(torch::Tensor rowptr, torch::Tensor col,
torch::optional<torch::Tensor> optional_weight);
std::optional<torch::Tensor> optional_weight);
4 changes: 2 additions & 2 deletions csrc/cpu/grid_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "utils.h"

torch::Tensor grid_cpu(torch::Tensor pos, torch::Tensor size,
torch::optional<torch::Tensor> optional_start,
torch::optional<torch::Tensor> optional_end) {
std::optional<torch::Tensor> optional_start,
std::optional<torch::Tensor> optional_end) {

CHECK_CPU(pos);
CHECK_CPU(size);
Expand Down
4 changes: 2 additions & 2 deletions csrc/cpu/grid_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

#include "../extensions.h"
torch::Tensor grid_cpu(torch::Tensor pos, torch::Tensor size,
torch::optional<torch::Tensor> optional_start,
torch::optional<torch::Tensor> optional_end);
std::optional<torch::Tensor> optional_start,
std::optional<torch::Tensor> optional_end);
4 changes: 2 additions & 2 deletions csrc/cpu/knn_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "utils/nanoflann.hpp"

torch::Tensor knn_cpu(torch::Tensor x, torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, int64_t k,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, int64_t k,
int64_t num_workers) {

CHECK_CPU(x);
Expand Down
4 changes: 2 additions & 2 deletions csrc/cpu/knn_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#include "../extensions.h"

torch::Tensor knn_cpu(torch::Tensor x, torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, int64_t k,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, int64_t k,
int64_t num_workers);
4 changes: 2 additions & 2 deletions csrc/cpu/radius_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "utils/nanoflann.hpp"

torch::Tensor radius_cpu(torch::Tensor x, torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, double r,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, double r,
int64_t max_num_neighbors, int64_t num_workers,
bool ignore_same_index) {

Expand Down
4 changes: 2 additions & 2 deletions csrc/cpu/radius_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "../extensions.h"

torch::Tensor radius_cpu(torch::Tensor x, torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, double r,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, double r,
int64_t max_num_neighbors, int64_t num_workers,
bool ignore_same_index);
6 changes: 3 additions & 3 deletions csrc/cuda/graclus_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ __global__ void weighted_propose_kernel(int64_t *out, int64_t *proposal,

void propose(torch::Tensor out, torch::Tensor proposal, torch::Tensor rowptr,
torch::Tensor col,
torch::optional<torch::Tensor> optional_weight) {
std::optional<torch::Tensor> optional_weight) {

auto stream = at::cuda::getCurrentCUDAStream();

Expand Down Expand Up @@ -192,7 +192,7 @@ __global__ void weighted_respond_kernel(int64_t *out, const int64_t *proposal,

void respond(torch::Tensor out, torch::Tensor proposal, torch::Tensor rowptr,
torch::Tensor col,
torch::optional<torch::Tensor> optional_weight) {
std::optional<torch::Tensor> optional_weight) {

auto stream = at::cuda::getCurrentCUDAStream();

Expand All @@ -214,7 +214,7 @@ void respond(torch::Tensor out, torch::Tensor proposal, torch::Tensor rowptr,
}

torch::Tensor graclus_cuda(torch::Tensor rowptr, torch::Tensor col,
torch::optional<torch::Tensor> optional_weight) {
std::optional<torch::Tensor> optional_weight) {
CHECK_CUDA(rowptr);
CHECK_CUDA(col);
CHECK_INPUT(rowptr.dim() == 1 && col.dim() == 1);
Expand Down
2 changes: 1 addition & 1 deletion csrc/cuda/graclus_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#include "../extensions.h"

torch::Tensor graclus_cuda(torch::Tensor rowptr, torch::Tensor col,
torch::optional<torch::Tensor> optional_weight);
std::optional<torch::Tensor> optional_weight);
4 changes: 2 additions & 2 deletions csrc/cuda/grid_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ __global__ void grid_kernel(const scalar_t *pos, const scalar_t *size,
}

torch::Tensor grid_cuda(torch::Tensor pos, torch::Tensor size,
torch::optional<torch::Tensor> optional_start,
torch::optional<torch::Tensor> optional_end) {
std::optional<torch::Tensor> optional_start,
std::optional<torch::Tensor> optional_end) {
CHECK_CUDA(pos);
CHECK_CUDA(size);
c10::cuda::MaybeSetDevice(pos.get_device());
Expand Down
4 changes: 2 additions & 2 deletions csrc/cuda/grid_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#include "../extensions.h"

torch::Tensor grid_cuda(torch::Tensor pos, torch::Tensor size,
torch::optional<torch::Tensor> optional_start,
torch::optional<torch::Tensor> optional_end);
std::optional<torch::Tensor> optional_start,
std::optional<torch::Tensor> optional_end);
4 changes: 2 additions & 2 deletions csrc/cuda/knn_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ knn_kernel(const scalar_t *__restrict__ x, const scalar_t *__restrict__ y,
}

torch::Tensor knn_cuda(const torch::Tensor x, const torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, const int64_t k,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, const int64_t k,
const bool cosine) {

CHECK_CUDA(x);
Expand Down
4 changes: 2 additions & 2 deletions csrc/cuda/knn_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#include "../extensions.h"

torch::Tensor knn_cuda(torch::Tensor x, torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, int64_t k,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, int64_t k,
bool cosine);
4 changes: 2 additions & 2 deletions csrc/cuda/radius_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ radius_kernel(const scalar_t *__restrict__ x, const scalar_t *__restrict__ y,
}

torch::Tensor radius_cuda(const torch::Tensor x, const torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, const double r,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, const double r,
const int64_t max_num_neighbors,
const bool ignore_same_index) {
CHECK_CUDA(x);
Expand Down
4 changes: 2 additions & 2 deletions csrc/cuda/radius_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "../extensions.h"

torch::Tensor radius_cuda(torch::Tensor x, torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, double r,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, double r,
int64_t max_num_neighbors,
bool ignore_same_index);
2 changes: 1 addition & 1 deletion csrc/graclus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PyMODINIT_FUNC PyInit__graclus_cpu(void) { return NULL; }
#endif

CLUSTER_API torch::Tensor graclus(torch::Tensor rowptr, torch::Tensor col,
torch::optional<torch::Tensor> optional_weight) {
std::optional<torch::Tensor> optional_weight) {
if (rowptr.device().is_cuda()) {
#ifdef WITH_CUDA
return graclus_cuda(rowptr, col, optional_weight);
Expand Down
4 changes: 2 additions & 2 deletions csrc/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ PyMODINIT_FUNC PyInit__grid_cpu(void) { return NULL; }
#endif

CLUSTER_API torch::Tensor grid(torch::Tensor pos, torch::Tensor size,
torch::optional<torch::Tensor> optional_start,
torch::optional<torch::Tensor> optional_end) {
std::optional<torch::Tensor> optional_start,
std::optional<torch::Tensor> optional_end) {
if (pos.device().is_cuda()) {
#ifdef WITH_CUDA
return grid_cuda(pos, size, optional_start, optional_end);
Expand Down
4 changes: 2 additions & 2 deletions csrc/knn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ PyMODINIT_FUNC PyInit__knn_cpu(void) { return NULL; }
#endif

CLUSTER_API torch::Tensor knn(torch::Tensor x, torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, int64_t k, bool cosine,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, int64_t k, bool cosine,
int64_t num_workers) {
if (x.device().is_cuda()) {
#ifdef WITH_CUDA
Expand Down
4 changes: 2 additions & 2 deletions csrc/radius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ PyMODINIT_FUNC PyInit__radius_cpu(void) { return NULL; }
#endif

CLUSTER_API torch::Tensor radius(torch::Tensor x, torch::Tensor y,
torch::optional<torch::Tensor> ptr_x,
torch::optional<torch::Tensor> ptr_y, double r,
std::optional<torch::Tensor> ptr_x,
std::optional<torch::Tensor> ptr_y, double r,
int64_t max_num_neighbors, int64_t num_workers,
bool ignore_same_index) {
if (x.device().is_cuda()) {
Expand Down

0 comments on commit 4ba8cf8

Please sign in to comment.