Skip to content

ValueError with linalg.dot when transa=True #326

@rileyjmurray

Description

@rileyjmurray

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions