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

Swapping 2 columns in a 2d tensor #1142

Open
Kreativshikkk opened this issue Mar 13, 2024 · 0 comments
Open

Swapping 2 columns in a 2d tensor #1142

Kreativshikkk opened this issue Mar 13, 2024 · 0 comments

Comments

@Kreativshikkk
Copy link

I have a function tridiagonalization to tridiagonalize matrix (2d tensor), and I want to map it to batch. It involves a for loop and on each iteration a permutation of 2 columns and 2 rows inside it. I do not understand how to permute 2 columns without errors. So my code for rows works and looks as follows:

row_temp = matrix_stacked[pivot[None]][0]
matrix_stacked[[pivot[None]][0]] = matrix_stacked[i+1].clone()
matrix_stacked[i+1] = row_temp

Where pivot is a tensor and i is a Python integer variable. For columns I have something like this:

column_temp = matrix_stacked[:, [pivot[None]][0]]
matrix_stacked[:, [pivot[None]][0]] = matrix_stacked[:, [i+1]].clone()
matrix_stacked[:, i+1] = column_temp

It does not wotk because of issues with size. What should I do in order to permute i+1 and pivot columns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant