Skip to content

perf: optimize f32_vec_to_bytes and bytes_to_f32_vec#12618

Merged
alexcrichton merged 1 commit intobytecodealliance:mainfrom
VolodymyrBg:fix/onnx-optimize-byte-conversion
Feb 18, 2026
Merged

perf: optimize f32_vec_to_bytes and bytes_to_f32_vec#12618
alexcrichton merged 1 commit intobytecodealliance:mainfrom
VolodymyrBg:fix/onnx-optimize-byte-conversion

Conversation

@VolodymyrBg
Copy link
Contributor

The functions created unnecessary intermediate Vec allocations - f32_vec_to_bytes allocated a Vec<[u8; 4]> then flattened it, and bytes_to_f32_vec had triple allocation with double collect.
Replaced with single-pass flat_map and simplified map with single collect, matching the pattern already used in winml.rs.

@alexcrichton alexcrichton added this pull request to the merge queue Feb 18, 2026
Merged via the queue into bytecodealliance:main with commit ec39df2 Feb 18, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments