onnxruntime/js/common/lib
Yulong Wang 58f4921686
[js] changes to allow Float16Array if any polyfill is available (#19305)
### Description

This change adds only necessary code to enable ort-web works with any
Float16Array polyfill. Unlike #19302, in this PR, ort-web does not
include any specific polyfill; instead, it's user's choice for how to
use a polyfill.

ORT-web uses Float16Array if it's available; otherwise, fallback to use
Uint16Array.

```js
// case 1: user does not use polyfill:
import * as ort from 'onnxruntime-web';

const myF16Data = new Uint16Array(...);  // need to use Uint16Array
const myF16tensor = new ort.Tensor('float16', myF16Data, dims);
```

```js
// case 2: user use polyfill:
import * as ort from 'onnxruntime-web';
import {
  Float16Array, isFloat16Array, isTypedArray,
  getFloat16, setFloat16,
  f16round,
} from "@petamoriken/float16";
globalThis.Float16Array = Float16Array;  // ort-web will pick the global Float16Array

const myF16Data = new Float16Array(...);  // Use the polyfilled Float16Array type
const myF16tensor = new ort.Tensor('float16', myF16Data, dims);
```
2024-02-21 00:31:06 -08:00
..
backend-impl.ts [js/web] revise backend registration (#18715) 2023-12-20 14:45:55 -08:00
backend.ts [js/web] revise backend registration (#18715) 2023-12-20 14:45:55 -08:00
env-impl.ts
env.ts [js/webgpu] Refactor timestamp-query and introduce timestamp-query-inside-passes (#18894) 2024-01-13 00:23:17 -08:00
index.ts [js/webgpu] Introduce trace support (#18928) 2024-01-03 10:13:17 -08:00
inference-session-impl.ts [js/webgpu] Introduce trace support (#18928) 2024-01-03 10:13:17 -08:00
inference-session.ts [js/webgpu] Support capture and replay for jsep (#18989) 2024-01-30 18:28:03 -08:00
onnx-model.ts [js] enable external data loading for ort-web (#19087) 2024-01-12 19:24:24 -08:00
onnx-value.ts [js/api] introducing IO binding for tensor (#16452) 2023-08-29 12:58:26 -07:00
tensor-conversion-impl.ts [js] using OffscreenCanvas when DOM is not available (#19033) 2024-01-12 13:54:05 -08:00
tensor-conversion.ts
tensor-factory-impl.ts [js] using OffscreenCanvas when DOM is not available (#19033) 2024-01-12 13:54:05 -08:00
tensor-factory.ts [js/common] prepare work for supporting webgpu IO binding implementation (#17465) 2023-09-08 13:49:24 -07:00
tensor-impl-type-mapping.ts [js] changes to allow Float16Array if any polyfill is available (#19305) 2024-02-21 00:31:06 -08:00
tensor-impl.ts [js] changes to allow Float16Array if any polyfill is available (#19305) 2024-02-21 00:31:06 -08:00
tensor-utils-impl.ts [js/api] introducing IO binding for tensor (#16452) 2023-08-29 12:58:26 -07:00
tensor-utils.ts
tensor.ts [js/webgpu] allow uint8 tensors for webgpu (#19545) 2024-02-16 18:28:27 -08:00
trace.ts [js/webgpu] Introduce trace support (#18928) 2024-01-03 10:13:17 -08:00
training-session-impl.ts [js/web/training] lazyResetGrad implementation (#18711) 2023-12-11 17:36:54 -08:00
training-session.ts [js/web/training] lazyResetGrad implementation (#18711) 2023-12-11 17:36:54 -08:00
version.ts [ORT 1.17.0 release] Bump up version to 1.18.0 (#19170) 2024-01-17 11:18:32 -08:00