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

fix: improved fix for making lstm weights contiguous #28368

Merged
merged 1 commit into from
Feb 21, 2024
Merged
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
7 changes: 1 addition & 6 deletions ivy/functional/backends/torch/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ def lstm(
if weights_transposed:
# transpose the weights if they are in the wrong format
all_weights = [
torch.transpose(weight, 1, 0) if weight.dim() == 2 else weight
torch.transpose(weight, 1, 0).contiguous() if weight.dim() == 2 else weight
for weight in all_weights
]
else:
Expand All @@ -910,11 +910,6 @@ def lstm(
if initial_states[1].dim() == 2:
initial_states[1] = ivy.expand_dims(initial_states[1])

# ensure all weights are contiguous, so they will work on gpu
for i, w in enumerate(all_weights):
if not w.is_contiguous():
all_weights[i] = w.contiguous()

ret = torch.lstm(
input,
initial_states,
Expand Down
Loading