Skip to content

Commit 4ba8cf8

Browse files
authored
c10::optional -> std::optional (#239)
1 parent 4126a52 commit 4ba8cf8

21 files changed

+42
-42
lines changed

csrc/cluster.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ CLUSTER_API torch::Tensor fps(torch::Tensor src, torch::Tensor ptr, torch::Tenso
1414
bool random_start);
1515

1616
CLUSTER_API torch::Tensor graclus(torch::Tensor rowptr, torch::Tensor col,
17-
torch::optional<torch::Tensor> optional_weight);
17+
std::optional<torch::Tensor> optional_weight);
1818

1919
CLUSTER_API torch::Tensor grid(torch::Tensor pos, torch::Tensor size,
20-
torch::optional<torch::Tensor> optional_start,
21-
torch::optional<torch::Tensor> optional_end);
20+
std::optional<torch::Tensor> optional_start,
21+
std::optional<torch::Tensor> optional_end);
2222

2323
CLUSTER_API torch::Tensor knn(torch::Tensor x, torch::Tensor y,
24-
torch::optional<torch::Tensor> ptr_x,
25-
torch::optional<torch::Tensor> ptr_y, int64_t k, bool cosine,
24+
std::optional<torch::Tensor> ptr_x,
25+
std::optional<torch::Tensor> ptr_y, int64_t k, bool cosine,
2626
int64_t num_workers);
2727

