ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

Issue with Normalization layer

Open uu-praveeng opened this issue 9 years ago • 4 comments

Hi, When I am trying to use the Normalization layer. Output is coming as expected but during the function exit I' getting the below error

*** Error in `./norm_layer': double free or corruption (!prev): 0x000000001182d040 *** Aborted

Code I'm using is as below.

main()
{
   // The src tensor which will contain the input image
    Tensor src;
    Tensor dup_src;

    // The weights and biases tensors should be initialized with the values inferred with the training
    Tensor dst;

    NENormalizationLayer    NormLayer;

    /* [Initialize tensors] */

   
    src.allocator()->init(TensorInfo(TensorShape(32000), 1, DataType::F32));
    dup_src.allocator()->init(TensorInfo(TensorShape(500), 1, DataType::F32));
    dst.allocator()->init(TensorInfo(TensorShape(500), 1, DataType::F32));

    printf("MWNormLayer :: %d %d\n",dup_src.info()->total_size(),dst.info()->total_size());
    NormLayer.configure(&dup_src, &dst, NormalizationLayerInfo(NormType::CROSS_MAP,1,0.0001, 0.75, 1.0));
    printf("MWNormLayer :: %d %d\n",dup_src.info()->total_size(),dst.info()->total_size());

    src.allocator()->allocate();
    dup_src.allocator()->allocate();
    dst.allocator()->allocate();
    
    if(src.info()->total_size() == dup_src.info()->total_size())
    {
      std::copy_n((unsigned char*)src.buffer(), 500*sizeof(float), (unsigned char*)dup_src.buffer());
    }
    else if(src.info()->total_size() > dup_src.info()->total_size())
    {
       printf("Entered the elseif %d %d %d\n",src.info()->offset_element_in_bytes(Coordinates(0, 0)),dup_src.info()->offset_element_in_bytes(Coordinates(0, 0)),500*sizeof(float));
       std::copy_n((unsigned char*)src.buffer(), 500*sizeof(float), (unsigned char*)dup_src.buffer()+dup_src.info()->offset_element_in_bytes(Coordinates(0, 0)));
    }
    else
    {
       printf("WARNING ::: Padding added during the Configure reconsider the copying !!!\n");
       printf("%d %d %d %d \n",src.info()->total_size(),dup_src.info()->total_size(),src.info()->offset_element_in_bytes(Coordinates(0, 0)),dup_src.info()->offset_element_in_bytes(Coordinates(0, 0)));
       std::copy_n((unsigned char*)src.buffer() +  src.info()->offset_element_in_bytes(Coordinates(0, 0)), 500*sizeof(float), (unsigned char*)dup_src.buffer() + dup_src.info()->offset_element_in_bytes(Coordinates(0, 0)));
    }

    NormLayer.run();
} 

Can you please point out what is the wrong with the code.

Thanks, G. Praveen.

uu-praveeng avatar Apr 07 '17 10:04 uu-praveeng

Hello,

We don't see such a failure. Can you add your build commands for the library and your test please? Thanks

GeorgeARM avatar Apr 07 '17 12:04 GeorgeARM

Hi, Please use the above c code and execute below make file commands in ComputeLibrary-master. CPP = aarch64-oe-linux-g++ #Creates the libarm.so using the Compute Library code arm_lib: $(CPP) -c -fpic -D_GLIBCXX_USE_NANOSLEEP -Wno-deprecated-declarations -Wall -DARCH_ARM -Wextra -Wno-unused-parameter -pedantic -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wstrict-overflow=2 -Wswitch-default -fpermissive -std=c++11 -Wno-vla -Woverloaded-virtual -Wctor-dtor-privacy -Wsign-promo -Weffc++ -Wno-format-nonliteral -Wno-overlength-strings -Wno-strict-overflow -Wlogical-op -Wnoexcept -Wstrict-null-sentinel -march=armv8-a -Werror -O3 -gdwarf-2 -Ibuild -I. -Iinclude src/core/NEON/kernels/.cpp src/runtime/NEON/.cpp src/runtime/NEON/functions/.cpp src/core/.cpp src/core/CPP/.cpp src/runtime/.cpp src/core/CPP/kernels/*.cpp src/runtime/CPP/CPPScheduler.cpp $(CPP) -shared -o libarm.so *.o -lpthread -lrt rm *.o sfmax: $(CPP) -march=armv8-a -O0 -g norm_layer.cpp -I. -Iinclude -std=c++11 -L. -larm -o norm_layer -Wl,-rpath,. clean: rm *.o libarm.so

Board and compiler toolchain version are as below Target platform is Juno Board Rev 0. Tool chain used is aarch64-oe-linux-g++ (Linaro GCC 4.9-2015.03) 4.9.3 20150311

Thanks in advance

uu-praveeng avatar Apr 07 '17 13:04 uu-praveeng

Thanks for providing more details. I managed to reproduce the issue and we already have fixed it internally. It is likely to be merged into the public branch over the next week.

mpflanzer avatar Apr 07 '17 14:04 mpflanzer

Fixed in v17.04 (Re-open if you still see the issue)

AnthonyBarbier avatar Apr 13 '17 17:04 AnthonyBarbier