-
-
Notifications
You must be signed in to change notification settings - Fork 815
refactor: update blas/ext/base/sdssum
to follow current project conventions
#1727
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
Conversation
…t project convention
@Planeshifter Please review my PR? |
for ( i = 0; i < x.length; i++ ) { | ||
x[ i ] = ( randu()*10.0 ) - 20.0; | ||
} | ||
var x = filledarrayBy( len, 'float64', rand ); |
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.
This is incorrect. The dtype should be float32
here and everywhere else in this PR.
lib/node_modules/@stdlib/blas/ext/base/sdssum/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
@@ -36,7 +37,7 @@ var sdssum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); | |||
var opts = { | |||
'skip': ( sdssum instanceof Error ) | |||
}; | |||
|
|||
var rand = uniform( -100.0, 100.0 ); |
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.
var rand = uniform( -100.0, 100.0 ); | |
var rand = uniform( -100.0, 100.0 ); | |
var y = sdssum( x.length, x, 1 ); | ||
console.log( y ); |
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.
var y = sdssum( x.length, x, 1 ); | |
console.log( y ); | |
var v = sdssum( x.length, x, 1 ); | |
console.log( v ); | |
No need to change the variable name here.
offset = minViewBufferIndex( N, stride, offset ); | ||
if ( stride < 0 ) { | ||
offset += (N-1) * stride; | ||
} | ||
view = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len | ||
view = offsetView( x, offset ); |
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.
This is the relevant file you want to emulate: https://github.com/stdlib-js/stdlib/blob/58c9a5053430b55c974e9ecccfc45c51c3fefc9e/lib/node_modules/%40stdlib/blas/base/sasum/lib/ndarray.native.js
@@ -1,5 +1,9 @@ | |||
{ | |||
"options": {}, | |||
"options": { |
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.
Please convert this file to 2-space indentation.
"@stdlib/napi/export", | ||
"@stdlib/napi/argv", | ||
"@stdlib/napi/argv-int64", | ||
"@stdlib/napi/argv-strided-float64array" |
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.
This is incorrect. The input array should be a float32 array.
] | ||
} | ||
] | ||
} | ||
} |
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.
Trailing newline. Please ensure you have installed EditorConfig, as mentioned in the development guide.
STDLIB_NAPI_ARGV(env, info, argv, argc, 3); | ||
STDLIB_NAPI_ARGV_INT64(env, N, argv, 0); | ||
STDLIB_NAPI_ARGV_INT64(env, strideX, argv, 2); | ||
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY(env, X, N, strideX, argv, 1); | ||
|
||
napi_value v; | ||
napi_status status = napi_create_double(env, c_sdssum(N, (double *)X, strideX), &v); | ||
assert(status == napi_ok); | ||
|
||
return v; |
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.
This should be TAB indentation. As mentioned above, input array should be float32, not float64. L43 should be (float *)X
.
* @param info callback data | ||
* @return Node-API value | ||
*/ | ||
static napi_value addon(napi_env env, napi_callback_info info) |
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.
Please adhere to project spacing conventions.
return v; | ||
} | ||
|
||
STDLIB_NAPI_MODULE_EXPORT_FCN(addon) |
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.
Trailing newline.
@@ -45,7 +45,7 @@ tape( 'main export is a function', opts, function test( t ) { | |||
}); | |||
|
|||
tape( 'the function has an arity of 4', opts, function test( t ) { | |||
t.strictEqual( sdssum.length, 4, 'has expected arity' ); | |||
t.strictEqual( sdssum.length, 4, 'returns expected value' ); |
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.
The changes in this file are incomplete. You should refactor to avoid the use of floor
. See reference PRs linked to in the OP.
@@ -21,7 +21,7 @@ | |||
// MODULES // | |||
|
|||
var tape = require( 'tape' ); | |||
var floor = require( '@stdlib/math/base/special/floor' ); | |||
|
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.
@@ -22,7 +22,7 @@ | |||
|
|||
var resolve = require( 'path' ).resolve; | |||
var tape = require( 'tape' ); | |||
var floor = require( '@stdlib/math/base/special/floor' ); | |||
|
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.
@@ -36,7 +36,7 @@ tape( 'main export is a function', function test( t ) { | |||
}); | |||
|
|||
tape( 'the function has an arity of 4', function test( t ) { | |||
t.strictEqual( sdssum.length, 4, 'has expected arity' ); | |||
t.strictEqual( sdssum.length, 4, 'returns expected value' ); |
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.
Refactoring is incomplete. Remove the use of floor
.
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.
Left various comments. Please pay particular attention to similar PRs and commits and match changes and conventions in those changesets as closely as possible.
blas/ext/base/sdssum
to follow current project conventions
Please also check the box in the OP indicating that you have read and understood the contribution guidelines. |
@kgryte Thanks for your review, I will implement these ass soon as possible |
@kgryte |
@@ -44,8 +44,8 @@ | |||
"dependencies": [ | |||
"@stdlib/napi/export", | |||
"@stdlib/napi/argv", | |||
"@stdlib/napi/argv-int64", | |||
"@stdlib/napi/argv-strided-float64array" | |||
"@stdlib/napi/argv-int32", |
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.
This is incorrect. Should be int64
.
@@ -19,8 +19,8 @@ | |||
#include "stdlib/blas/base/sdssum.h" | |||
#include "stdlib/napi/export.h" | |||
#include "stdlib/napi/argv.h" | |||
#include "stdlib/napi/argv_int64.h" | |||
#include "stdlib/napi/argv_strided_float64array.h" | |||
#include "stdlib/napi/argv_int32.h" |
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.
This should be int64
.
@@ -21,7 +21,7 @@ | |||
// MODULES // | |||
|
|||
var tape = require( 'tape' ); | |||
var floor = require( '@stdlib/math/base/special/floor' ); | |||
//var floor = require( '@stdlib/math/base/special/floor' ); |
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.
Don't comment out. Remove.
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var pow = require( '@stdlib/math/base/special/pow' ); | ||
var Float32Array = require( '@stdlib/array/float32' ); | ||
|
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.
for ( i = 0; i < x.length; i++ ) { | ||
x[ i ] = ( randu()*10.0 ) - 20.0; | ||
} | ||
var x = filledarrayBy( len, 'float64', rand ); |
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.
float32
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var pow = require( '@stdlib/math/base/special/pow' ); | ||
var Float32Array = require( '@stdlib/array/float32' ); | ||
|
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.
var pkg = require( './../package.json' ).name; | ||
var sdssum = require( './../lib/ndarray.js' ); | ||
|
||
|
||
|
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.
Please ensure you have your local dev environment setup, including running make init
. Your PR contains various lint errors which project automated tooling can catch, but only if you have properly set things up locally.
for ( i = 0; i < x.length; i++ ) { | ||
x[ i ] = ( randu()*10.0 ) - 20.0; | ||
} | ||
var x = filledarrayBy( len, 'float64', rand ); |
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.
float32
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var pow = require( '@stdlib/math/base/special/pow' ); | ||
var Float32Array = require( '@stdlib/array/float32' ); | ||
|
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.
for ( i = 0; i < x.length; i++ ) { | ||
x[ i ] = ( randu()*10.0 ) - 20.0; | ||
} | ||
var x = filledarrayBy( len, 'float64', rand ); |
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.
float32
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.
This PR currently has a number of issues. Please consult other packages in blas/ext/base
and try to adhere as closely as possible. For example, see https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/ext/base/ssumors. But don't just copy-paste. Consider what is appropriate to emulate and where to deviate based on the needs of sdssum
. I suggested consulting sasum
, but only for how ndarray views are handled.
@kgryte @Planeshifter |
@kgryte @Planeshifter Please see this |
Closing as this refactoring was meanwhile merged per #2080. Thanks either way for your contribution even though it didn't make it in this time! |
Resolves #1525
Description
This pull request updates
@stdlib/blas/ext/base/sdssum
to follow current project conventions.Related Issues
This pull request:
blas/ext/base/sdssum
to follow current project conventions #1525Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers