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

Changing all non trivial operations that use broadcasting with einsum where possible #309

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions modelforge/potential/schnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ def forward(

# Generate interaction filters based on radial basis functions
W_ij = self.filter_network(f_ij.squeeze(1))
W_ij = W_ij * f_ij_cutoff # Shape: [n_pairs, number_of_filters]
W_ij = torch.einsum("nf,n->nf", W_ij, f_ij_cutoff.squeeze(-1))

# Perform continuous-filter convolution
x_j = atomic_embedding[idx_j]
x_ij = x_j * W_ij # Element-wise multiplication
x_ij = torch.einsum("nk,nk->nk", W_ij, x_j)

out = torch.zeros_like(atomic_embedding).scatter_add_(
0, idx_i.unsqueeze(-1).expand_as(x_ij), x_ij
Expand Down
Loading