Skip to content

Fix and improve af::accum documentation #2298

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

Merged
merged 2 commits into from
Sep 24, 2018

Conversation

mark-poscablo
Copy link
Contributor

The accum docs has some typos, such as saying "exclusive sum" on the function docs while it is really an inclusive sum scan. Also I think the brief description needs to say "cumulative" somewhere - "inclusive sum (scan)" didn't really ring a bell to me until I started learning parallel programming (a Google search on "inclusive sum" also doesn't immediately get clear results that it means inclusive sum scan). I added an example too just so it's clearer what it does.

Here are some snapshots of the docs after the change:
image
image
image

\snippet test/scan.cpp ex_accum_1D

For 2D arrays (and higher dimensions), you can specify the dimension along which
the cumulative sum will be performed. If none is specified, it will be performed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think computed/computed sounds better than performed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah thanks, not sure why I wasn't consistent here, I did use "compute" in the brief description


For 2D arrays (and higher dimensions), you can specify the dimension along which
the cumulative sum will be performed. If none is specified, it will be performed
along the first dimension (0):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please verify if it dimension defaults to 0 or the first non-singleton dimension.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure, so I tried it:

    array s = iota(dim4(1, 4));
    af_print(s);
    af_print(accum(s));
s
[1 4 1 1]
   Offset: 0
   Strides: [1 1 4 4]
    0.0000     1.0000     2.0000     3.0000 
accum(s)
[1 4 1 1]
   Offset: 0
   Strides: [1 1 4 4]
    0.0000     1.0000     2.0000     3.0000 

Here dim1 is the first non-singleton dimension, and it looks like accum doesn't do anything to it. So I think it defaults to dim0. I should probably note though that this defaulting behavior is only on the C++ API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

PS. Defaults are only available for C++ API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a bug

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you expecting the default to be -1 ? I was, but the code has 0 as default right now for whatever reason.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect it to work on the first non-zero dimension. Does -1 do that? If it does then yes it should be the default. If it doesn't then it should be implemented.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fixed in a different PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 usually represents the first non-singleton dimension, this was the convention from the days of v2.x and we use it for most functions in v3.x also I believe.


\param[in] in is the input array
\param[in] dim The dimension along which exclusive sum is performed
\return the output containing exclusive sums of the input
\param[in] dim is the dimension along which inclusive sum is performed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my first comment, perform is mostly with subjective contexts. Perhaps calculated or computed.

\param[in] in is the input array
\param[in] dim The dimension along which exclusive sum is performed
\param[in] dim is the dimension along which inclusive sum is performed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as my previous comment about perform

@mark-poscablo
Copy link
Contributor Author

mark-poscablo commented Sep 24, 2018

@umar456 also requested that docs include a formula for the inclusive sum in the docs. Working on it.

@mark-poscablo
Copy link
Contributor Author

Here's how it looks like now:
image
image
image


For 2D arrays (and higher dimensions), you can specify the dimension along which
the cumulative sum will be performed. If none is specified, it will be performed
along the first dimension (0):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fixed in a different PR

@9prady9 9prady9 merged commit d111543 into arrayfire:master Sep 24, 2018
@mark-poscablo mark-poscablo deleted the improve-accum-docs branch October 29, 2018 17:50
@mlloreda mlloreda added this to the v3.6.2 milestone Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants