From d14941d5e0f177b3b5b5bc8721944c0373c51583 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 18 May 2026 11:35:08 +0530 Subject: [PATCH 1/4] test: add alpha & beta tests for blas/base/sgemm --- .../ra_rb_rc_nta_ntb_alpha2_beta3.json | 22 ++++++++++++++++++ .../row_major_nta_ntb_alpha2_beta3.json | 17 ++++++++++++++ .../blas/base/sgemm/test/test.ndarray.js | 23 +++++++++++++++++++ .../blas/base/sgemm/test/test.sgemm.js | 23 +++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/sgemm/test/fixtures/ra_rb_rc_nta_ntb_alpha2_beta3.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgemm/test/fixtures/row_major_nta_ntb_alpha2_beta3.json diff --git a/lib/node_modules/@stdlib/blas/base/sgemm/test/fixtures/ra_rb_rc_nta_ntb_alpha2_beta3.json b/lib/node_modules/@stdlib/blas/base/sgemm/test/fixtures/ra_rb_rc_nta_ntb_alpha2_beta3.json new file mode 100644 index 000000000000..020e31958562 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemm/test/fixtures/ra_rb_rc_nta_ntb_alpha2_beta3.json @@ -0,0 +1,22 @@ +{ + "transA": "no-transpose", + "transB": "no-transpose", + "M": 2, + "N": 4, + "K": 3, + "alpha": 2.0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "B": [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ], + "strideB1": 4, + "strideB2": 1, + "offsetB": 0, + "beta": 3.0, + "C": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], + "strideC1": 4, + "strideC2": 1, + "offsetC": 0, + "C_out": [ 15.0, 18.0, 21.0, 24.0, 45.0, 48.0, 51.0, 54.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemm/test/fixtures/row_major_nta_ntb_alpha2_beta3.json b/lib/node_modules/@stdlib/blas/base/sgemm/test/fixtures/row_major_nta_ntb_alpha2_beta3.json new file mode 100644 index 000000000000..905d5b8470d1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemm/test/fixtures/row_major_nta_ntb_alpha2_beta3.json @@ -0,0 +1,17 @@ +{ + "order": "row-major", + "transA": "no-transpose", + "transB": "no-transpose", + "M": 2, + "N": 4, + "K": 3, + "alpha": 2.0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "lda": 3, + "B": [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ], + "ldb": 4, + "beta": 3.0, + "C": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], + "ldc": 4, + "C_out": [ 15.0, 18.0, 21.0, 24.0, 45.0, 48.0, 51.0, 54.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js index 67d1ec501666..b6c34f56b23b 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js @@ -82,6 +82,7 @@ var rarbrcntantboa = require( './fixtures/ra_rb_rc_nta_ntb_oa.json' ); var rarbrcntantbob = require( './fixtures/ra_rb_rc_nta_ntb_ob.json' ); var rarbrcntantboc = require( './fixtures/ra_rb_rc_nta_ntb_oc.json' ); var cap = require( './fixtures/ra_rb_rc_nta_ntb_complex_access_pattern.json' ); +var rarbrcntantbAlpha2Beta3 = require( './fixtures/ra_rb_rc_nta_ntb_alpha2_beta3.json' ); // TESTS // @@ -1487,3 +1488,25 @@ tape( 'the function supports computation over large arrays (column-major, column t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function correctly applies both `α` and `β` scalars (row-major, row-major, row-major, no-transpose, no-transpose, α=2, β=3)', function test( t ) { + var expected; + var data; + var out; + var a; + var b; + var c; + + data = rarbrcntantbAlpha2Beta3; + + a = new Float32Array( data.A ); + b = new Float32Array( data.B ); + c = new Float32Array( data.C ); + + expected = new Float32Array( data.C_out ); + + out = sgemm( data.transA, data.transB, data.M, data.N, data.K, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, b, data.strideB1, data.strideB2, data.offsetB, data.beta, c, data.strideC1, data.strideC2, data.offsetC ); + t.strictEqual( out, c, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.sgemm.js b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.sgemm.js index f0a6162ab1d4..52bbc2c83bc1 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.sgemm.js +++ b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.sgemm.js @@ -39,6 +39,7 @@ var rntantb = require( './fixtures/row_major_nta_ntb.json' ); var rtantb = require( './fixtures/row_major_ta_ntb.json' ); var rntatb = require( './fixtures/row_major_nta_tb.json' ); var rtatb = require( './fixtures/row_major_ta_tb.json' ); +var rntantbAlpha2Beta3 = require( './fixtures/row_major_nta_ntb_alpha2_beta3.json' ); // TESTS // @@ -704,3 +705,25 @@ tape( 'if `α` is `0` and `β` is neither `0` nor `1`, the function returns the t.end(); }); + +tape( 'the function correctly applies both `α` and `β` scalars (row-major, no-transpose, no-transpose, α=2, β=3)', function test( t ) { + var expected; + var data; + var out; + var a; + var b; + var c; + + data = rntantbAlpha2Beta3; + + a = new Float32Array( data.A ); + b = new Float32Array( data.B ); + c = new Float32Array( data.C ); + + expected = new Float32Array( data.C_out ); + + out = sgemm( data.order, data.transA, data.transB, data.M, data.N, data.K, data.alpha, a, data.lda, b, data.ldb, data.beta, c, data.ldc ); + t.strictEqual( out, c, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); From 6a38525a27b83bc5a02773ec380b1ed7e3447924 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 18 May 2026 13:03:11 +0530 Subject: [PATCH 2/4] disable lint rule for test.ndarray.js --- lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js index b6c34f56b23b..f0c476c27223 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js @@ -18,6 +18,8 @@ /* eslint-disable max-len */ +/* stdlib/no-empty-lines-between-requires */ + 'use strict'; // MODULES // From fcc3beb937bdbb8986da764821d79ae14f88034a Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 18 May 2026 01:36:49 -0700 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js index f0c476c27223..e9d2c3433b81 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.ndarray.js @@ -16,9 +16,7 @@ * limitations under the License. */ -/* eslint-disable max-len */ - -/* stdlib/no-empty-lines-between-requires */ +/* eslint-disable max-len, stdlib/no-empty-lines-between-requires */ 'use strict'; From 585ed7bd7549573ba34c08047d069e702bfde2f2 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 18 May 2026 01:37:50 -0700 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/sgemm/test/test.sgemm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.sgemm.js b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.sgemm.js index 52bbc2c83bc1..236e0d63dbfd 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemm/test/test.sgemm.js +++ b/lib/node_modules/@stdlib/blas/base/sgemm/test/test.sgemm.js @@ -16,7 +16,7 @@ * limitations under the License. */ -/* eslint-disable max-len */ +/* eslint-disable max-len, stdlib/no-empty-lines-between-requires */ 'use strict';