Repository navigation
Return a finite value for single-element windows, linspace and logspace - #1252
Conversation
|
|
/build |
|
Thanks for the PR @Arthur031221! Since this adds conditionals in the data path is there possibly a better way to do this where if we detect the size is 1 we can return something that always generates the same value instead of checking? |
…T windows A one-point logspace still divided (last - first) by one, so an endpoint difference that overflows gave an infinite step and NaN at index zero. Use a zero step when count is one. The one-point early return added to bartlett was typed T while the general expression was not, so bartlett with a half or bfloat16 generator type stopped compiling. Convert the general expression to T. Add a one-point window test for the JIT executor and build the one-point bartlett test with the output type.
|
On the branch in the data path: I timed each generator with 2^26 float elements on an RTX 5090 (best of 7 runs of 200 launches each, two process runs per tree). On the review bot findings, I pushed a follow-up commit that covers the three findings, with one difference noted below. A one-point Passing the output type to the window generators found a regression in my earlier commit: I also added a one-point JIT test for the five windows. With an empty kernel cache, |
Sounds good. I think there's one more legitimate bot comment. |
|
You're right about the remaining type coverage finding. The singleton test now instantiates The |
Any caller that passes a window size or sweep count of 1, for example
hamming<0>({1})orlinspace(2.0f, 5.0f, 1), gets NaN instead of a value, because the generators divide bysize - 1orcount - 1, which is 0.On the base commit, these assign NaN to a one-element float tensor:
hanning,hamming,bartlett,blackmanandflattopof size 1linspaceandlogspacewith a count of 1After this change a one-point window is 1, and a one-point linspace or logspace is the start value (
10^firstfor logspace), as withnumpy.hanning(1)andnumpy.linspace(2, 5, 1).The fix returns 1 early in the five window generators when the size is 1, including the JIT source strings, and keeps the step finite in
linspaceandlogspacewhen the count is 1. Sizes and counts above 1 take the same code path as before.Tests added in
test/00_operators/GeneratorTests.cu:SingleElementWindows(half, bfloat16, float, double) andSingleElementLinspaceLogspace. I compiled these two tests on their own, outside the CMake test target, against the base headers, where all 5 test instances fail with NaN, and against this change, where all 5 pass. I did not run the rest of the suite or the existingWindowstest (it needs pybind11).I did not build with
MATX_EN_JIT. Instead I extracted the five edited JIT source strings from the headers, compiled them with nvcc as device operators and ran them: size 1 gives 1.0 for every window, and size 5 gives the expected symmetric window, for example0.08 0.54 1.0 0.54 0.08for Hamming.