[tmva][sofie] Fix big endian#22723
Merged
Merged
Conversation
Test Results 23 files 23 suites 3d 17h 33m 20s ⏱️ For more details on these failures, see this check. Results for commit 8554bf4. ♻️ This comment has been updated with latest results. |
Follow-up to the last commit ("[tmva][sofie] Fix big endian"), which
byte-swapped raw_data initializers on big-endian platforms but left a
few gaps:
- Initializers with data_location == EXTERNAL were still read from the
external weights file without swapping, silently producing
byte-reversed weights on big-endian machines.
- The type switch only handled FLOAT, DOUBLE, INT32 and INT64. One-byte
types (BOOL, UINT8, INT8), which parse fine on little-endian via
plain memcpy, now threw on big-endian, and the other fixed-width
types (INT16, UINT16, UINT32, UINT64) were rejected as well.
- The swap loops dereferenced the protobuf string buffer through
reinterpret_cast'ed uint32_t*/uint64_t* pointers, which is a
misaligned access on strict-alignment targets (e.g. SPARC) since
the buffer carries no alignment guarantee.
Replace the four copy-pasted swap loops with a width-dispatched helper,
CopyLEToHost, that plain-copies 1-byte element types and byte-swaps
2/4/8-byte elements through a memcpy'd temporary (no misaligned loads,
valid for in-place use), and call it from both the raw_data and the
external-data paths.
🤖 Done with the help of AI
8554bf4 to
27dd6d4
Compare
guitargeek
approved these changes
Jul 8, 2026
guitargeek
left a comment
Contributor
There was a problem hiding this comment.
Thank you very much! I have added one more commit to complete the big endian support.
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.
This Pull request:
Changes or fixes:
This PR fixes rhe big endian code path.
Checklist:
This PR fixes #