NNPACK icon indicating copy to clipboard operation
NNPACK copied to clipboard

Windows

Open CFAndy opened this issue 8 years ago • 7 comments

Can NNPACK support windows?

CFAndy avatar Aug 13 '16 14:08 CFAndy

Here is a list of obstacles to Windows support:

  • NNPACK is written in C99, and Microsoft compilers still do not support this 17 years old standard.
  • It is possible to compile NNPACK with Clang with Microsoft codegen from the recent Visual Studio version, and the current configure.py has incomplete initial support for this configuration. However, linking would fail because the runtime library does not support _Complex float functions from C99 standard library. These functions are widely used in the reference implementation of FFT functions in NNPACK, and thus it is impossible to link the unit tests without them.
  • NNPACK uses pthreadpool library for multi-threading, and pthreadpool is implemented on top of pthreads and GCC-specific intrinsic functions for atomic operations. pthreads interface is not natively supported on Windows. Probably github.com/GerHobbelt/pthread-win32 can be leveraged to pthreads on Windows, but I didn't try.

Other options to try:

  • Compilation of NNPACK with Cygwin might work, but would be incompatible with most of Windows ecosystem.
  • Compilation of NNPACK with mingw would solve problems 1 and 2, probably problem 3 as well.
  • Compilation to NNPACK with Intel compiler for Windows should fix problems 1 and 2. pthreadpool dependency on pthreads would need to be resolved manually.

That said, I don't have plans (and time) for Windows port, but such contribution would be welcome!

Maratyszcza avatar Aug 13 '16 16:08 Maratyszcza

It's very helpful.

CFAndy avatar Aug 15 '16 01:08 CFAndy

Is it possible that I can easily compile NNPACK with Intel compiler for Windows if I just use

enum nnp_status nnp_convolution_inference(
                               enum nnp_convolution_algorithm algorithm,
                               enum nnp_convolution_transform_strategy transform_strategy,
                               size_t input_channels,
                               size_t output_channels,
                               struct nnp_size input_size,
                               struct nnp_padding input_padding,
                               struct nnp_size kernel_size,
                               struct nnp_size output_subsampling,
                               const float input[],
                               const float kernel[],
                               const float bias[],
                               float output[],
                               pthreadpool_t threadpool,
                               struct nnp_profile* profile)

for deployment and don't use the multi-thread feature within it(simply assign threadpool = null)?

knsong avatar Dec 19 '16 08:12 knsong

@knsong I think it will work. You'll have to remove nearly all implementation code from the thread pool.

Maratyszcza avatar Dec 19 '16 09:12 Maratyszcza

I converted the c99 AVX2 convolution part to a native windows c++ static library. I used the microsoft ppl functionality as a solution for the threadpool. Many thanks for your great library! Filip

ghost avatar May 08 '17 22:05 ghost

@zeno40 could you please create a PR?

miolini avatar May 11 '17 18:05 miolini

Well I created a public repository

https://github.com/zeno40/nnpack-windows

ghost avatar May 17 '17 20:05 ghost