Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
akihironitta committed Feb 12, 2025
1 parent 3b6ef9d commit 14e9e49
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions pyg_lib/csrc/partition/cpu/metis_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace {
at::Tensor metis_kernel(const at::Tensor& rowptr,
const at::Tensor& col,
int64_t num_partitions,
const c10::optional<at::Tensor>& node_weight,
const c10::optional<at::Tensor>& edge_weight,
const std::optional<at::Tensor>& node_weight,
const std::optional<at::Tensor>& edge_weight,
bool recursive) {
#ifdef _WIN32
TORCH_INTERNAL_ASSERT(false, "METIS not yet supported on Windows");
Expand Down
4 changes: 2 additions & 2 deletions pyg_lib/csrc/partition/metis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace partition {
at::Tensor metis(const at::Tensor& rowptr,
const at::Tensor& col,
int64_t num_partitions,
const c10::optional<at::Tensor>& node_weight,
const c10::optional<at::Tensor>& edge_weight,
const std::optional<at::Tensor>& node_weight,
const std::optional<at::Tensor>& edge_weight,
bool recursive) {
at::TensorArg rowptr_t{rowptr, "rowtpr", 1};
at::TensorArg col_t{col, "col", 1};
Expand Down
2 changes: 1 addition & 1 deletion pyg_lib/csrc/random/cpu/biased_sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace pyg {
namespace random {

c10::optional<at::Tensor> biased_to_cdf(const at::Tensor& rowptr,
std::optional<at::Tensor> biased_to_cdf(const at::Tensor& rowptr,
at::Tensor& bias,
bool inplace) {
TORCH_CHECK(rowptr.is_cpu(), "'rowptr' must be a CPU tensor");
Expand Down
10 changes: 5 additions & 5 deletions pyg_lib/csrc/sampler/cpu/dist_merge_outputs_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace {
template <bool disjoint>
std::tuple<at::Tensor,
at::Tensor,
c10::optional<at::Tensor>,
std::optional<at::Tensor>,
std::vector<int64_t>>
merge_outputs(
const std::vector<at::Tensor>& node_ids,
Expand All @@ -25,10 +25,10 @@ merge_outputs(
const std::vector<int64_t>& partition_orders,
const int64_t num_partitions,
const int64_t num_neighbors,
const c10::optional<at::Tensor>& batch) {
const std::optional<at::Tensor>& batch) {
at::Tensor out_node_id;
at::Tensor out_edge_id;
c10::optional<at::Tensor> out_batch = c10::nullopt;
std::optional<at::Tensor> out_batch = c10::nullopt;

auto offset = num_neighbors;

Expand Down Expand Up @@ -140,7 +140,7 @@ merge_outputs(

std::tuple<at::Tensor,
at::Tensor,
c10::optional<at::Tensor>,
std::optional<at::Tensor>,
std::vector<int64_t>>
merge_sampler_outputs_kernel(
const std::vector<at::Tensor>& node_ids,
Expand All @@ -150,7 +150,7 @@ merge_sampler_outputs_kernel(
const std::vector<int64_t>& partition_orders,
const int64_t num_partitions,
const int64_t num_neighbors,
const c10::optional<at::Tensor>& batch,
const std::optional<at::Tensor>& batch,
bool disjoint) {
DISPATCH_MERGE_OUTPUTS(
disjoint, node_ids, edge_ids, cumsum_neighbors_per_node, partition_ids,
Expand Down
8 changes: 4 additions & 4 deletions pyg_lib/csrc/sampler/cpu/dist_relabel_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::tuple<at::Tensor, at::Tensor> relabel(
const at::Tensor& sampled_nodes_with_duplicates,
const std::vector<int64_t>& num_sampled_neighbors_per_node,
const int64_t num_nodes,
const c10::optional<at::Tensor>& batch,
const std::optional<at::Tensor>& batch,
const bool csc) {
if (disjoint) {
TORCH_CHECK(batch.has_value(),
Expand Down Expand Up @@ -103,7 +103,7 @@ relabel(
const c10::Dict<rel_type, std::vector<std::vector<int64_t>>>&
num_sampled_neighbors_per_node_dict,
const c10::Dict<node_type, int64_t>& num_nodes_dict,
const c10::optional<c10::Dict<node_type, at::Tensor>>& batch_dict,
const std::optional<c10::Dict<node_type, at::Tensor>>& batch_dict,
const bool csc) {
c10::Dict<rel_type, at::Tensor> out_row_dict, out_col_dict;

Expand Down Expand Up @@ -281,7 +281,7 @@ std::tuple<at::Tensor, at::Tensor> relabel_neighborhood_kernel(
const at::Tensor& sampled_nodes_with_duplicates,
const std::vector<int64_t>& num_sampled_neighbors_per_node,
const int64_t num_nodes,
const c10::optional<at::Tensor>& batch,
const std::optional<at::Tensor>& batch,
bool csc,
bool disjoint) {
DISPATCH_RELABEL(disjoint, seed, sampled_nodes_with_duplicates,
Expand All @@ -297,7 +297,7 @@ hetero_relabel_neighborhood_kernel(
const c10::Dict<rel_type, std::vector<std::vector<int64_t>>>&
num_sampled_neighbors_per_node_dict,
const c10::Dict<node_type, int64_t>& num_nodes_dict,
const c10::optional<c10::Dict<node_type, at::Tensor>>& batch_dict,
const std::optional<c10::Dict<node_type, at::Tensor>>& batch_dict,
bool csc,
bool disjoint) {
c10::Dict<rel_type, at::Tensor> out_row_dict, out_col_dict;
Expand Down
56 changes: 28 additions & 28 deletions pyg_lib/csrc/sampler/cpu/neighbor_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ class NeighborSampler {
dst_mapper, generator, out_global_dst_nodes);
}

std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>>
std::tuple<at::Tensor, at::Tensor, std::optional<at::Tensor>>
get_sampled_edges(bool csc = false) {
TORCH_CHECK(save_edges, "No edges have been stored")
const auto row = pyg::utils::from_vector(sampled_rows_);
const auto col = pyg::utils::from_vector(sampled_cols_);
c10::optional<at::Tensor> edge_id = c10::nullopt;
std::optional<at::Tensor> edge_id = c10::nullopt;
if (save_edge_ids) {
edge_id = pyg::utils::from_vector(sampled_edge_ids_);
}
Expand Down Expand Up @@ -330,18 +330,18 @@ template <bool replace,
std::tuple<at::Tensor,
at::Tensor,
at::Tensor,
c10::optional<at::Tensor>,
std::optional<at::Tensor>,
std::vector<int64_t>,
std::vector<int64_t>,
std::vector<int64_t>>
sample(const at::Tensor& rowptr,
const at::Tensor& col,
const at::Tensor& seed,
const std::vector<int64_t>& num_neighbors,
const c10::optional<at::Tensor>& node_time,
const c10::optional<at::Tensor>& edge_time,
const c10::optional<at::Tensor>& seed_time,
const c10::optional<at::Tensor>& edge_weight,
const std::optional<at::Tensor>& node_time,
const std::optional<at::Tensor>& edge_time,
const std::optional<at::Tensor>& seed_time,
const std::optional<at::Tensor>& edge_weight,
const bool csc,
const std::string temporal_strategy) {
TORCH_CHECK(!node_time.has_value() || disjoint,
Expand Down Expand Up @@ -373,7 +373,7 @@ sample(const at::Tensor& rowptr,
"Biased edge temporal sampling not yet supported");

at::Tensor out_row, out_col, out_node_id;
c10::optional<at::Tensor> out_edge_id = c10::nullopt;
std::optional<at::Tensor> out_edge_id = c10::nullopt;
std::vector<int64_t> num_sampled_nodes_per_hop;
std::vector<int64_t> num_sampled_edges_per_hop;
std::vector<int64_t> cumsum_neighbors_per_node =
Expand Down Expand Up @@ -516,7 +516,7 @@ template <bool replace,
std::tuple<c10::Dict<rel_type, at::Tensor>,
c10::Dict<rel_type, at::Tensor>,
c10::Dict<node_type, at::Tensor>,
c10::optional<c10::Dict<rel_type, at::Tensor>>,
std::optional<c10::Dict<rel_type, at::Tensor>>,
c10::Dict<node_type, std::vector<int64_t>>,
c10::Dict<rel_type, std::vector<int64_t>>>
sample(const std::vector<node_type>& node_types,
Expand All @@ -525,10 +525,10 @@ sample(const std::vector<node_type>& node_types,
const c10::Dict<rel_type, at::Tensor>& col_dict,
const c10::Dict<node_type, at::Tensor>& seed_dict,
const c10::Dict<rel_type, std::vector<int64_t>>& num_neighbors_dict,
const c10::optional<c10::Dict<node_type, at::Tensor>>& node_time_dict,
const c10::optional<c10::Dict<rel_type, at::Tensor>>& edge_time_dict,
const c10::optional<c10::Dict<node_type, at::Tensor>>& seed_time_dict,
const c10::optional<c10::Dict<rel_type, at::Tensor>>& edge_weight_dict,
const std::optional<c10::Dict<node_type, at::Tensor>>& node_time_dict,
const std::optional<c10::Dict<rel_type, at::Tensor>>& edge_time_dict,
const std::optional<c10::Dict<node_type, at::Tensor>>& seed_time_dict,
const std::optional<c10::Dict<rel_type, at::Tensor>>& edge_weight_dict,
const bool csc,
const std::string temporal_strategy) {
TORCH_CHECK(!node_time_dict.has_value() || disjoint,
Expand Down Expand Up @@ -576,7 +576,7 @@ sample(const std::vector<node_type>& node_types,

c10::Dict<rel_type, at::Tensor> out_row_dict, out_col_dict;
c10::Dict<node_type, at::Tensor> out_node_id_dict;
c10::optional<c10::Dict<node_type, at::Tensor>> out_edge_id_dict;
std::optional<c10::Dict<node_type, at::Tensor>> out_edge_id_dict;
if (return_edge_id) {
out_edge_id_dict = c10::Dict<rel_type, at::Tensor>();
} else {
Expand Down Expand Up @@ -892,17 +892,17 @@ sample(const std::vector<node_type>& node_types,
std::tuple<at::Tensor,
at::Tensor,
at::Tensor,
c10::optional<at::Tensor>,
std::optional<at::Tensor>,
std::vector<int64_t>,
std::vector<int64_t>>
neighbor_sample_kernel(const at::Tensor& rowptr,
const at::Tensor& col,
const at::Tensor& seed,
const std::vector<int64_t>& num_neighbors,
const c10::optional<at::Tensor>& node_time,
const c10::optional<at::Tensor>& edge_time,
const c10::optional<at::Tensor>& seed_time,
const c10::optional<at::Tensor>& edge_weight,
const std::optional<at::Tensor>& node_time,
const std::optional<at::Tensor>& edge_time,
const std::optional<at::Tensor>& seed_time,
const std::optional<at::Tensor>& edge_weight,
bool csc,
bool replace,
bool directed,
Expand All @@ -921,7 +921,7 @@ neighbor_sample_kernel(const at::Tensor& rowptr,
std::tuple<c10::Dict<rel_type, at::Tensor>,
c10::Dict<rel_type, at::Tensor>,
c10::Dict<node_type, at::Tensor>,
c10::optional<c10::Dict<rel_type, at::Tensor>>,
std::optional<c10::Dict<rel_type, at::Tensor>>,
c10::Dict<node_type, std::vector<int64_t>>,
c10::Dict<rel_type, std::vector<int64_t>>>
hetero_neighbor_sample_kernel(
Expand All @@ -931,10 +931,10 @@ hetero_neighbor_sample_kernel(
const c10::Dict<rel_type, at::Tensor>& col_dict,
const c10::Dict<node_type, at::Tensor>& seed_dict,
const c10::Dict<rel_type, std::vector<int64_t>>& num_neighbors_dict,
const c10::optional<c10::Dict<node_type, at::Tensor>>& node_time_dict,
const c10::optional<c10::Dict<rel_type, at::Tensor>>& edge_time_dict,
const c10::optional<c10::Dict<node_type, at::Tensor>>& seed_time_dict,
const c10::optional<c10::Dict<rel_type, at::Tensor>>& edge_weight_dict,
const std::optional<c10::Dict<node_type, at::Tensor>>& node_time_dict,
const std::optional<c10::Dict<rel_type, at::Tensor>>& edge_time_dict,
const std::optional<c10::Dict<node_type, at::Tensor>>& seed_time_dict,
const std::optional<c10::Dict<rel_type, at::Tensor>>& edge_weight_dict,
bool csc,
bool replace,
bool directed,
Expand All @@ -952,10 +952,10 @@ dist_neighbor_sample_kernel(const at::Tensor& rowptr,
const at::Tensor& col,
const at::Tensor& seed,
const int64_t num_neighbors,
const c10::optional<at::Tensor>& node_time,
const c10::optional<at::Tensor>& edge_time,
const c10::optional<at::Tensor>& seed_time,
const c10::optional<at::Tensor>& edge_weight,
const std::optional<at::Tensor>& node_time,
const std::optional<at::Tensor>& edge_time,
const std::optional<at::Tensor>& seed_time,
const std::optional<at::Tensor>& edge_weight,
bool csc,
bool replace,
bool directed,
Expand Down
4 changes: 2 additions & 2 deletions pyg_lib/csrc/sampler/cpu/subgraph_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace sampler {

namespace {

std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>> subgraph_kernel(
std::tuple<at::Tensor, at::Tensor, std::optional<at::Tensor>> subgraph_kernel(
const at::Tensor& rowptr,
const at::Tensor& col,
const at::Tensor& nodes,
Expand All @@ -21,7 +21,7 @@ std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>> subgraph_kernel(

const auto out_rowptr = rowptr.new_empty({nodes.size(0) + 1});
at::Tensor out_col;
c10::optional<at::Tensor> out_edge_id = c10::nullopt;
std::optional<at::Tensor> out_edge_id = c10::nullopt;

AT_DISPATCH_INTEGRAL_TYPES(nodes.scalar_type(), "subgraph_kernel", [&] {
const auto rowptr_data = rowptr.data_ptr<scalar_t>();
Expand Down
4 changes: 2 additions & 2 deletions pyg_lib/csrc/sampler/dist_merge_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace sampler {

std::tuple<at::Tensor,
at::Tensor,
c10::optional<at::Tensor>,
std::optional<at::Tensor>,
std::vector<int64_t>>
merge_sampler_outputs(
const std::vector<at::Tensor>& node_ids,
Expand All @@ -20,7 +20,7 @@ merge_sampler_outputs(
const std::vector<int64_t>& partition_orders,
const int64_t num_partitions,
const int64_t num_neighbors,
const c10::optional<at::Tensor>& batch,
const std::optional<at::Tensor>& batch,
bool disjoint) {
std::vector<at::TensorArg> node_ids_args;
std::vector<at::TensorArg> edge_ids_args;
Expand Down
4 changes: 2 additions & 2 deletions pyg_lib/csrc/sampler/dist_relabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ std::tuple<at::Tensor, at::Tensor> relabel_neighborhood(
const at::Tensor& sampled_nodes_with_duplicates,
const std::vector<int64_t>& num_sampled_neighbors_per_node,
const int64_t num_nodes,
const c10::optional<at::Tensor>& batch,
const std::optional<at::Tensor>& batch,
bool csc,
bool disjoint) {
at::TensorArg seed_t{seed, "seed", 1};
Expand Down Expand Up @@ -41,7 +41,7 @@ hetero_relabel_neighborhood(
const c10::Dict<rel_type, std::vector<std::vector<int64_t>>>&
num_sampled_neighbors_per_node_dict,
const c10::Dict<node_type, int64_t>& num_nodes_dict,
const c10::optional<c10::Dict<node_type, at::Tensor>>& batch_dict,
const std::optional<c10::Dict<node_type, at::Tensor>>& batch_dict,
bool csc,
bool disjoint) {
std::vector<at::TensorArg> seed_dict_args;
Expand Down
28 changes: 14 additions & 14 deletions pyg_lib/csrc/sampler/neighbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ namespace sampler {
std::tuple<at::Tensor,
at::Tensor,
at::Tensor,
c10::optional<at::Tensor>,
std::optional<at::Tensor>,
std::vector<int64_t>,
std::vector<int64_t>>
neighbor_sample(const at::Tensor& rowptr,
const at::Tensor& col,
const at::Tensor& seed,
const std::vector<int64_t>& num_neighbors,
const c10::optional<at::Tensor>& node_time,
const c10::optional<at::Tensor>& edge_time,
const c10::optional<at::Tensor>& seed_time,
const c10::optional<at::Tensor>& edge_weight,
const std::optional<at::Tensor>& node_time,
const std::optional<at::Tensor>& edge_time,
const std::optional<at::Tensor>& seed_time,
const std::optional<at::Tensor>& edge_weight,
bool csc,
bool replace,
bool directed,
Expand All @@ -47,7 +47,7 @@ neighbor_sample(const at::Tensor& rowptr,
std::tuple<c10::Dict<rel_type, at::Tensor>,
c10::Dict<rel_type, at::Tensor>,
c10::Dict<node_type, at::Tensor>,
c10::optional<c10::Dict<rel_type, at::Tensor>>,
std::optional<c10::Dict<rel_type, at::Tensor>>,
c10::Dict<node_type, std::vector<int64_t>>,
c10::Dict<rel_type, std::vector<int64_t>>>
hetero_neighbor_sample(
Expand All @@ -57,10 +57,10 @@ hetero_neighbor_sample(
const c10::Dict<rel_type, at::Tensor>& col_dict,
const c10::Dict<node_type, at::Tensor>& seed_dict,
const c10::Dict<rel_type, std::vector<int64_t>>& num_neighbors_dict,
const c10::optional<c10::Dict<node_type, at::Tensor>>& node_time_dict,
const c10::optional<c10::Dict<rel_type, at::Tensor>>& edge_time_dict,
const c10::optional<c10::Dict<node_type, at::Tensor>>& seed_time_dict,
const c10::optional<c10::Dict<rel_type, at::Tensor>>& edge_weight_dict,
const std::optional<c10::Dict<node_type, at::Tensor>>& node_time_dict,
const std::optional<c10::Dict<rel_type, at::Tensor>>& edge_time_dict,
const std::optional<c10::Dict<node_type, at::Tensor>>& seed_time_dict,
const std::optional<c10::Dict<rel_type, at::Tensor>>& edge_weight_dict,
bool csc,
bool replace,
bool directed,
Expand Down Expand Up @@ -101,10 +101,10 @@ std::tuple<at::Tensor, at::Tensor, std::vector<int64_t>> dist_neighbor_sample(
const at::Tensor& col,
const at::Tensor& seed,
const int64_t num_neighbors,
const c10::optional<at::Tensor>& node_time,
const c10::optional<at::Tensor>& edge_time,
const c10::optional<at::Tensor>& seed_time,
const c10::optional<at::Tensor>& edge_weight,
const std::optional<at::Tensor>& node_time,
const std::optional<at::Tensor>& edge_time,
const std::optional<at::Tensor>& seed_time,
const std::optional<at::Tensor>& edge_weight,
bool csc,
bool replace,
bool directed,
Expand Down
2 changes: 1 addition & 1 deletion pyg_lib/csrc/sampler/subgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace pyg {
namespace sampler {

std::tuple<at::Tensor, at::Tensor, c10::optional<at::Tensor>> subgraph(
std::tuple<at::Tensor, at::Tensor, std::optional<at::Tensor>> subgraph(
const at::Tensor& rowptr,
const at::Tensor& col,
const at::Tensor& nodes,
Expand Down

0 comments on commit 14e9e49

Please sign in to comment.