RenderKit / oidn

Intel® Open Image Denoise library
https://www.openimagedenoise.org/
Apache License 2.0
1.74k stars 160 forks source link

Adding support for Apple silicon and optional support for Apple BNNS API #89

Closed Developer-Ecosystem-Engineering closed 3 years ago

Developer-Ecosystem-Engineering commented 3 years ago

MacOS 11.0 (BigSur) have updated support for various neural networks layers via improvements to Apple’s BNNS API’s (https://developer.apple.com/documentation/accelerate/bnns?language=objc). Specifically, 2D convolution+relu and max-pooling layers are now available from BNNS and as a result, OIDN u-Network could be easily implemented using BNNS API's. The attached patch:

  1. Allows OIDN to use BNNS API’s instead on MKL-DNN:

    • Convolution2D and max-pool layers are calling BNNS services directly
    • As BNNS uses NCHW data arrangement, new input, output and upscale services were added to support NCHW format
    • MKL-DNN is still used to manage memory
    • changes to cmake script to support new modeBNNS with all required versioning checks
  2. Allows compilation for Apple silicon based Macs and iPhone/iPad

    • Removing all files and dependencies of MKL-DNN that are specific for x86_64 platforms from compilation process
    • target ISPC to generate ios-arm64 object files, which are compatible with Apple silicon Mac and iOS

By default, Intel based Mac system will continue to use MKL-DNN. When targeting the build for Apple silicon Mac targets (CMAKE_OSX_ARCHITECTURES=arm64), cmake will enable BNNS builds and APPLE_SILICON. x86_64 Mac targets can build the BNNS option by setting OIDN_BNNS cmake boolean.

atafra commented 3 years ago

Thank you for the patch! We'll integrate it into the next major release of the library.

atafra commented 3 years ago

Integrated into v1.3.0 with major modifications.