ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

ASSERT in _weights_reshaped.allocator()->allocate() when configuring NEConvolutionLayer

Open joel-mi opened this issue 9 years ago • 4 comments

The Convolution Neural Network I'm trying to implement starts with Convolution Layer, followed by RELU, followed itself by 2nd convolution layer, etc ... I'm performing the following sequence of operations :

  1. configure 1st convolution (NEActivationLayer::configure)
  2. configure RELU - uses same input data tensor as 1st convolution's output data tensor
  3. perform "allocate" operations for all 4 tensors used by convolution (data-IN, weights, biases, data-OUT)
  4. fill data-IN, weights and biases tensors with data
  5. run 1st convolution (NEActivationLayer::run)
  6. delete data-IN and weights tensors - but not biases tensor which can be reused (number of output slices remains the same)
  7. create new weights tensor, input tensors and output tensor for 2nd convolution
  8. configure 2nd convolution :
    • at this stage, _weights_reshaped.allocator()->allocate() is failing on ARM_COMPUTE_ERROR_ON(_buffer != nullptr)

joel-mi avatar Apr 30 '17 13:04 joel-mi

Hi @joel-mi from the ASSERT it seems that you are trying to allocate a tensor (_weights_reshaped) already allocated. Is "_weights_reshaped" used for other functions?

Thanks

gmiodice avatar May 01 '17 02:05 gmiodice

No, it's a brand new tensor for weights (since I couldn't reuse the previous one) In some cases I do re-use tensors - in this case, the biases tensor, but I don't attempt to "re-allocate" it. I suspect that my problem may be somewhere else : I'm currently using one instance of NEConvolutionLayer for all convolution layers, and I re-configure it for each convolution layer; maybe I should have separate instances of NEConvolutionLayer for each convolution layer ?

joel-mi avatar May 01 '17 08:05 joel-mi

Hi @joel-mi ,

I think the issue is related to the re-use of NEConvolutionLayer. You should use a separate NEConvolutionLayer for each layer because otherwise you replace the internal tensor's pointer and re-allocate the memory for the internal tensors already allocated.

You should have something like:

NEConvolutionLayer conv0; NEConvolutionLayer conv1; NEConvolutionLayer conv2; NEConvolutionLayer conv3;

// Configure conv0.configure(); conv1.configure(); conv2.configure(); conv3.configure();

//Allocate ....

//Run conv0.run(); conv1.run(); conv2.run(); conv3.run();

If you re-use the NEConvolutionLayer, you won't be able to run properly your network. Could you try use different functions of NEConvolutionLayer?

Hope this can help you. Thanks

gmiodice avatar May 01 '17 12:05 gmiodice

Closing issue as answer is clear! Reopen if required.

GeorgeARM avatar May 04 '17 11:05 GeorgeARM