Comments (2)
FYI, I looked into this:
using dgmm
is noticably faster: on my machine the following code takes 70ms with the current implementation, while an implementation based on *dgmm
takes 20ms.
Test code:
from scikits.cuda import linalg as la
import pycuda.autoinit
import pycuda.gpuarray as gpu
import numpy as np
la.init()
n = 1024*4
x = np.asarray(np.random.rand(n, n), np.float32)
d = np.asarray(np.random.rand(n, 1), np.float32).reshape(-1)
xd = gpu.to_gpu(x)
dd = gpu.to_gpu(d)
%time la.dot_diag(dd, xd).get()
However, the current version allows for incompatible types between A and D. E.g. it is possible to multiply a np.complex128 vector with a np.float64 diagonal matrix. *dgmm
requires that the diagonal matrix as well as the dense matrix be of the same type.
The current behaviour required in the linalg.pinv
implementation. However pinv
could certainly implemented using CULA's gelss
, which is probably a faster solution anyway. Then, that requirement would go away.
Alternatively, one could use *dgemm
if both arguments are of the same type, and use the old code if they are not (personally, I'd prefer the "cleaner" version of requiring D and A be of the same type).
As a sidenote, I think the cublas API is a bit cleaner than the scikit-cuda one: For me, it's more natural to specify whether D is multiplied from the Left/Right (= how cublas does it) than to specify whether A is transposed or not.
With that said, I can send a PR for my current code which replaces diag_dot with calls to *dgmm
if you're interested (But I guess I'd have to change pinv
to use gelss
or switch to the old implementation if A and D have different types).
from scikit-cuda.
A dgmm-based dot_diag() would be welcome. Requiring that all of the arguments have the same type seems reasonable since maintaining a single numerical storage type throughout a CUDA-based program is usually a given.
I would prefer to keep the current transpose-based interface to dot() and dot_diag() for the time being because some other code that my adviser's research group has written depends on it.
It would be interesting to see whether a gelss-based pinv() is be noticeably faster than the gesvd-based one irrespective of the proposed dot_diag() improvement (although I would have to investigate whether there are meaningful numerical differences between the two algorithms when applied to poorly conditioned matrices that might make one preferable to the other in certain circumstances).
from scikit-cuda.
Related Issues (20)
- Batch Matrix Multiplication using CuBLAS
- np.float() is deprecated in NumPy 1.20, which is used in misc.py HOT 1
- add birch, a cluster algorithm, please!!!! HOT 2
- linalg.misc.mult_matvec protential bug for Fortran Matrix-vector element wise mulitplication HOT 1
- skcuda.linalg.eig - return eigenvector, index issue ?
- test failed
- Schedule for 0.5.4 release? HOT 2
- Error while importing skcuda.linalg HOT 4
- CUSOLVER library only available in CUDA 7.0 and later
- skcuda.linalg.cho_solve API different than in scipy.linalg HOT 1
- cusolver.py can't import cusolver64_11.dll
- gpuarray fail to transpose and flatten after cublas.Sgemm
- ValueError with linalg.dot when transa=True HOT 1
- Can not install pycuda to Azure Container Instances with v100 HOT 1
- Missing `cublasSetMatrix` compared with CUDA documentation HOT 1
- `pycuda._driver.LogicError: cuMemAlloc failed: context is destroyed` (caused by scikit-cuda or even CUDA itself?) HOT 1
- qr decomposition HOT 1
- Calling cublasDgetrfBatched failed with pycuda
- UPDATE WINDOW NAME
- cufft library not found
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scikit-cuda.