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

print on diag operator appears broken [BUG] #550

Closed
luitjens opened this issue Jan 8, 2024 · 3 comments · Fixed by #598
Closed

print on diag operator appears broken [BUG] #550

luitjens opened this issue Jan 8, 2024 · 3 comments · Fixed by #598

Comments

@luitjens
Copy link
Collaborator

luitjens commented Jan 8, 2024

Here is a trivial reproducer:

`
#include "matx.h"
#include
#include
#include <math.h>

using namespace matx;

int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
{
MATX_ENTER_HANDLER();
auto A = matx::make_tensor({4,4});

A.SetVals({ {0,1,2,3},{4,5,6,7},{8,9,10,11},{12,13,14,15}});
cudaDeviceSynchronize();

printf("A:\n"); print(A);
printf("diag A:\n"); print(diag(A));
printf("sqrt diag A:\n"); print(sqrt(diag(A)));

CUDA_CHECK_LAST_ERROR();
MATX_EXIT_HANDLER();
}`

output:
A: Tensor{float} Rank: 2, Sizes:[4, 4], Strides:[4,1] 000000: 0.0000e+00 1.0000e+00 2.0000e+00 3.0000e+00 000001: 4.0000e+00 5.0000e+00 6.0000e+00 7.0000e+00 000002: 8.0000e+00 9.0000e+00 1.0000e+01 1.1000e+01 000003: 1.2000e+01 1.3000e+01 1.4000e+01 1.5000e+01 diag A: Operator{float} Rank: 1, Sizes:[4] 000000: 0.0000e+00 000001: 0.0000e+00 000002: 0.0000e+00 000003: 0.0000e+00 sqrt diag A: Operator{float} Rank: 1, Sizes:[4] 000000: 0.0000e+00 000001: 2.2361e+00 000002: 3.1623e+00 000003: 3.8730e+00

Notice the diag output is all zeros. In my full use case I get the first row of A. This indicates something is going wrong to me. Note that once you wrap diag in a square root you get the right values printed. In my real use case the device side has the right answers but the prints that I was debugging were wrong.

@luitjens
Copy link
Collaborator Author

luitjens commented Jan 9, 2024

@cliffburdick reverting this commit fixes the issue: 59bcbb7

We will need to debug why that patch doesn't fully work for the diag operator.

@luitjens
Copy link
Collaborator Author

luitjens commented Jan 9, 2024

Fixed in #552

@cliffburdick
Copy link
Collaborator

I copied that code from another place we print. Will take a look at it when back

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