Skip to content

Commit 7126aeb

Browse files
authored
c10::optional -> std::optional (#473)
1 parent 7cabb53 commit 7126aeb

16 files changed

+132
-132
lines changed

csrc/cpu/scatter_cpu.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include "reducer.h"
55
#include "utils.h"
66

7-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
7+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
88
scatter_cpu(torch::Tensor src, torch::Tensor index, int64_t dim,
9-
torch::optional<torch::Tensor> optional_out,
10-
torch::optional<int64_t> dim_size, std::string reduce) {
9+
std::optional<torch::Tensor> optional_out,
10+
std::optional<int64_t> dim_size, std::string reduce) {
1111
CHECK_CPU(src);
1212
CHECK_CPU(index);
1313
if (optional_out.has_value())
@@ -36,7 +36,7 @@ scatter_cpu(torch::Tensor src, torch::Tensor index, int64_t dim,
3636
out = torch::empty(sizes, src.options());
3737
}
3838

39-
torch::optional<torch::Tensor> arg_out = torch::nullopt;
39+
std::optional<torch::Tensor> arg_out = std::nullopt;
4040
int64_t *arg_out_data = nullptr;
4141
if (reduce2REDUCE.at(reduce) == MIN || reduce2REDUCE.at(reduce) == MAX) {
4242
arg_out = torch::full_like(out, src.size(dim), index.options());

csrc/cpu/scatter_cpu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "../extensions.h"
44

5-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
5+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
66
scatter_cpu(torch::Tensor src, torch::Tensor index, int64_t dim,
7-
torch::optional<torch::Tensor> optional_out,
8-
torch::optional<int64_t> dim_size, std::string reduce);
7+
std::optional<torch::Tensor> optional_out,
8+
std::optional<int64_t> dim_size, std::string reduce);

csrc/cpu/segment_coo_cpu.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include "utils.h"
66
#include <ATen/OpMathType.h>
77

8-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
8+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
99
segment_coo_cpu(torch::Tensor src, torch::Tensor index,
10-
torch::optional<torch::Tensor> optional_out,
11-
torch::optional<int64_t> dim_size, std::string reduce) {
10+
std::optional<torch::Tensor> optional_out,
11+
std::optional<int64_t> dim_size, std::string reduce) {
1212
CHECK_CPU(src);
1313
CHECK_CPU(index);
1414
if (optional_out.has_value())
@@ -45,7 +45,7 @@ segment_coo_cpu(torch::Tensor src, torch::Tensor index,
4545
out = torch::empty(sizes, src.options());
4646
}
4747

48-
torch::optional<torch::Tensor> arg_out = torch::nullopt;
48+
std::optional<torch::Tensor> arg_out = std::nullopt;
4949
int64_t *arg_out_data = nullptr;
5050
if (reduce2REDUCE.at(reduce) == MIN || reduce2REDUCE.at(reduce) == MAX) {
5151
arg_out = torch::full_like(out, src.size(dim), index.options());
@@ -141,7 +141,7 @@ segment_coo_cpu(torch::Tensor src, torch::Tensor index,
141141
}
142142

143143
torch::Tensor gather_coo_cpu(torch::Tensor src, torch::Tensor index,
144-
torch::optional<torch::Tensor> optional_out) {
144+
std::optional<torch::Tensor> optional_out) {
145145
CHECK_CPU(src);
146146
CHECK_CPU(index);
147147
if (optional_out.has_value())

csrc/cpu/segment_coo_cpu.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
#include "../extensions.h"
44

5-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
5+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
66
segment_coo_cpu(torch::Tensor src, torch::Tensor index,
7-
torch::optional<torch::Tensor> optional_out,
8-
torch::optional<int64_t> dim_size, std::string reduce);
7+
std::optional<torch::Tensor> optional_out,
8+
std::optional<int64_t> dim_size, std::string reduce);
99

1010
torch::Tensor gather_coo_cpu(torch::Tensor src, torch::Tensor index,
11-
torch::optional<torch::Tensor> optional_out);
11+
std::optional<torch::Tensor> optional_out);

csrc/cpu/segment_csr_cpu.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include "utils.h"
66
#include <ATen/OpMathType.h>
77

8-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
8+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
99
segment_csr_cpu(torch::Tensor src, torch::Tensor indptr,
10-
torch::optional<torch::Tensor> optional_out,
10+
std::optional<torch::Tensor> optional_out,
1111
std::string reduce) {
1212
CHECK_CPU(src);
1313
CHECK_CPU(indptr);
@@ -38,7 +38,7 @@ segment_csr_cpu(torch::Tensor src, torch::Tensor indptr,
3838
out = torch::empty(sizes, src.options());
3939
}
4040

41-
torch::optional<torch::Tensor> arg_out = torch::nullopt;
41+
std::optional<torch::Tensor> arg_out = std::nullopt;
4242
int64_t *arg_out_data = nullptr;
4343
if (reduce2REDUCE.at(reduce) == MIN || reduce2REDUCE.at(reduce) == MAX) {
4444
arg_out = torch::full(out.sizes(), src.size(dim), indptr.options());
@@ -92,7 +92,7 @@ segment_csr_cpu(torch::Tensor src, torch::Tensor indptr,
9292
}
9393

9494
torch::Tensor gather_csr_cpu(torch::Tensor src, torch::Tensor indptr,
95-
torch::optional<torch::Tensor> optional_out) {
95+
std::optional<torch::Tensor> optional_out) {
9696
CHECK_CPU(src);
9797
CHECK_CPU(indptr);
9898
if (optional_out.has_value())

csrc/cpu/segment_csr_cpu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
#include "../extensions.h"
44

5-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
5+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
66
segment_csr_cpu(torch::Tensor src, torch::Tensor indptr,
7-
torch::optional<torch::Tensor> optional_out,
7+
std::optional<torch::Tensor> optional_out,
88
std::string reduce);
99

1010
torch::Tensor gather_csr_cpu(torch::Tensor src, torch::Tensor indptr,
11-
torch::optional<torch::Tensor> optional_out);
11+
std::optional<torch::Tensor> optional_out);

csrc/cuda/scatter_cuda.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ scatter_arg_kernel(const scalar_t *src_data,
5555
}
5656
}
5757

58-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
58+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
5959
scatter_cuda(torch::Tensor src, torch::Tensor index, int64_t dim,
60-
torch::optional<torch::Tensor> optional_out,
61-
torch::optional<int64_t> dim_size, std::string reduce) {
60+
std::optional<torch::Tensor> optional_out,
61+
std::optional<int64_t> dim_size, std::string reduce) {
6262
CHECK_CUDA(src);
6363
CHECK_CUDA(index);
6464
if (optional_out.has_value())
@@ -89,7 +89,7 @@ scatter_cuda(torch::Tensor src, torch::Tensor index, int64_t dim,
8989
out = torch::empty(sizes, src.options());
9090
}
9191

92-
torch::optional<torch::Tensor> arg_out = torch::nullopt;
92+
std::optional<torch::Tensor> arg_out = std::nullopt;
9393
int64_t *arg_out_data = nullptr;
9494
if (reduce2REDUCE.at(reduce) == MIN || reduce2REDUCE.at(reduce) == MAX) {
9595
arg_out = torch::full_like(out, src.size(dim), index.options());

csrc/cuda/scatter_cuda.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "../extensions.h"
44

5-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
5+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
66
scatter_cuda(torch::Tensor src, torch::Tensor index, int64_t dim,
7-
torch::optional<torch::Tensor> optional_out,
8-
torch::optional<int64_t> dim_size, std::string reduce);
7+
std::optional<torch::Tensor> optional_out,
8+
std::optional<int64_t> dim_size, std::string reduce);

csrc/cuda/segment_coo_cuda.cu

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ __global__ void segment_coo_arg_broadcast_kernel(
149149
}
150150
}
151151

152-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
152+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
153153
segment_coo_cuda(torch::Tensor src, torch::Tensor index,
154-
torch::optional<torch::Tensor> optional_out,
155-
torch::optional<int64_t> dim_size, std::string reduce) {
154+
std::optional<torch::Tensor> optional_out,
155+
std::optional<int64_t> dim_size, std::string reduce) {
156156
CHECK_CUDA(src);
157157
CHECK_CUDA(index);
158158
if (optional_out.has_value())
@@ -191,7 +191,7 @@ segment_coo_cuda(torch::Tensor src, torch::Tensor index,
191191
out = torch::zeros(sizes, src.options());
192192
}
193193

194-
torch::optional<torch::Tensor> arg_out = torch::nullopt;
194+
std::optional<torch::Tensor> arg_out = std::nullopt;
195195
int64_t *arg_out_data = nullptr;
196196
if (reduce2REDUCE.at(reduce) == MIN || reduce2REDUCE.at(reduce) == MAX) {
197197
arg_out = torch::full_like(out, src.size(dim), index.options());
@@ -325,7 +325,7 @@ __global__ void gather_coo_broadcast_kernel(
325325
}
326326
327327
torch::Tensor gather_coo_cuda(torch::Tensor src, torch::Tensor index,
328-
torch::optional<torch::Tensor> optional_out) {
328+
std::optional<torch::Tensor> optional_out) {
329329
CHECK_CUDA(src);
330330
CHECK_CUDA(index);
331331
if (optional_out.has_value())

csrc/cuda/segment_coo_cuda.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
#include "../extensions.h"
44

5-
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
5+
std::tuple<torch::Tensor, std::optional<torch::Tensor>>
66
segment_coo_cuda(torch::Tensor src, torch::Tensor index,
7-
torch::optional<torch::Tensor> optional_out,
8-
torch::optional<int64_t> dim_size, std::string reduce);
7+
std::optional<torch::Tensor> optional_out,
8+
std::optional<int64_t> dim_size, std::string reduce);
99

1010
torch::Tensor gather_coo_cuda(torch::Tensor src, torch::Tensor index,
11-
torch::optional<torch::Tensor> optional_out);
11+
std::optional<torch::Tensor> optional_out);

0 commit comments

Comments
 (0)