Skip to content

Fix Mac M1 build#16763

Merged
edgchen1 merged 3 commits into
mainfrom
edgchen1/fix_m1_build
Jul 21, 2023
Merged

Fix Mac M1 build#16763
edgchen1 merged 3 commits into
mainfrom
edgchen1/fix_m1_build

Conversation

@edgchen1

@edgchen1 edgchen1 commented Jul 19, 2023

Copy link
Copy Markdown
Contributor

Description

  1. Add ifndef __APPLE__ to skip lines which cause EXC_BAD_INSTRUCTION error.

  2. Fix floatToHalf/doubleToHalf conversion issue and add tests.
    Eigen was updated and the type of __half_raw.x changed to __fp16. See this commit. From here, "Operators that expect arithmetic operands immediately promote __fp16 operands to float." Apparently, the __fp16 result was promoted to float before assignment to uint16_t. Copying the bytes over with something like std::bit_cast does what we want here.

Motivation and Context

Fix Mac M1 build issues.

Fix #16496.
Fix #16230.

@cbourjau

cbourjau commented Jul 20, 2023

Copy link
Copy Markdown
Contributor

It would be great if this could be tested in CI going forward (possibly in a follow-up PR?). In the meantime, I'd like to I can confirm that this patch works for me locally! Thanks!

Edit: Fixed ambiguous wording

@edgchen1

edgchen1 commented Jul 20, 2023

Copy link
Copy Markdown
Contributor Author

It would be great if this could be tested in CI going forward (possibly in a follow-up PR?). In the meantime I'd like to confirm that this patch works for me locally! Thanks!

Please try it out and let me know. I agree that a Mac M1 CI test would be nice but I don't know if we have Mac M1 build agents. Will try to set something up if possible.

Edit: Sorry, I think I misunderstood - you've confirmed that this change works locally. In that case, good to know. :)

@Craigacp

Copy link
Copy Markdown
Contributor

This also fixes the SIGILL for me on my 2020 13" M1 MBP. It does expose a test failure in the Java CoreML test as CoreML is less precise than the expected value, I'll put a small patch in for that, though I don't think any of the CI runs have both --build_java and --use_coreml turned on.

Comment thread onnxruntime/core/mlas/lib/platform.cpp
chenfucn
chenfucn previously approved these changes Jul 20, 2023
@edgchen1
edgchen1 merged commit 0f9883f into main Jul 21, 2023
@edgchen1
edgchen1 deleted the edgchen1/fix_m1_build branch July 21, 2023 01:24
ytaous pushed a commit that referenced this pull request Aug 9, 2023
### Description
Reduces precision on the CoreML provider test as it returns slightly
different answers than the other tested providers. Checked on a 2020 13"
M1 MBP.

### Motivation and Context
Fixes Java CoreML test failure after #16763.
jchen351 pushed a commit that referenced this pull request Aug 12, 2023
- Add ifndef `__APPLE__` to skip lines which cause EXC_BAD_INSTRUCTION error.
- Fix floatToHalf/doubleToHalf conversion issue and add tests.
jchen351 pushed a commit that referenced this pull request Aug 12, 2023
### Description
Reduces precision on the CoreML provider test as it returns slightly
different answers than the other tested providers. Checked on a 2020 13"
M1 MBP.

### Motivation and Context
Fixes Java CoreML test failure after #16763.
kleiti pushed a commit to kleiti/onnxruntime that referenced this pull request Mar 22, 2024
### Description
Reduces precision on the CoreML provider test as it returns slightly
different answers than the other tested providers. Checked on a 2020 13"
M1 MBP.

### Motivation and Context
Fixes Java CoreML test failure after microsoft#16763.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants