Skip to content

[tmva][sofie] Fix big endian#22723

Merged
guitargeek merged 2 commits into
root-project:masterfrom
ellert:sofie-big-endian
Jul 8, 2026
Merged

[tmva][sofie] Fix big endian#22723
guitargeek merged 2 commits into
root-project:masterfrom
ellert:sofie-big-endian

Conversation

@ellert

@ellert ellert commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

This Pull request:

Changes or fixes:

This PR fixes rhe big endian code path.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #

@ellert ellert requested a review from lmoneta as a code owner June 28, 2026 16:45
@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 17h 33m 20s ⏱️
 3 873 tests  3 824 ✅   0 💤 49 ❌
79 415 runs  79 091 ✅ 275 💤 49 ❌

For more details on these failures, see this check.

Results for commit 8554bf4.

♻️ This comment has been updated with latest results.

ellert and others added 2 commits July 8, 2026 11:12
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

@guitargeek guitargeek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! I have added one more commit to complete the big endian support.

@guitargeek guitargeek merged commit 2fec582 into root-project:master Jul 8, 2026
31 checks passed
@ellert ellert deleted the sofie-big-endian branch July 8, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants