Fix loading little-endian models on big-endian hosts #970
Open
satyamg1620 wants to merge 2 commits intoexplosion:v8.3.xfrom
Open
Fix loading little-endian models on big-endian hosts #970satyamg1620 wants to merge 2 commits intoexplosion:v8.3.xfrom
satyamg1620 wants to merge 2 commits intoexplosion:v8.3.xfrom
Conversation
…lising byte order in Ops.asarray Signed-off-by: satyamg1620 <Satyam.Gupta.3@ibm.com>
…25+ ndim>0 scalar-conversion deprecation Signed-off-by: satyamg1620 <Satyam.Gupta.3@ibm.com>
Author
|
Shouldn't this also drop the lazy load of BigEndianOps in compat.py? |
Author
I think the lazy load isn't in compat.py, it's in thinc/backends/init.py inside _import_extra_cpu_backends(), mirroring the AppleOps pattern. |
Yes, my mistake. I was thinking of the wrong file. But it would be good to get rid of that if it is now just supported within the base numpy ops |
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
Loading spaCy pipelines (e.g. en_core_web_sm) on big-endian hosts like s390x currently fails with ValueError: Little-endian buffer not supported on big-endian compiler, because thinc's Cython typed memoryviews reject the little-endian arrays that ship in the serialized model. This PR adds a thinc.util.ensure_native_byteorder helper and routes both Ops.asarray and NumpyOps.asarray through it, so deserialized arrays are byteswapped to native order before reaching any Cython path. On little-endian platforms native arrays are returned by identity, so there is no behavioural or performance change.
Types of change
Bug fix — enables thinc (and downstream spaCy) to load little-endian model artifacts on big-endian CPUs (like s390x ).
Checklist