Maratyszcza / NNPACK

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

Surprising nnp_status_insufficient_buffer return code #149

Closed rsaxvc closed 6 years ago

rsaxvc commented 6 years ago

I'm using nnp_convolution_algorithm_implicit_gemm. Steps:

  1. Call nnp_convolution_inference with nnp_convolution_transform_strategy_precompute to compute how much memory is required for the workspace. Result code is success.
  2. Allocate correct amount of memory for the workspace
  3. Call nnp_convolution_inference again with nnp_convolution_transform_strategy_precompute and a pointer to the workspace. The result code is success.
  4. Call nnp_convolution_inference with nnp_convolution_transform_strategy_reuse, and a pointer to the workspace.

On step 4 I sometimes receive nnp_status_insufficient_buffer. I believe this has something to do with the specific layer configuration I'm passing in. Some layers work fine. I've verified that the workspace sizes I'm passing in match those allocated and requested by the earlier precompute calls.

I think the problem is that nnp_convolution_transform_strategy_precompute allocates/checks against packed_kernel_size, but nnp_convolution_transform_strategy_reuse checks the packed_kernel_size + packed_input_size. Additionally, the computation of packed_kernel_size is done differently in the two locations.

Maratyszcza commented 6 years ago

It seems that you are not using the API right. See #82 and #75 for explanation.

rsaxvc commented 6 years ago

You're right. What I had missed: