Skip to content

Most reductions in ArrayFire.Algorithms should return array, not scalar #36

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

Closed
gilgamec opened this issue Nov 8, 2019 · 2 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@gilgamec
Copy link

gilgamec commented Nov 8, 2019

The functions which take a dimension to reduce along should return a full matrix, with only that dimension flattened, rather than a single scalar. These are (at least) sum, sumNaN, product, productNaN, min, max, allTrue, anyTrue, and count. The correct array is being computed by the FFI, but the getScalar function is being applied and just extracts the first element, rather than returning the entire array. The current behaviour of (for instance) sum is

λ> A.mkArray @Int [2,3] [1..]
ArrayFire Array
[2 3 1 1]
         1          3          5 
         2          4          6 
λ> A.sum it 0
3
λ> A.sum it 1
9

as opposed to the expected output,

ArrayFire Array
[1 3 1 1]
         3          7         11 

and

ArrayFire Array
[2 1 1 1]
         9 
        12 
@dmjio
Copy link
Member

dmjio commented Nov 9, 2019

I think a few of these functions should be extracting a scalar value, allTrue, anyTrue, countAll, but the rest probably not. I'll make a PR to remove this.

@dmjio dmjio self-assigned this Nov 9, 2019
@dmjio dmjio added the enhancement New feature or request label Nov 9, 2019
@dmjio
Copy link
Member

dmjio commented Nov 9, 2019

@gilgamec this should solve all those issues, tests have been updated to reflect the changes.

#24

@dmjio dmjio closed this as completed Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants