Git Product home page Git Product logo

Comments (5)

mpflanzer avatar mpflanzer commented on May 5, 2024 1

When you call allocate before configuring the function the tensor by default will be allocated with no padding. The ActivationLayer function tries to process 16 elements at once (in X direction) but since your tensor is smaller the end of the window is automatically reduced to prevent invalid memory accesses. In your case it is reduced all the way down to zero which later triggers the assertion. We will add a better error message to indicate the problem.

To use the ActivationLayer function your options are:

  • to set the padding manually before allocating the tensors (TensorInfo::extend_padding(PaddingSize)),
  • to use auto padding which will be large enough to run any function but will allocate unnecessarily much memory for many functions (TensorInfo::auto_padding(), not recommended) or
  • to allocate the tensors after configuring the functions. In that case the function will update the padding according to their needs. But this can only be done if the tensors are not already allocated.

from computelibrary.

AnthonyBarbier avatar AnthonyBarbier commented on May 5, 2024

In your piece of code it's unclear where and how you allocate your buffers, could you please give us more details ?

from computelibrary.

AnthonyBarbier avatar AnthonyBarbier commented on May 5, 2024

We've tried to run the following code and it seems to work:

    Tensor input;
    Tensor output;

    const TensorShape shape(14U, 14U, 192U);

    input.allocator()->init(TensorInfo(shape, 1, DataType::F32));
    output.allocator()->init(TensorInfo(shape, 1, DataType::F32));

    NEActivationLayer activation;
    activation.configure(&input, &output, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU));

    input.allocator()->allocate();
    //TODO: Fill the input's content
    output.allocator()->allocate();

    activation.run();

from computelibrary.

sundw2014 avatar sundw2014 commented on May 5, 2024

Hi @AnthonyARM ,
I found that if I call the allocate() function before configure(), it will crash.

The following code crashed.

    input->allocator()->allocate();
    output->allocator()->allocate();
    activation.configure(input, output, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU));

    activation.run();

The following code worked.

    activation.configure(input, output, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU));
    input->allocator()->allocate();
    output->allocator()->allocate();

    activation.run();

I have not got how to use Tensor properly. ^_^!

This is the complete test code

    const TensorShape shape(14U, 14U, 192U);

    Tensor *input = new Tensor();
    input->allocator()->init(TensorInfo(shape, Format::F32));

    Tensor *output = new Tensor();
    output->allocator()->init(TensorInfo(shape, Format::F32));

    NEActivationLayer activation;
    activation.configure(input, output, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU));
    input->allocator()->allocate();
    output->allocator()->allocate();

    activation.run();

from computelibrary.

sundw2014 avatar sundw2014 commented on May 5, 2024

Cool! Thank you all.

from computelibrary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.