-
Notifications
You must be signed in to change notification settings - Fork 11
Add sparse matrix interface #349
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
base: main
Are you sure you want to change the base?
Conversation
|
@inducer I added a loopy kernel fallback for eager (code), and it's working when the array being multiplied is 1D, but I'm running into some trouble with array strides for higher dimensions. I set up the input array like this: u1 = actx.np.where(actx.np.less_equal(x, (a+b)/2), 0*x + 1, 0*x)
u2 = actx.np.where(actx.np.greater_equal(x, (a+b)/2), 0*x + 1, 0*x)
# u = actx.freeze_thaw(u1) # 1D
u = actx.freeze_thaw(actx.np.stack([u1, u2]).T) # 2DThe strides are no longer C-like after transposing. Lazy doesn't seem to care about this, but eager doesn't like it; it makes my 1D diffusion solver blow up instantly. If I add Edit: I guess the strides of |
|
FWIW, using a dense matrix + |
|
Upon closer inspection, it looks like the kernels may actually be OK. The problem occurs later in the test driver, when I do this: u = actx.freeze_thaw(u + dt*compiled_rhs(t, u))(here |
|
I added some limited support for applying sparse matrices to array containers. Currently it's restricted to the cases of
@inducer I think this is ready for a first look. I still have some FIXMEs scattered throughout the changes for things I could use some input on. |
…_matmul instead of using derived matrix classes
Adds a generic interface for operations involving sparse CSR matrices.
cc @lukeolson