Skip to content

Commit be0253d

Browse files
authored
Avoid scalar indexing in remove_edges (#672)
1 parent 04e8694 commit be0253d

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎GNNGraphs/src/GNNGraphs.jl‎

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

33
using SparseArrays
44
import Graphs
5-
using Graphs: AbstractGraph, outneighbors, inneighbors, adjacency_matrix, degree,
5+
using Graphs: AbstractGraph, outneighbors, inneighbors, adjacency_matrix, degree,
66
has_self_loops, is_directed, induced_subgraph, has_edge
77
import NearestNeighbors
88
import NNlib
@@ -11,7 +11,7 @@ import KrylovKit
1111
import ChainRulesCore as CRC
1212
using LinearAlgebra, Random, Statistics
1313
import MLUtils
14-
using MLUtils: getobs, numobs, ones_like, zeros_like, chunk, batch, rand_like
14+
using MLUtils: getobs, numobs, ones_like, zeros_like, fill_like, chunk, batch, rand_like
1515
using MLDataDevices: get_device, cpu_device, CPUDevice
1616
using Functors: @functor
1717

@@ -38,9 +38,9 @@ export GNNHeteroGraph,
3838
include("temporalsnapshotsgnngraph.jl")
3939
export TemporalSnapshotsGNNGraph,
4040
add_snapshot,
41-
# add_snapshot!,
41+
# add_snapshot!,
4242
remove_snapshot
43-
# remove_snapshot!
43+
# remove_snapshot!
4444

4545
include("query.jl")
4646
include("gnnheterograph/query.jl")
@@ -59,7 +59,7 @@ export adjacency_list,
5959
# from Graphs.jl
6060
adjacency_matrix,
6161
degree,
62-
has_edge,
62+
has_edge,
6363
has_isolated_nodes,
6464
has_self_loops,
6565
inneighbors,
@@ -75,7 +75,7 @@ export add_nodes,
7575
negative_sample,
7676
rand_edge_split,
7777
remove_self_loops,
78-
remove_edges,
78+
remove_edges,
7979
coalesce,
8080
set_edge_weight,
8181
to_bidirected,
@@ -117,7 +117,7 @@ export mldataset2gnngraph
117117
include("deprecations.jl")
118118

119119
include("sampling.jl")
120-
export NeighborLoader, sample_neighbors,
121-
induced_subgraph # from Graphs.jl
120+
export NeighborLoader, sample_neighbors,
121+
induced_subgraph # from Graphs.jl
122122

123123
end #module

‎GNNGraphs/src/transform.jl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ function remove_edges(g::GNNGraph{<:COO_T}, edges_to_remove::AbstractVector{<:In
123123
w = get_edge_weight(g)
124124
edata = g.edata
125125

126-
mask_to_keep = trues(length(s))
126+
# mask_to_keep = trues(length(s))
127+
mask_to_keep = MLUtils.fill_like(edges_to_remove, true)
127128

128129
mask_to_keep[edges_to_remove] .= false
129130

0 commit comments

Comments
 (0)