-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Numpy std var large tensor fix #19324
Numpy std var large tensor fix #19324
Conversation
|
Hey @Zha0q1 , Thanks for submitting the PR
CI supported jobs: [unix-cpu, windows-cpu, windows-gpu, sanity, centos-cpu, edge, centos-gpu, clang, unix-gpu, website, miscellaneous] Note: |
|
local run: |
| MSHADOW_XINLINE static void Map(index_t i, | ||
| DType *out, | ||
| const DType *data, | ||
| const DType *mean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change index variables inside the kernel to index_t from size_t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
| assert inp.grad[-1, 0] == 5 and inp.grad[-1, 1] == -4 and inp.grad[-1, 2] == -1 | ||
|
|
||
|
|
||
| @use_np |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, added it back
| with mx.autograd.record(): | ||
| out = np.std(inp, axis=1) | ||
| out.backward() | ||
| assert out.shape == (2, ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we directly comapre the outputs with actual numpy's operators ? call import numpy as _np
Then we probably don't have to worry about correctness of the formula used? @Zha0q1 wdyt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that first but it would take too long to run on large tensors so I instead derived a analytical formula. The correctness has been verified with small tensor size first then I switched to large tenosr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Resolve merge conflicts
This PR fixes std and var against large tensors