Skip to content

Commit f43849a

Browse files
committed
Auto-generated commit
1 parent 930a2d5 commit f43849a

8 files changed

Lines changed: 73 additions & 3 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+
- [`4d0ce60`](https://github.com/stdlib-js/stdlib/commit/4d0ce60011997633aac407dbba435da1763a2550) - add float16 dtype support to `array/convert-same` [(#14126)](https://github.com/stdlib-js/stdlib/pull/14126)
1314
- [`823ccaa`](https://github.com/stdlib-js/stdlib/commit/823ccaae2a34ef2fc8d0795f885b0503394ddae8) - add float16 dtype support to `array/convert` [(#14125)](https://github.com/stdlib-js/stdlib/pull/14125)
1415
- [`f95a2e1`](https://github.com/stdlib-js/stdlib/commit/f95a2e1e1f7fb5bd69f9d403cc8f9b40a7b1defb) - add float16 dtype support to `array/nans` [(#14127)](https://github.com/stdlib-js/stdlib/pull/14127)
1516
- [`28c1b87`](https://github.com/stdlib-js/stdlib/commit/28c1b877001ac4db853b9a958d9ec33bd1bd8288) - add float16 dtype support to `array/one-to-like` [(#14148)](https://github.com/stdlib-js/stdlib/pull/14148)
@@ -85,6 +86,7 @@ This release closes the following issue:
8586

8687
<details>
8788

89+
- [`4d0ce60`](https://github.com/stdlib-js/stdlib/commit/4d0ce60011997633aac407dbba435da1763a2550) - **feat:** add float16 dtype support to `array/convert-same` [(#14126)](https://github.com/stdlib-js/stdlib/pull/14126) _(by Gururaj Gurram)_
8890
- [`823ccaa`](https://github.com/stdlib-js/stdlib/commit/823ccaae2a34ef2fc8d0795f885b0503394ddae8) - **feat:** add float16 dtype support to `array/convert` [(#14125)](https://github.com/stdlib-js/stdlib/pull/14125) _(by Gururaj Gurram)_
8991
- [`f95a2e1`](https://github.com/stdlib-js/stdlib/commit/f95a2e1e1f7fb5bd69f9d403cc8f9b40a7b1defb) - **feat:** add float16 dtype support to `array/nans` [(#14127)](https://github.com/stdlib-js/stdlib/pull/14127) _(by Gururaj Gurram, Athan Reines)_
9092
- [`28c1b87`](https://github.com/stdlib-js/stdlib/commit/28c1b877001ac4db853b9a958d9ec33bd1bd8288) - **feat:** add float16 dtype support to `array/one-to-like` [(#14148)](https://github.com/stdlib-js/stdlib/pull/14148) _(by Gururaj Gurram)_

convert-same/benchmark/benchmark.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var bench = require( '@stdlib/bench' );
2424
var isCollection = require( '@stdlib/assert/is-collection' );
2525
var Float64Array = require( './../../float64' );
2626
var Float32Array = require( './../../float32' );
27+
var Float16Array = require( './../../float16' );
2728
var Int32Array = require( './../../int32' );
2829
var Int16Array = require( './../../int16' );
2930
var Int8Array = require( './../../int8' );
@@ -122,6 +123,34 @@ bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) {
122123
b.end();
123124
});
124125

126+
bench( format( '%s:dtype=float16', pkg ), function benchmark( b ) {
127+
var arr;
128+
var out;
129+
var v;
130+
var i;
131+
132+
arr = [];
133+
for ( i = 0; i < 10; i++ ) {
134+
arr.push( i );
135+
}
136+
v = new Float16Array( 0 );
137+
138+
b.tic();
139+
for ( i = 0; i < b.iterations; i++ ) {
140+
arr[ 0 ] += 1;
141+
out = convertArraySame( arr, v );
142+
if ( out.length !== arr.length ) {
143+
b.fail( 'should have expected length' );
144+
}
145+
}
146+
b.toc();
147+
if ( !isCollection( out ) ) {
148+
b.fail( 'should return an array-like object' );
149+
}
150+
b.pass( 'benchmark finished' );
151+
b.end();
152+
});
153+
125154
bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) {
126155
var arr;
127156
var out;

convert-same/benchmark/benchmark.length.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var pow = require( '@stdlib/math/base/special/pow' );
2525
var isCollection = require( '@stdlib/assert/is-collection' );
2626
var Float64Array = require( './../../float64' );
2727
var Float32Array = require( './../../float32' );
28+
var Float16Array = require( './../../float16' );
2829
var Int32Array = require( './../../int32' );
2930
var Int16Array = require( './../../int16' );
3031
var Int8Array = require( './../../int8' );
@@ -116,6 +117,9 @@ function main() {
116117
f = createBenchmark( len, new Float32Array( 0 ) );
117118
bench( format( '%s:len=%d,dtype=float32', pkg, len ), f );
118119

120+
f = createBenchmark( len, new Float16Array( 0 ) );
121+
bench( format( '%s:len=%d,dtype=float16', pkg, len ), f );
122+
119123
f = createBenchmark( len, new Int32Array( 0 ) );
120124
bench( format( '%s:len=%d,dtype=int32', pkg, len ), f );
121125

convert-same/benchmark/julia/benchmark.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ function main()
169169
dtypes = [
170170
Float64,
171171
Float32,
172+
Float16,
172173
Int32,
173174
Int16,
174175
Int8,

convert-same/benchmark/python/numpy/benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def main():
107107
dtypes = [
108108
"float64",
109109
"float32",
110+
"float16",
110111
"int32",
111112
"int16",
112113
"int8",
@@ -120,8 +121,7 @@ def main():
120121
n = 1
121122
while n < 1e7:
122123
n *= 10
123-
for i in range(0, len(dtypes)):
124-
dtype = dtypes[i]
124+
for dtype in dtypes:
125125
name = ":len="+str(n)+",dtype="+dtype
126126
setup = "import numpy as np;"
127127
setup += "A = np.ones([1,"+str(n)+"], dtype='float64');"

convert-same/docs/types/index.d.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

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

23-
import { AnyArray, Collection, Complex128Array, Complex64Array, BooleanArray } from '@stdlib/types/array';
23+
import { AnyArray, Collection, Float16Array, Complex128Array, Complex64Array, BooleanArray } from '@stdlib/types/array';
2424

2525
/**
2626
* Converts an array to a `Float64Array`.
@@ -58,6 +58,24 @@ declare function convertSame( x: Collection, y: Float64Array ): Float64Array;
5858
*/
5959
declare function convertSame( x: Collection, y: Float32Array ): Float32Array;
6060

61+
/**
62+
* Converts an array to a `Float16Array`.
63+
*
64+
* @param x - array to convert
65+
* @param y - array having the desired output data type
66+
* @returns output array
67+
*
68+
* @example
69+
* var Float16Array = require( '@stdlib/array/float16' );
70+
*
71+
* var x = [ 1.0, 2.0, 3.0, 4.0 ];
72+
* var y = new Float16Array( 0 );
73+
*
74+
* var out = convertSame( x, y );
75+
* // returns <Float16Array>[ 1.0, 2.0, 3.0, 4.0 ]
76+
*/
77+
declare function convertSame( x: Collection, y: Float16Array ): Float16Array;
78+
6179
/**
6280
* Converts an array to an `Int32Array`.
6381
*

convert-same/docs/types/test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19+
import Float16Array = require( './../../../float16' );
1920
import Complex128Array = require( './../../../complex128' );
2021
import Complex64Array = require( './../../../complex64' );
2122
import BooleanArray = require( './../../../bool' );
@@ -28,6 +29,7 @@ import convertSame = require( './index' );
2829
{
2930
convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Float64Array( 0 ) ); // $ExpectType Float64Array
3031
convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Float32Array( 0 ) ); // $ExpectType Float32Array
32+
convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Float16Array( 0 ) ); // $ExpectType Float16ArrayFallback
3133
convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Int32Array( 0 ) ); // $ExpectType Int32Array
3234
convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Int16Array( 0 ) ); // $ExpectType Int16Array
3335
convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Int8Array( 0 ) ); // $ExpectType Int8Array

convert-same/test/test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var tape = require( 'tape' );
2626
var dtype = require( './../../dtype' );
2727
var Float64Array = require( './../../float64' );
2828
var Float32Array = require( './../../float32' );
29+
var Float16Array = require( './../../float16' );
2930
var Int16Array = require( './../../int16' );
3031
var Int32Array = require( './../../int32' );
3132
var Int8Array = require( './../../int8' );
@@ -39,6 +40,7 @@ var BooleanArray = require( './../../bool' );
3940
var isArray = require( '@stdlib/assert/is-array' );
4041
var isFloat64Array = require( '@stdlib/assert/is-float64array' );
4142
var isFloat32Array = require( '@stdlib/assert/is-float32array' );
43+
var isFloat16Array = require( '@stdlib/assert/is-float16array' );
4244
var isInt16Array = require( '@stdlib/assert/is-int16array' );
4345
var isInt32Array = require( '@stdlib/assert/is-int32array' );
4446
var isInt8Array = require( '@stdlib/assert/is-int8array' );
@@ -156,6 +158,7 @@ tape( 'the function converts an array to the same data type as a second input ar
156158
y = [
157159
new Float64Array( 0 ),
158160
new Float32Array( 0 ),
161+
new Float16Array( 0 ),
159162
[],
160163
new Int16Array( 0 ),
161164
new Int32Array( 0 ),
@@ -169,6 +172,7 @@ tape( 'the function converts an array to the same data type as a second input ar
169172
expected = [
170173
[ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ],
171174
[ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ],
175+
[ new Float16Array( [ -1.0, 0.0, 1.0 ] ), isFloat16Array ],
172176
[ x, isArray ],
173177
[ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ],
174178
[ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ],
@@ -201,6 +205,7 @@ tape( 'the function converts an array to the same data type as a second input ar
201205
y = [
202206
new Float64Array( 0 ),
203207
new Float32Array( 0 ),
208+
new Float16Array( 0 ),
204209
[],
205210
new Int16Array( 0 ),
206211
new Int32Array( 0 ),
@@ -219,6 +224,7 @@ tape( 'the function converts an array to the same data type as a second input ar
219224
expected = [
220225
[ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ],
221226
[ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ],
227+
[ new Float16Array( [ -1.0, 0.0, 1.0 ] ), isFloat16Array ],
222228
[ [ -1, 0, 1 ], isArray ],
223229
[ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ],
224230
[ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ],
@@ -354,6 +360,7 @@ tape( 'the function converts an array to the same data type as a second input ar
354360
y = [
355361
new Float64Array( 0 ),
356362
new Float32Array( 0 ),
363+
new Float16Array( 0 ),
357364
new Int16Array( 0 ),
358365
new Int32Array( 0 ),
359366
new Int8Array( 0 ),
@@ -366,6 +373,7 @@ tape( 'the function converts an array to the same data type as a second input ar
366373
expected = [
367374
[ new Float64Array( [ 1.0, 0.0, 1.0 ] ), isFloat64Array ],
368375
[ new Float32Array( [ 1.0, 0.0, 1.0 ] ), isFloat32Array ],
376+
[ new Float16Array( [ 1.0, 0.0, 1.0 ] ), isFloat16Array ],
369377
[ new Int16Array( [ 1, 0, 1 ] ), isInt16Array ],
370378
[ new Int32Array( [ 1, 0, 1 ] ), isInt32Array ],
371379
[ new Int8Array( [ 1, 0, 1 ] ), isInt8Array ],
@@ -505,6 +513,7 @@ tape( 'the function converts an array to the same data type as a second input ar
505513
y = [
506514
new Float64Array( 0 ),
507515
new Float32Array( 0 ),
516+
new Float16Array( 0 ),
508517
new Int16Array( 0 ),
509518
new Int32Array( 0 ),
510519
new Int8Array( 0 ),
@@ -517,6 +526,7 @@ tape( 'the function converts an array to the same data type as a second input ar
517526
expected = [
518527
[ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ],
519528
[ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ],
529+
[ new Float16Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat16Array ],
520530
[ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ],
521531
[ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ],
522532
[ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ],
@@ -548,6 +558,7 @@ tape( 'the function converts an array to the same data type as a second input ar
548558
y = [
549559
new Float64Array( 0 ),
550560
new Float32Array( 0 ),
561+
new Float16Array( 0 ),
551562
new Int16Array( 0 ),
552563
new Int32Array( 0 ),
553564
new Int8Array( 0 ),
@@ -560,6 +571,7 @@ tape( 'the function converts an array to the same data type as a second input ar
560571
expected = [
561572
[ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ],
562573
[ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ],
574+
[ new Float16Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat16Array ],
563575
[ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ],
564576
[ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ],
565577
[ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ],
@@ -712,6 +724,7 @@ tape( 'the function converts an array to the same data type as a second input ar
712724
y = [
713725
new Float64Array( 0 ),
714726
new Float32Array( 0 ),
727+
new Float16Array( 0 ),
715728
[],
716729
new Int16Array( 0 ),
717730
new Int32Array( 0 ),
@@ -731,6 +744,7 @@ tape( 'the function converts an array to the same data type as a second input ar
731744
expected = [
732745
isFloat64Array,
733746
isFloat32Array,
747+
isFloat16Array,
734748
isArray,
735749
isInt16Array,
736750
isInt32Array,

0 commit comments

Comments
 (0)