-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FP16 causes cross-compilation errors for x86-64 targets on macOS. #6989
Comments
I think FP16 really is a necessary dependency, it's not optional for optimization. The thing that would need to be optional is support for float16 ops, which AFAIK is not and cannot easily be made so. Maratyszcza/FP16#32 is a workaround for this that might be easy for you to apply. Can you share how you are attempting to cross-compile XNNPACK? I'm not sure if this is an issue with the cross compilation setup (which could be looking for the wrong math.h, i.e. using an x86 math.h when it should be using an ARM one), or an issue with XNNPACK's build. |
https://github.com/Tinuv-Dev/TensorflowLiteBuilder I'm happy to share my build script, even though it's a bit rough. You just need to enable libXNNPACK in the TensorflowLiteBuilder and comment out the other libraries. extension TensorflowLiteBuilder {
func initLibrayList() -> [Library] {
var libraryList: [Library] = []
// libraryList.append(.libAbseil)
// libraryList.append(.libeigen)
// libraryList.append(.libflatbuffers)
// libraryList.append(.libNEON_2_SSE)
// libraryList.append(.libcpuinfo)
// libraryList.append(.libruy)
// libraryList.append(.libpthreadpool)
libraryList.append(.libXNNPACK)
// libraryList.append(.libtensorflow)
return libraryList
}
} After that, modify your workDirectory and other configurations as needed. static let workDirectory = "file:///your/work/path"
static let buildDirectory = workDirectory + "/build"
static let distDirectory = workDirectory + "/dist"
static let patchDirector = workDirectory + "/patch"
static let platforms = PlatformType.allCases.filter { ![.watchos, .watchsimulator, .android].contains($0) } then run the main file to build with XNNPACK. You can see in the Builder file that I checked out the source code for XNNPACK to a specific commit ID to successfully compile it. If you comment out those statements, you'll be able to see the errors I described. func obtainSource() {
if !FileManager.default.fileExists(atPath: lib.libSourceDirectory.path()) {
var arguments = ["clone", "--recurse-submodules"]
arguments.append(contentsOf: ["--branch", lib.libVersion, lib.libRepoURL, lib.libSourceDirectory.path()])
try! Utility.launch(path: "/usr/bin/git", arguments: arguments)
//if lib == .libXNNPACK {
// try! Utility.launch(path: "/usr/bin/git", arguments: ["checkout", "e716e05befe59f2512f82432fb161ba1fea9969a"],currentDirectoryURL: lib.libSourceDirectory)
//}
}
} |
Some compilation options can be found in the LibXNNPACKBuilder file. |
This dependency is causing issues on some platforms. We have a workaround: https://github.com/Maratyszcza/fp16 that some users have implemented (e.g. https://github.com/microsoft/onnxruntime/pull/22294/files), but it doesn't make sense to hack this workaround into everything that depends on XNNPACK. This PR pulls the small part of the fp16 library we actually need in XNNPACK, and removes the dependency. Fixes #6989 FUTURE_COPYBARA_INTEGRATE_REVIEW=#7128 from imaginationtech:img_patch30_f32_f16_vcvt 2f40edd PiperOrigin-RevId: 682156616
I attempted to cross-compile XNNPACK today using the latest code from the master branch, but the compilation failed with an error. I am quite puzzled by this because I was able to successfully cross-compile XNNPACK not long ago.
After analyzing the error, I found that it is likely caused by the use of FP16. It seems that a recent commit (5443c56, commit message: “Add a typedef for float16 to uint16”) added #include <fp16/fp16.h> to libXNNPACK-source-master/src/xnnpack/math.h. This inclusion causes a compilation error when cross-compiling for the x86-64 target (including macOS x86-64 physical devices and iOS x86-64 simulators). It appears that FP16 is a library used for optimization. Could you add an option to the CMakeLists.txt file that allows me to disable FP16 optimization? Alternatively, if there is another way to do this, I would appreciate any guidance that would allow me to successfully cross-compile.
Additional Information:
Log Information:
The text was updated successfully, but these errors were encountered: