Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artemis Automated Code Optimiser: Readability Improvements #390

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions modulus/datapipes/gnn/vortex_shedding_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,25 +207,19 @@ def __len__(self):
return self.length

def _get_edge_stats(self):
edge_mean = 0
edge_meansqr = 0
for i in range(self.num_samples):
edge_mean += torch.mean(self.graphs[i].edata["x"], dim=0)
edge_meansqr += torch.mean(torch.square(self.graphs[i].edata["x"]), dim=0)
edge_mean /= self.num_samples
edge_meansqr /= self.num_samples
edge_std = torch.sqrt(edge_meansqr - torch.square(edge_mean))
stats = {
"edge_mean": 0,
"edge_meansqr": 0,
"edge_mean": edge_mean,
"edge_std": edge_std,
}
for i in range(self.num_samples):
stats["edge_mean"] += (
torch.mean(self.graphs[i].edata["x"], dim=0) / self.num_samples
)
stats["edge_meansqr"] += (
torch.mean(torch.square(self.graphs[i].edata["x"]), dim=0)
/ self.num_samples
)
stats["edge_std"] = torch.sqrt(
stats["edge_meansqr"] - torch.square(stats["edge_mean"])
)
stats.pop("edge_meansqr")

# save to file
save_json(stats, "edge_stats.json")
save_json(stats, 'edge_stats.json')
return stats

def _get_node_stats(self):
Expand Down Expand Up @@ -379,13 +373,8 @@ def _push_forward_diff(invar):

@staticmethod
def _get_rollout_mask(node_type):
mask = torch.logical_or(
torch.eq(node_type, torch.zeros_like(node_type)),
torch.eq(
node_type,
torch.zeros_like(node_type) + 5,
),
)
zeros = torch.zeros_like(node_type)
mask = torch.logical_or(torch.eq(node_type, zeros), torch.eq(node_type, zeros + 5))
return mask

@staticmethod
Expand Down