Skip to content

Commit

Permalink
spurious diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
mitkotak committed Nov 25, 2024
1 parent a95b28d commit 3115468
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
16 changes: 8 additions & 8 deletions data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from torch_geometric.loader import DataLoader
from torch_geometric.nn import radius_graph

def get_random_graph(nodes, cutoff) -> Data:
def get_random_graph(n_nodes, cutoff) -> Data:

positions = torch.randn(nodes, 3)
positions = torch.randn(n_nodes, 3)

distance_matrix = positions[:, None, :] - positions[None, :, :]
distance_matrix = torch.linalg.norm(distance_matrix, dim=-1)
assert distance_matrix.shape == (nodes, nodes)
assert distance_matrix.shape == (n_nodes, n_nodes)

senders, receivers = torch.nonzero(distance_matrix < cutoff).T

Expand All @@ -20,11 +20,11 @@ def get_random_graph(nodes, cutoff) -> Data:

# Create a PyTorch Geometric Data object
graph = Data(
pos = positions,
relative_vectors = positions[receivers] - positions[senders],
y=z,
edge_index=edge_index,
num_nodes=len(positions)
pos = positions, # node positions
relative_vectors = positions[receivers] - positions[senders], # node relative positions
y=z, # graph label
edge_index=edge_index, # edge indices
numbers=torch.ones((len(positions),1)), # node features
)

return graph
Expand Down
15 changes: 13 additions & 2 deletions inference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ int main(int argc, char *argv[]) {
runner = new torch::inductor::AOTIModelContainerRunnerCuda(model_path, 1);
std::vector<torch::Tensor> inputs = {
// node_features
torch::randn({32,1}, torch::TensorOptions().dtype(torch::kFloat32).device(torch::kCUDA)),

torch::ones({32, 1}, torch::TensorOptions().dtype(torch::kFloat32).device(torch::kCUDA)),


// pos
torch::randn({32,3}, torch::TensorOptions().dtype(torch::kFloat32).device(torch::kCUDA)),
torch::tensor({
{0., 0., 0.}, {0., 0., 1.}, {1., 0., 0.}, {1., 1., 0.},
{1., 1., 1.}, {1., 1., 2.}, {2., 1., 1.}, {2., 0., 1.},
{0., 0., 0.}, {1., 0., 0.}, {0., 1., 0.}, {1., 1., 0.},
{0., 0., 0.}, {0., 0., 1.}, {0., 0., 2.}, {0., 0., 3.},
{0., 0., 0.}, {0., 0., 1.}, {0., 1., 0.}, {1., 0., 0.},
{0., 0., 0.}, {0., 0., 1.}, {0., 0., 2.}, {0., 1., 0.},
{0., 0., 0.}, {0., 0., 1.}, {0., 0., 2.}, {0., 1., 1.},
{0., 0., 0.}, {1., 0., 0.}, {1., 1., 0.}, {2., 1., 0.}
}, torch::TensorOptions().dtype(torch::kFloat32).device(torch::kCUDA)),

// edge_index
torch::tensor({
Expand Down

0 comments on commit 3115468

Please sign in to comment.