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

setUnion does not work on arrays of size 1 #1660

Closed
ranjanan opened this issue Dec 5, 2016 · 5 comments
Closed

setUnion does not work on arrays of size 1 #1660

ranjanan opened this issue Dec 5, 2016 · 5 comments
Milestone

Comments

@ranjanan
Copy link

ranjanan commented Dec 5, 2016

Unions of size 1 give the following error:

ERROR: ArrayFire Error (202) : Invalid input argument

It works for arrays with 2 or more elements though.

Ref JuliaGPU/ArrayFire.jl#99

@pavanky
Copy link
Member

pavanky commented Dec 5, 2016

Can you show some example code in C that fails ?

@9prady9
Copy link
Member

9prady9 commented Dec 5, 2016

@pavanky @ranjanan Reported this on gitter earlier today and i found that the following code stub generates the error he was talking about.

const int n = 1;
af::array A = af::randu(n, f32);
af::array B = af::randu(n, f32);
af::array C = af::setUnion(A, B, false);

If n = 1, earlier code generates the below error.

A
[1 1 1 1]
   Offset: 0
   Strides: [1 1 1 1]
    0.3990 
B
[1 1 1 1]
   Offset: 0
   Strides: [1 1 1 1]
    0.6720 
ArrayFire Exception (Invalid input argument:202):
In function af_err af_set_union(void**, af_array, af_array, bool)
In file src/api/c/set.cpp:82
Invalid argument at index 1
Expected: first_info.isVector()

In function af::array af::setUnion(const af::array&, const af::array&, bool)
In file src/api/cpp/set.cpp:38
terminate called after throwing an instance of 'af::exception'
  what():  ArrayFire Exception (Invalid input argument:202):
In function af_err af_set_union(void**, af_array, af_array, bool)
In file src/api/c/set.cpp:82
Invalid argument at index 1
Expected: first_info.isVector()

@pavanky pavanky added this to the v3.4.2 milestone Dec 5, 2016
@pavanky pavanky changed the title Unions do not work arrays of size 1 setUnion does not work arrays of size 1 Dec 5, 2016
@pavanky pavanky changed the title setUnion does not work arrays of size 1 setUnion does not work on arrays of size 1 Dec 5, 2016
@pavanky
Copy link
Member

pavanky commented Dec 6, 2016

@9prady9 can you fix the issue by adding isScalar() in set.cpp and then checking other functions that are using isVector too ?

For example I see convolve is also using this. We may need to punt to scalar multiplication when the kernel is a scalar instead of launching a convolve kernel.

@9prady9
Copy link
Member

9prady9 commented Dec 8, 2016

@pavanky I have checked for other files that are using isVector and all of the cases seems to be of legitimate usecases. I have fixed convolve checks.

@shehzan10
Copy link
Member

Fixed in hotfix-3.4.2

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

4 participants