Repository navigation
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
The native wrapper now converts |
| var endpoint = arrays[ 4 ]; | ||
| var base = arrays[ 1 ]; | ||
| var strt = arrays[ 2 ]; | ||
| var buf = getData( endpoint ); | ||
| var stp = arrays[ 3 ]; | ||
| var x = arrays[ 0 ]; | ||
|
|
||
| if ( getDType( base ) !== 'float32' ) { | ||
| base = scalar2ndarray( ndarraylike2scalar( base ), { | ||
| 'dtype': 'float32' | ||
| }); | ||
| } | ||
| addon( getData( x ), serialize( x ), getData( base ), serialize( base ), getData( strt ), serialize( strt ), getData( stp ), serialize( stp ), new Uint8Array( buf.buffer, buf.byteOffset, buf.length ), serialize( endpoint ) ); // eslint-disable-line max-len |
There was a problem hiding this comment.
No dtype conversion here. Like k in ztril, the scalar ndarrays should already be float32 (as in the docs), and the boolean buffer can go through reinterpret-boolean.
| var endpoint = arrays[ 4 ]; | |
| var base = arrays[ 1 ]; | |
| var strt = arrays[ 2 ]; | |
| var buf = getData( endpoint ); | |
| var stp = arrays[ 3 ]; | |
| var x = arrays[ 0 ]; | |
| if ( getDType( base ) !== 'float32' ) { | |
| base = scalar2ndarray( ndarraylike2scalar( base ), { | |
| 'dtype': 'float32' | |
| }); | |
| } | |
| addon( getData( x ), serialize( x ), getData( base ), serialize( base ), getData( strt ), serialize( strt ), getData( stp ), serialize( stp ), new Uint8Array( buf.buffer, buf.byteOffset, buf.length ), serialize( endpoint ) ); // eslint-disable-line max-len | |
| var endpoint = arrays[ 4 ]; | |
| var base = arrays[ 1 ]; | |
| var strt = arrays[ 2 ]; | |
| var stp = arrays[ 3 ]; | |
| var x = arrays[ 0 ]; | |
| addon( getData( x ), serialize( x ), getData( base ), serialize( base ), getData( strt ), serialize( strt ), getData( stp ), serialize( stp ), reinterpret( getData( endpoint ), 0 ), serialize( endpoint ) ); // eslint-disable-line max-len |
There was a problem hiding this comment.
I’m concerned removing the conversion will bring back the failure in this CI run(https://github.com/stdlib-js/stdlib/actions/runs/39103254507/job/117603674460#step:9:220): logspace passes a float64 base with float32 output, and native slogspace returned [1, 0, 0] instead of [1, 10, 100]. Where would you prefer that conversion to happen?
There was a problem hiding this comment.
Good catch, and thanks for the link. The root cause is in blas/ext/logspace: it intentionally keeps base in its own dtype (a number primitive becomes a float64 0-d ndarray, to avoid casting the base to complex for complex outputs), while start/stop are cast to the output dtype, and the dispatcher doesn't cast additional ndarray arguments. So with a float32 output the kernel receives a float64 base, and stdlib_ndarray_get_float32 in main.c misreads it. That's why only base was wrong.
The JS main.js is dtype-agnostic (ndarraylike2scalar), but the C getters are not, so the real question is which layer should guarantee the kernel's float32 contract. Converting in native.js works, but no merged native.js does this, and a generic endpoint (also allowed by blas/ext/logspace) would still crash the add-on. @kgryte, would you prefer blas/ext/logspace to cast a real base to the output dtype (for real outputs), or should the kernels handle mixed scalar dtypes? Until then the current conversion is fine with me.
|
Left a few suggestions; |
|
Updated boolean buffer handling to use reinterpret-boolean and synced the tests with develop. Waiting for @kgryte’s guidance on dtype conversion. |
Related to #14819.
Description
This pull request:
blas/ext/base/ndarray/slogspaceusing theexisting strided C routine.
Related Issues
This pull request has the following related issues:
blas/ext/base/ndarraypackages #14819Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
The AI is used for generating the documentation , all the changes are carefully reviewed before push
@stdlib-js/reviewers