ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

Last several values get corrupted

Open jialiang19 opened this issue 9 years ago • 4 comments

Dear ARM Developers:

First of all, thank you very much for updating the library, and I cannot wait to try the new features like your AlexNet Implementations.

I have found a really bad bug about 4 days ago, but I did not submit right away because I suspect that may be the GPU driver I was using at the time was outdated. Yesterday, My research advisor and other PHD students help me to set up a new Mali GPU with updated driver. However, once everything set up with a newly released version of library downloaded, the same bug has remained.

Here is the description of the bug:

I have been implementing AlexNet on my own for a while now, I started to test the correctness of the each output layers implemented by ARM computing library. After using the same weights and biases and inputs, I compare the outputs of the caffe implementation and the outputs of the ARM Computing implementations. However, it seems that the last several values of the output get corrupted!

So for the AlexNet, the output value after the first Convolution layer and first relu layer is corrected. However, after the first Normalization Layer, the last several values started to be corrupted. Eventually, this mistakes start to propogate until everyvalue start to be corrputed when entering Fully-connected Layers.

This is the screen shots of the output:

First comparison (the output value is corrected after the first convolution layer and first activation layer):

output of the caffee: caffe_relu1 output of the ARM_computing library: arm_computing_activation1

Second comparison (the mojority of the value is correct, but the last several values get corrupted. Look closer to the last several lines.)

output of caffee: caffe_norm1

output of the ARM_computing Library: arm_norm1

You can see that the last several values are corrupted somehow.

jialiang19 avatar Jun 29 '17 16:06 jialiang19

Hello @jialiang19,

Can you please post the code that you use so that we can have a better look?

GeorgeARM avatar Jun 29 '17 16:06 GeorgeARM

Hellow @GeorgeARM, Thank you for the quick response:

the code for the CLNormalization is here. I have double checked that the size of the activation1 tensor and the size of the norm1 tensor is correct. and the value stored in activation1 tensor is corrected by comparing with those from caffe. However, after this layer, the values start to be corropted.

        /*norm1*/
        CLTensor norm1;
        const TensorShape norm1_shape(activation1_shape);
        norm1.allocator()->init(TensorInfo(norm1_shape, Format::F32));
        NormalizationLayerInfo norm_info1(/*NormalizationLayerInfo::*/ NormType::CROSS_MAP,5,0.0001,0.75);
        CLNormalizationLayer normlayer1;
        normlayer1.configure(&activation1, &norm1, norm_info1);
        norm1.allocator()->allocate();
        normlayer1.run();

The full code is about 900 lines, do you need me to post the full code?

jialiang19 avatar Jun 29 '17 16:06 jialiang19

@jialiang19 am I correct to assume that you call configure/allocate/run for each layers separately? You have to configure all the layers first, then call allocate on all the tensors and finally call run for all the layers. If you check the alexnet model example, we first create the tensors, then configure all the layers, then allocate the tensors and finally call run on the layers. This is required as some functions might add padding to your tensors if required. The way you do it, where you preallocate the tensor, locks the ability to extend the padding leading the kernels to run on a reduced window (that's why you notice that your last values are not being calculated at all). Read the documentation for more details on how padding works.

GeorgeARM avatar Jun 29 '17 17:06 GeorgeARM

Hi @GeorgeARM, Yes, you are indeed correct! Thank you for your help!

jialiang19 avatar Jun 29 '17 20:06 jialiang19