★ wanayoo — archive 1999 https://github.com/xtensor-stack/xtensor/pull/2047Nouvelle recherche | Portail wanayoo
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

Fixed error with zero tensor size in xt::mean #2047

Merged
merged 1 commit into from May 20, 2020

Conversation

@tanshihaj
Copy link

@tanshihaj tanshihaj commented May 13, 2020

Checklist

  • The title and commit message(s) are descriptive.
  • Small commits made to fix your PR have been squashed to avoid history pollution.
  • Tests have been added for new features or bug fixes.
  • API of new functions and classes are documented.

Description

Fixed bug when zero tensor size after moving in xt::mean leads to inf mean values

@tanshihaj
Copy link
Author

@tanshihaj tanshihaj commented May 14, 2020

I've checked failed checks - they crashed because linker can't parse some argument:
unknown /machine argument: x64;/MANIFEST:NO
I don't that it connected with my changes

@tanshihaj
Copy link
Author

@tanshihaj tanshihaj commented May 19, 2020

anyone?

@JohanMabille
Copy link
Member

@JohanMabille JohanMabille commented May 19, 2020

I don't understand how your changes can have any impact, you are storing calls to size() in local variables and then immediatly use these locals as arguments for mean_division. This is equivalent to the previous code where calls to size are directly used as arguments, but more verbose.

@tanshihaj
Copy link
Author

@tanshihaj tanshihaj commented May 20, 2020 •

No, code is not equivalent to the previous one.
Here

auto s = sum<T>(std::forward<E>(e), std::forward<X>(axes), es);
return mean_division<T>(std::move(s), e.size() - ddof);

if e is rvalue it can be moved to the sum() functions arguments and therefore e.size() after calling sum() can be 0 and result of mean() can be inf. Test I've added reproduces situation when e is rvalue.

@JohanMabille
Copy link
Member

@JohanMabille JohanMabille commented May 20, 2020

Ha indeed, now I feel a bit embarrassed ;) Thanks for the PR, and the clarification.

The failure of azure pipelines is totally unrelated to your change (it seems that we have the same failure for the whole stack), however I would like to fix it before merging any PR.

@JohanMabille JohanMabille merged commit 9154860 into xtensor-stack:master May 20, 2020
10 of 12 checks passed
10 of 12 checks passed
xtensor-stack.xtensor Build #20200513.1 failed
Details
xtensor-stack.xtensor (Windows_clangcl) Windows_clangcl failed
Details
Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
xtensor-stack.xtensor (Linux clang_4) Linux clang_4 succeeded
Details
xtensor-stack.xtensor (Linux clang_5) Linux clang_5 succeeded
Details
xtensor-stack.xtensor (Linux clang_6) Linux clang_6 succeeded
Details
xtensor-stack.xtensor (Linux clang_7) Linux clang_7 succeeded
Details
xtensor-stack.xtensor (Linux clang_8) Linux clang_8 succeeded
Details
xtensor-stack.xtensor (Linux clang_9) Linux clang_9 succeeded
Details
xtensor-stack.xtensor (OSX macOS_10_14) OSX macOS_10_14 succeeded
Details
xtensor-stack.xtensor (OSX macOS_10_15) OSX macOS_10_15 succeeded
Details
@tanshihaj
Copy link
Author

@tanshihaj tanshihaj commented May 21, 2020

No problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.