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

ValueError with linalg.dot when transa=True #326

Open
rileyjmurray opened this issue Nov 14, 2021 · 1 comment
Open

ValueError with linalg.dot when transa=True #326

rileyjmurray opened this issue Nov 14, 2021 · 1 comment

Comments

@rileyjmurray
Copy link

Problem

I want to compute the skcuda equivalent to A.T @ b for numpy arrays (A, b) when A has 2 dimensions and b has one dimension. Here's some simple test data

import numpy as np
import pycuda.gpuarray as gpuarray
import skcuda.linalg as skla

A_gpu = gpuarray.to_gpu(np.ones((3, 2)))
b_gpu = gpuarray.to_gpu(np.ones(3))

I would expect that the function call below produces the desired output. But instead it raises a ValueError:

skla.dot(A_gpu, b_gpu, transa='T')

Traceback (most recent call last):
  File "/home/riley/anaconda3/envs/rla39a/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-27-3e66e0c2b9c5>", line 1, in <module>
    skla.dot(A_gpu, b_gpu, transa='T')
  File "/home/riley/anaconda3/envs/rla39a/lib/python3.9/site-packages/skcuda/linalg.py", line 1060, in dot
    return out.reshape(out_shape)
  File "/home/riley/anaconda3/envs/rla39a/lib/python3.9/site-packages/pycuda/gpuarray.py", line 912, in reshape
    raise ValueError("total size of new array must be unchanged")
ValueError: total size of new array must be unchanged

The function call below computes the expected result

c_gpu = skla.dot(b_gpu, A_gpu)

Environment

  • Ubuntu 18.04
  • Python 3.9
  • CUDA 9.1.0 (I forget how I installed it, sorry!)
  • PyCUDA 2021.1
  • scikit-cuda 0.5.3.
@wingkitlee0
Copy link
Contributor

It sounds like a bug where the transpose option was not taken into account when out_shape is computed

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

2 participants