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

[BUG] matx::argmax returns weird results for tensors that have all-negative elements #197

Closed
AtomicVar opened this issue Jun 16, 2022 · 1 comment · Fixed by #198
Closed

Comments

@AtomicVar
Copy link
Contributor

Describe the bug
When the input tensor has all-negative elements, like [-3, -1, -7], the matx::argmax returns weird index.

To Reproduce

#include <matx.h>

int main() {
  // Create a tensor with all negative elements
  auto t = matx::make_tensor<float, 1>({3});
  t.SetVals({-3, -1, -7});
  t.Print();

  // Apply matx::argmax
  matx::tensor_t<float, 0> max_val{};
  matx::tensor_t<matx::index_t, 0> max_idx{};
  matx::argmax(max_val, max_idx, t);
  max_val.Print();
  max_idx.Print();

  return 0;
}

Output:

000000: -3.0000e+00 
000001: -1.0000e+00 
000002: -7.0000e+00 
1.1755e-38 
9223372036854775807

The max_val is 1.1755e-38 and max_idx is 9223372036854775807 which make no sense.

Expected behavior
The max_val should be -1 and max_idx should be 1.

System details (please complete the following information):

  • OS: Ubuntu 20.04
  • CUDA version: CUDA 11.4
  • g++ version: 9.3.0
@cliffburdick
Copy link
Collaborator

Hi @ZJUGuoShuai this has been fixed. Sorry for the delay.

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

Successfully merging a pull request may close this issue.

2 participants