Closed ezyang closed 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:
confu
, the configuration system I use in NNPACK development.--convolution-only
and --inference-only
options would incur a significant increase in size of mobile builds.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.
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.
@ezyang The variable name is confusing:
nnp_convolution_inference
)--inference-only
disables building functions which are only used for training--convolution-only
disables building functions for non-convolutional layers (i.e. ReLU, SoftMax, FC, MaxPool)Thus, it would make more sense to do
check_symbol_exists(nnp_convolution_kernel_gradient "nnpack.h" NNPACK_HAS_TRAINING)
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:nnpack.h
was adjusted to only contain the actual definitions that actually made it into the objects, you'd get a more understandable "nnp_blah not in scope" rather than a linking error way later in the build process.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