tedsta / gpuarray-rs

A simple array math library in Rust on top of OpenCL
MIT License
28 stars 4 forks source link

Inverse Matrix Kernel? #1

Open ghost opened 7 years ago

ghost commented 7 years ago

Hi folks,

This might be a noobish question, but I'm eager to learn here if it is. :)

I'd like to implement Moore Penrose, perhaps using this code as an example. I can't see any CL kernels or other tools to do a matrix inversion operation, which is required for this. I also don't know how to compose matrix operations that are provided, to provide an Inverse operation. If this is possible, I'd love to learn how! If not, does it (basic matrix inversion) require a dedicated OpenCL kernel?

Thanks!

tedsta commented 7 years ago

You are right, there is no basic matrix invert operation yet. A PR would be welcome :) It is a simple enough request though, perhaps I can do it after I get off of work tonight. I'll also write an example showing how to compose matrix operations.

Please note that this library is really just a toy. I wanted to learn the basics of OpenCL and also implement a neural network framework that used GPU kernels. I'm sure it is far from optimal (I don't have a fancy machine to performance test it on). I hope to continue work on it soon and switch to use ocl instead of rust-opencl, as the former is actively maintained and looks pretty mature now (when I created gpuarray-rs it was just starting out). I'd also like to make it easier to use. Composing operations gets messy very quickly as you can probably glean from the examples.

ghost commented 7 years ago

I'd be delighted to contribute, just as soon as I get a clue :D

Also happy to help with porting efforts, at that stage.

I guess this answers my question about inversion though: it would require a kernel, and can't be easily constructed (on-GPU) from the operations here. Thanks!

On 13 January 2017 18:16:06 GMT+00:00, Theodore DeRego notifications@github.com wrote:

You are right, their is no basic matrix invert operation yet. A PR would be welcome :) It is a simple enough request though, perhaps I can do it after I get off of work tonight. I'll also write an example showing how to compose matrix operations.

Please note that this library is really just a toy. I wanted to learn the basics of OpenCL and also implement a neural network framework that used GPU kernels. I'm sure it is far from optimal (I don't have a fancy machine to performance test it on). I hope to continue work on it soon and switch to use ocl instead of rust-opencl, as the former is actively maintained and looks pretty mature now (when I created gpuarray-rs it was just starting out). I'd also like to make it easier to use. Composing operations gets messy very quickly as you can probably glean from the examples.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/tedsta/gpuarray-rs/issues/1#issuecomment-272507876

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

tedsta commented 7 years ago

I made a simple example of composing operations. As you can see, it gets messy really quick. This was intended as more of a low level library used for buildings things on top (e.g. https://github.com/tedsta/deeplearn-rs). It also never really grew out of just being a toy.

https://github.com/tedsta/gpuarray-rs/blob/master/examples/operation_composition.rs

Anyway, as for a matrix inversion operation, I looked into it and it can be fairly complex to generalize it for any matrix size. I'll look into it more and see what I can do.