microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
13.48k stars 2.76k forks source link

[Build] Compiliation failed on Xilinx Zynq #15155

Open BoarQing opened 1 year ago

BoarQing commented 1 year ago

Describe the issue

onnxruntime_mlas.cmake failed to compile on Xilinx's Zynq.

It seems like fp16 is not supported on Zynq.

Urgency

It would stall the verification process of Vitis-AI, a provider for onnxruntime.

Target platform

Xilinx Zynq(aarch640)

Build script

None

Error / output

cc1plus: error: switch ‘-mcpu=cortex-a72.cortex-a53’ conflicts with ‘-march=armv8.2-a+fp16’ switch [-Werror]

Visual Studio Version

No response

GCC / Compiler Version

No response

chenfucn commented 1 year ago

Please take a look at the following PR. This PR is aimed at fixing compilation errors caused by older compilers or assemblers not supporting fp16. https://github.com/microsoft/onnxruntime/pull/15055

BoarQing commented 1 year ago

it does not fix the error. It is not beacuase older compilers or assemblers. It is because the hardware(-mcpu=cortex-a72.cortex-a53) does not support fp16.

chenfucn commented 1 year ago

I searched our cmake file, it does not add (-mcpu=cortex-a72.cortex-a53) at all. And I tried to dump all compilation flags on Linux arm64, found so such flags either. Would you check why your make system would add such flags?

BoarQing commented 1 year ago

We are using pentalinux which compile arm binary on a x86 machine. Thus, the flag is added. But, I checked on wiki. Isn't fp16 supported after armv8.2? Would that cause error even if we compile it natively and without the flag on an aritecture older than v8.2?

chenfucn commented 1 year ago

Sorry I am not sure I understand how those flags are added in your case. I used an x86 machine for cross compilation arm64, and I checked, those flags were not added.

BoarQing commented 1 year ago

It is not really about the flag. Could you check if your code can compile and run on an aritecture older than v8.2? https://en.wikipedia.org/wiki/ARM_Cortex-A72

frdasah commented 8 months ago

Hi, I am facing the same issue. I am compiling for linux environment for arm v8.0 processor (-mcpu=cortex-a53).

The flags that cause the issue are set in file cmake/onnxruntime_mlas.cmake (around line 360) for the case NOT APPLE. For example on 1.15.1: set_source_files_properties(${MLAS_SRC_DIR}/aarch64/HalfGemmKernelNeon.S PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ") set_source_files_properties(${MLAS_SRC_DIR}/activate_fp16.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ") set_source_files_properties(${MLAS_SRC_DIR}/dwconv.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ") set_source_files_properties(${MLAS_SRC_DIR}/pooling_fp16.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ")

Is there any way to compile for armv8.0 processors for linux ?

BoarQing commented 8 months ago

Hi, I am facing the same issue. I am compiling for linux environment for arm v8.0 processor (-mcpu=cortex-a53).

The flags that cause the issue are set in file cmake/onnxruntime_mlas.cmake (around line 360) for the case NOT APPLE. For example on 1.15.1: set_source_files_properties(${MLAS_SRC_DIR}/aarch64/HalfGemmKernelNeon.S PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ") set_source_files_properties(${MLAS_SRC_DIR}/activate_fp16.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ") set_source_files_properties(${MLAS_SRC_DIR}/dwconv.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ") set_source_files_properties(${MLAS_SRC_DIR}/pooling_fp16.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+fp16 ")

Is there any way to compile for armv8.0 processors for linux ?

We used a custom patch to skip compiling these file.

frdasah commented 8 months ago

Thank you for your answer. I also did a patch on my side.