2828
CLUSTER_API torch::Tensor nearest(torch::Tensor x, torch::Tensor y, torch::Tensor ptr_x,

csrc/cpu/graclus_cpu.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "utils.h"
44

55
torch::Tensor graclus_cpu(torch::Tensor rowptr, torch::Tensor col,
6-
torch::optional<torch::Tensor> optional_weight) {
6+
std::optional<torch::Tensor> optional_weight) {
77
CHECK_CPU(rowptr);
88
CHECK_CPU(col);
99
CHECK_INPUT(rowptr.dim() == 1 && col.dim() == 1);

csrc/cpu/graclus_cpu.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#include "../extensions.h"
44

55
torch::Tensor graclus_cpu(torch::Tensor rowptr, torch::Tensor col,
6-
torch::optional<torch::Tensor> optional_weight);
6+
std::optional<torch::Tensor> optional_weight);

csrc/cpu/grid_cpu.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include "utils.h"
44

55
torch::Tensor grid_cpu(torch::Tensor pos, torch::Tensor size,
6-
torch::optional<torch::Tensor> optional_start,
7-
torch::optional<torch::Tensor> optional_end) {
6+
std::optional<torch::Tensor> optional_start,
7+
std::optional<torch::Tensor> optional_end) {
88

99
CHECK_CPU(pos);
1010
CHECK_CPU(size);

csrc/cpu/grid_cpu.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
#include "../extensions.h"
44
torch::Tensor grid_cpu(torch::Tensor pos, torch::Tensor size,
5-
torch::optional<torch::Tensor> optional_start,
6-
torch::optional<torch::Tensor> optional_end);
5+
std::optional<torch::Tensor> optional_start,
6+
std::optional<torch::Tensor> optional_end);

csrc/cpu/knn_cpu.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include "utils/nanoflann.hpp"
66

77
torch::Tensor knn_cpu(torch::Tensor x, torch::Tensor y,
8-
torch::optional<torch::Tensor> ptr_x,
9-
torch::optional<torch::Tensor> ptr_y, int64_t k,
8+
std::optional<torch::Tensor> ptr_x,
9+
std::optional<torch::Tensor> ptr_y, int64_t k,
1010
int64_t num_workers) {
1111

1212
CHECK_CPU(x);

csrc/cpu/knn_cpu.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#include "../extensions.h"
44

55
torch::Tensor knn_cpu(torch::Tensor x, torch::Tensor y,
6-
torch::optional<torch::Tensor> ptr_x,
7-
torch::optional<torch::Tensor> ptr_y, int64_t k,
6+
std::optional<torch::Tensor> ptr_x,
7+
std::optional<torch::Tensor> ptr_y, int64_t k,
88
int64_t num_workers);

csrc/cpu/radius_cpu.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include "utils/nanoflann.hpp"
66

77
torch::Tensor radius_cpu(torch::Tensor x, torch::Tensor y,
8-
torch::optional<torch::Tensor> ptr_x,
9-
torch::optional<torch::Tensor> ptr_y, double r,
8+
std::optional<torch::Tensor> ptr_x,
9+
std::optional<torch::Tensor> ptr_y, double r,
1010
int64_t max_num_neighbors, int64_t num_workers,
1111
bool ignore_same_index) {
1212

csrc/cpu/radius_cpu.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "../extensions.h"
44

55
torch::Tensor radius_cpu(torch::Tensor x, torch::Tensor y,
6-
torch::optional<torch::Tensor> ptr_x,
7-
torch::optional<torch::Tensor> ptr_y, double r,
6+
std::optional<torch::Tensor> ptr_x,
7+
std::optional<torch::Tensor> ptr_y, double r,
88
int64_t max_num_neighbors, int64_t num_workers,
99
bool ignore_same_index);

csrc/cuda/graclus_cuda.cu

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ __global__ void weighted_propose_kernel(int64_t *out, int64_t *proposal,
103103

104104
void propose(torch::Tensor out, torch::Tensor proposal, torch::Tensor rowptr,
105105
torch::Tensor col,
106-
torch::optional<torch::Tensor> optional_weight) {
106+
std::optional<torch::Tensor> optional_weight) {
107107

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

@@ -192,7 +192,7 @@ __global__ void weighted_respond_kernel(int64_t *out, const int64_t *proposal,
192192

193193
void respond(torch::Tensor out, torch::Tensor proposal, torch::Tensor rowptr,
194194
torch::Tensor col,
195-
torch::optional<torch::Tensor> optional_weight) {
195+
std::optional<torch::Tensor> optional_weight) {
196196

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

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

216216
torch::Tensor graclus_cuda(torch::Tensor rowptr, torch::Tensor col,
217-
torch::optional<torch::Tensor> optional_weight) {
217+
std::optional<torch::Tensor> optional_weight) {
218218
CHECK_CUDA(rowptr);
219219
CHECK_CUDA(col);
220220
CHECK_INPUT(rowptr.dim() == 1 && col.dim() == 1);

csrc/cuda/graclus_cuda.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#include "../extensions.h"
44

55
torch::Tensor graclus_cuda(torch::Tensor rowptr, torch::Tensor col,
6-
torch::optional<torch::Tensor> optional_weight);
6+
std::optional<torch::Tensor> optional_weight);

csrc/cuda/grid_cuda.cu

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ __global__ void grid_kernel(const scalar_t *pos, const scalar_t *size,
2525
}
2626

2727
torch::Tensor grid_cuda(torch::Tensor pos, torch::Tensor size,
28-
torch::optional<torch::Tensor> optional_start,
29-
torch::optional<torch::Tensor> optional_end) {
28+
std::optional<torch::Tensor> optional_start,
29+
std::optional<torch::Tensor> optional_end) {
3030
CHECK_CUDA(pos);
3131
CHECK_CUDA(size);
3232
c10::cuda::MaybeSetDevice(pos.get_device());

csrc/cuda/grid_cuda.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
#include "../extensions.h"
44

55
torch::Tensor grid_cuda(torch::Tensor pos, torch::Tensor size,
6-
torch::optional<torch::Tensor> optional_start,
7-
torch::optional<torch::Tensor> optional_end);
6+
std::optional<torch::Tensor> optional_start,
7+
std::optional<torch::Tensor> optional_end);

csrc/cuda/knn_cuda.cu

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ knn_kernel(const scalar_t *__restrict__ x, const scalar_t *__restrict__ y,
8484
}
8585

8686
torch::Tensor knn_cuda(const torch::Tensor x, const torch::Tensor y,
87-
torch::optional<torch::Tensor> ptr_x,
88-
torch::optional<torch::Tensor> ptr_y, const int64_t k,
87+
std::optional<torch::Tensor> ptr_x,
88+
std::optional<torch::Tensor> ptr_y, const int64_t k,
8989
const bool cosine) {
9090

9191
CHECK_CUDA(x);

csrc/cuda/knn_cuda.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#include "../extensions.h"
44

55
torch::Tensor knn_cuda(torch::Tensor x, torch::Tensor y,
6-
torch::optional<torch::Tensor> ptr_x,
7-
torch::optional<torch::Tensor> ptr_y, int64_t k,
6+
std::optional<torch::Tensor> ptr_x,
7+
std::optional<torch::Tensor> ptr_y, int64_t k,
88
bool cosine);

csrc/cuda/radius_cuda.cu

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ radius_kernel(const scalar_t *__restrict__ x, const scalar_t *__restrict__ y,
4242
}
4343

4444
torch::Tensor radius_cuda(const torch::Tensor x, const torch::Tensor y,
45-
torch::optional<torch::Tensor> ptr_x,
46-
torch::optional<torch::Tensor> ptr_y, const double r,
45+
std::optional<torch::Tensor> ptr_x,
46+
std::optional<torch::Tensor> ptr_y, const double r,
4747
const int64_t max_num_neighbors,
4848
const bool ignore_same_index) {
4949
CHECK_CUDA(x);

csrc/cuda/radius_cuda.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "../extensions.h"
44

55
torch::Tensor radius_cuda(torch::Tensor x, torch::Tensor y,
6-
torch::optional<torch::Tensor> ptr_x,
7-
torch::optional<torch::Tensor> ptr_y, double r,
6+
std::optional<torch::Tensor> ptr_x,
7+
std::optional<torch::Tensor> ptr_y, double r,
88
int64_t max_num_neighbors,
99
bool ignore_same_index);

csrc/graclus.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ PyMODINIT_FUNC PyInit__graclus_cpu(void) { return NULL; }
2020
#endif
2121

2222
CLUSTER_API torch::Tensor graclus(torch::Tensor rowptr, torch::Tensor col,
23-
torch::optional<torch::Tensor> optional_weight) {
23+
std::optional<torch::Tensor> optional_weight) {
2424
if (rowptr.device().is_cuda()) {
2525
#ifdef WITH_CUDA
2626
return graclus_cuda(rowptr, col, optional_weight);

csrc/grid.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ PyMODINIT_FUNC PyInit__grid_cpu(void) { return NULL; }
2020
#endif
2121

2222
CLUSTER_API torch::Tensor grid(torch::Tensor pos, torch::Tensor size,
23-
torch::optional<torch::Tensor> optional_start,
24-
torch::optional<torch::Tensor> optional_end) {
23+
std::optional<torch::Tensor> optional_start,
24+
std::optional<torch::Tensor> optional_end) {
2525
if (pos.device().is_cuda()) {
2626
#ifdef WITH_CUDA
2727
return grid_cuda(pos, size, optional_start, optional_end);

csrc/knn.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ PyMODINIT_FUNC PyInit__knn_cpu(void) { return NULL; }
2020
#endif
2121

2222
CLUSTER_API torch::Tensor knn(torch::Tensor x, torch::Tensor y,
23-
torch::optional<torch::Tensor> ptr_x,
24-
torch::optional<torch::Tensor> ptr_y, int64_t k, bool cosine,
23+
std::optional<torch::Tensor> ptr_x,
24+
std::optional<torch::Tensor> ptr_y, int64_t k, bool cosine,
2525
int64_t num_workers) {
2626
if (x.device().is_cuda()) {
2727
#ifdef WITH_CUDA

csrc/radius.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ PyMODINIT_FUNC PyInit__radius_cpu(void) { return NULL; }
2020
#endif
2121

2222
CLUSTER_API torch::Tensor radius(torch::Tensor x, torch::Tensor y,
23-
torch::optional<torch::Tensor> ptr_x,
24-
torch::optional<torch::Tensor> ptr_y, double r,
23+
std::optional<torch::Tensor> ptr_x,
24+
std::optional<torch::Tensor> ptr_y, double r,
2525
int64_t max_num_neighbors, int64_t num_workers,
2626
bool ignore_same_index) {
2727
if (x.device().is_cuda()) {

0 commit comments

Comments
 (0)