Skip to content

Commit 32db83c

Browse files
committed
Auto-generated commit
1 parent bbab609 commit 32db83c

5 files changed

Lines changed: 66 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- [`ce01d62`](https://github.com/stdlib-js/stdlib/commit/ce01d62f42a0f04f16f413f93dea56794a601211) - add float16 dtype support to `ndarray/base/from-array` [(#15742)](https://github.com/stdlib-js/stdlib/pull/15742)
1314
- [`745b7b2`](https://github.com/stdlib-js/stdlib/commit/745b7b23ad7c544eeaa33344aae3e79ba3404062) - add float16 dtype support to `ndarray/base/from-scalar` [(#15743)](https://github.com/stdlib-js/stdlib/pull/15743)
1415
- [`2e4d8af`](https://github.com/stdlib-js/stdlib/commit/2e4d8af6edb78e37812c0f124cb0fda43cee720f) - add float16 dtype support to `ndarray/slice-from` [(#15744)](https://github.com/stdlib-js/stdlib/pull/15744)
1516
- [`682a1f9`](https://github.com/stdlib-js/stdlib/commit/682a1f9c78b6af207258e6211089f76ceb3e8e44) - add float16 dtype support to `ndarray/slice-to` [(#15747)](https://github.com/stdlib-js/stdlib/pull/15747)
@@ -139,6 +140,7 @@ A total of 4 issues were closed in this release:
139140

140141
<details>
141142

143+
- [`ce01d62`](https://github.com/stdlib-js/stdlib/commit/ce01d62f42a0f04f16f413f93dea56794a601211) - **feat:** add float16 dtype support to `ndarray/base/from-array` [(#15742)](https://github.com/stdlib-js/stdlib/pull/15742) _(by Samarth Kolarkar)_
142144
- [`745b7b2`](https://github.com/stdlib-js/stdlib/commit/745b7b23ad7c544eeaa33344aae3e79ba3404062) - **feat:** add float16 dtype support to `ndarray/base/from-scalar` [(#15743)](https://github.com/stdlib-js/stdlib/pull/15743) _(by Samarth Kolarkar)_
143145
- [`2e4d8af`](https://github.com/stdlib-js/stdlib/commit/2e4d8af6edb78e37812c0f124cb0fda43cee720f) - **feat:** add float16 dtype support to `ndarray/slice-from` [(#15744)](https://github.com/stdlib-js/stdlib/pull/15744) _(by Samarth Kolarkar)_
144146
- [`682a1f9`](https://github.com/stdlib-js/stdlib/commit/682a1f9c78b6af207258e6211089f76ceb3e8e44) - **feat:** add float16 dtype support to `ndarray/slice-to` [(#15747)](https://github.com/stdlib-js/stdlib/pull/15747) _(by Samarth Kolarkar)_

‎base/from-array/benchmark/benchmark.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,28 @@ bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) {
7575
b.end();
7676
});
7777

78+
bench( format( '%s:dtype=float16', pkg ), function benchmark( b ) {
79+
var buf;
80+
var x;
81+
var i;
82+
83+
buf = typedarray( 1, 'float16' );
84+
85+
b.tic();
86+
for ( i = 0; i < b.iterations; i++ ) {
87+
x = array2ndarray( buf, 'row-major' );
88+
if ( x.length !== 1 ) {
89+
b.fail( 'should have length 1' );
90+
}
91+
}
92+
b.toc();
93+
if ( !isndarrayLike( x ) ) {
94+
b.fail( 'should return an ndarray' );
95+
}
96+
b.pass( 'benchmark finished' );
97+
b.end();
98+
});
99+
78100
bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) {
79101
var buf;
80102
var x;

‎base/from-array/docs/types/index.d.ts‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { Collection, AccessorArrayLike, Complex128Array, Complex64Array, BooleanArray } from '@stdlib/types/array';
24-
import { float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, boolndarray, genericndarray, Order } from '@stdlib/types/ndarray';
23+
import { Collection, AccessorArrayLike, Complex128Array, Complex64Array, BooleanArray, Float16Array } from '@stdlib/types/array';
24+
import { float64ndarray, float32ndarray, float16ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, boolndarray, genericndarray, Order } from '@stdlib/types/ndarray';
2525

2626
/**
2727
* Converts an array to a one-dimensional ndarray.
@@ -65,6 +65,27 @@ declare function array2ndarray( buf: Float64Array, order: Order ): float64ndarra
6565
*/
6666
declare function array2ndarray( buf: Float32Array, order: Order ): float32ndarray;
6767

68+
/**
69+
* Converts an array to a one-dimensional ndarray.
70+
*
71+
* @param buf - input array
72+
* @param order - memory layout (row-major or column-major)
73+
* @returns one-dimensional ndarray
74+
*
75+
* @example
76+
* var getDType = require( '@stdlib/ndarray/dtype' );
77+
* var Float16Array = require( '@stdlib/array/float16' );
78+
*
79+
* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );
80+
*
81+
* var x = array2ndarray( arr, 'row-major' );
82+
* // returns <ndarray>
83+
*
84+
* var dt = String( getDType( x ) );
85+
* // returns 'float16'
86+
*/
87+
declare function array2ndarray( buf: Float16Array, order: Order ): float16ndarray;
88+
6889
/**
6990
* Converts an array to a one-dimensional ndarray.
7091
*

‎base/from-array/docs/types/test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import array2ndarray = require( './index' );
2626
{
2727
array2ndarray( zeros( 1, 'float64' ), 'row-major' ); // $ExpectType float64ndarray
2828
array2ndarray( zeros( 1, 'float32' ), 'row-major' ); // $ExpectType float32ndarray
29+
array2ndarray( zeros( 1, 'float16' ), 'row-major' ); // $ExpectType float16ndarray
2930
array2ndarray( zeros( 1, 'complex128' ), 'row-major' ); // $ExpectType complex128ndarray
3031
array2ndarray( zeros( 1, 'complex64' ), 'row-major' ); // $ExpectType complex64ndarray
3132
array2ndarray( zeros( 1, 'int32' ), 'row-major' ); // $ExpectType int32ndarray

‎base/from-array/test/test.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,24 @@ tape( 'the function returns a one-dimensional ndarray (dtype=float32)', function
7878
t.end();
7979
});
8080

81+
tape( 'the function returns a one-dimensional ndarray (dtype=float16)', function test( t ) {
82+
var buf;
83+
var arr;
84+
85+
buf = typedarray( 4, 'float16' );
86+
arr = array2ndarray( buf, 'column-major' );
87+
88+
t.strictEqual( instanceOf( arr, base ), true, 'returns expected value' );
89+
t.strictEqual( String( getDType( arr ) ), 'float16', 'returns expected value' );
90+
t.strictEqual( getData( arr ), buf, 'returns expected value' );
91+
t.deepEqual( getShape( arr ), [ buf.length ], 'returns expected value' );
92+
t.deepEqual( getStrides( arr ), [ 1 ], 'returns expected value' );
93+
t.strictEqual( getOffset( arr ), 0, 'returns expected value' );
94+
t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' );
95+
96+
t.end();
97+
});
98+
8199
tape( 'the function returns a one-dimensional ndarray (dtype=int32)', function test( t ) {
82100
var buf;
83101
var arr;

0 commit comments

Comments
 (0)