Maratyszcza / NNPACK

Acceleration package for neural networks on multi-core CPUs
BSD 2-Clause "Simplified" License
1.67k stars 317 forks source link

Make it easier to test whether functionality was built #123

Closed ezyang closed 6 years ago

ezyang commented 6 years ago

I am a library and I want to make use of an nnpack installation that I have found on a user's system. Can I use it? Well, it depends: nnpack has --convolution-only and --inference-only, which will remove certain symbols from the built objects. Right now, the only way to test if this has occurred is to, configure-style, see if you can actually link against the symbol or question. It would be nice if there were an easier way to test for this. A few possibilities:

Even better: don't let users control what symbols are available by configuration options; or split nnpack into separate libraries, one per logical unit of functionality.

Real case of this happening: https://github.com/pytorch/pytorch/issues/4336

Maratyszcza commented 6 years ago

@ezyang --convolution-only and --inference-only are intended to reduce size for mobile builds, and are off by default. I assume that users who explicitly enable these options understand what they are doing.

Unfortunately, neither option that you suggested is easy to implement:

For PyTorch, I would suggest to build NNPACK (using its CMake scripts) by default, and only use user-installed version if explicitly instructed to do so.

ezyang commented 6 years ago

OK, well, we ended up fixing this in PyTorch's build system using check_symbol_exists(nnp_convolution_kernel_gradient "nnpack.h" NNPACK_HAS_INFERENCE) to check if the symbol actually existed, so maybe if there is ever an FAQ written for this sort of thing, we could add this there.

Maratyszcza commented 6 years ago

@ezyang The variable name is confusing:

Thus, it would make more sense to do check_symbol_exists(nnp_convolution_kernel_gradient "nnpack.h" NNPACK_HAS_TRAINING)