Repository navigation
feat(executorch-bindings): accept Float16Array dataPtr for fp16 tensors - #1205
Closed
msluszniak wants to merge 1 commit into
Closed
msluszniak wants to merge 1 commit into
msluszniak wants to merge 1 commit into
Conversation
…rs (#373) Add `Float16Array` to the `TensorBuffer` union so users exporting fp16 models can pass half-precision inputs ergonomically alongside `ScalarType.HALF`. `bfloat16` has no native TypedArray and is left for callers to pack into a raw `ArrayBuffer` / `Uint16Array` view.
Collaborator
|
Have you verified this works? IIRC hermes doesn't support Float16Array, so this could crash: |
Member
Author
Ok, I tested and indeed it failed. So I will close this issue with the accurate message. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
Float16Arrayto theTensorBufferunion so users running fp16-exported models can pass half-precision inputs ergonomically alongside the already-definedScalarType.HALF. The native input path atJsiConversions.halready reads the underlyingArrayBufferraw and forwards the integerscalarType, so no native changes are needed — TS 5.9 shipsFloat16Arrayinlib.esnext.float16.d.tsand the package targetsESNext.bfloat16is intentionally left out: JS has noBFloat16Array, so callers who need it can still pack the raw bytes into anArrayBuffer(or aUint16Arrayview) — this is now noted in the docs.Introduces a breaking change?
Type of change
Tested on
Testing instructions
tsc --noEmitonpackages/react-native-executorchpasses.TensorPtrwithdataPtr: new Float16Array(...)andscalarType: ScalarType.HALF; type-checks and forwards to ExecuTorch as half-precision.Screenshots
Related issues
Partially addresses #373 (fp16 only; bf16 has no JS TypedArray and is out of scope here).
Checklist
Additional notes