Giter Site home page Giter Site logo

Comments (7)

maltanar avatar maltanar commented on August 19, 2024

A quick note if you are using the finn compiler to produce the finn-hlslib description: we have a ConvertSubToAdd transformation that converts subtraction ops to add ops, which would handle this without any extra implementation: https://github.com/Xilinx/finn-base/blob/dev/src/finn/transformation/general.py#L233

(If you are manually putting together finn-hlslib layers then what I wrote above does not apply)

from finn-hlslib.

SpontaneousDuck avatar SpontaneousDuck commented on August 19, 2024

Thanks for the response! Unfortunately, I am subtracting two unique streams. I assume I would need a block to invert the sign of one fo the streams then? Which is the better solution?

from finn-hlslib.

giuliogamba avatar giuliogamba commented on August 19, 2024

Hi, changing the API of AddStreams could have implications in the finn compiler, so I would advise against it.
I would suggest trying using the Thresholding_Batch function (here) with the activation function std::negate, that should allow you to perform sign inversion on a per-channel basis on one of the inputs allowing you to do a subtraction in 2 steps.

from finn-hlslib.

SpontaneousDuck avatar SpontaneousDuck commented on August 19, 2024

Sounds like a plan! Is there a method for doing that in FINN? A matching CustomOp?

from finn-hlslib.

maltanar avatar maltanar commented on August 19, 2024

This approach best discussed on the finn gitter channel as it's not an hlslib issue per se. Also feel free to open an issue on the finn compiler repo with a minimal example and we can try to help formulate a way of making this work. But in summary:

If you express the subtraction of streams explicitly as a negate-and-add I believe this should be doable with existing transformations and CustomOps, namely InferChannelwiseLinearLayer to convert standalone Mul by -1 into the CustomOp ChannelWiseOp_Batch which is implemented with the Thresholding_Batch function under the hood (https://github.com/Xilinx/finn/blob/master/src/finn/custom_op/fpgadataflow/channelwise_op_batch.py). Followed by appropriate transformations to infer the AddStreams.

from finn-hlslib.

SpontaneousDuck avatar SpontaneousDuck commented on August 19, 2024

Thanks for the help!

from finn-hlslib.

SpontaneousDuck avatar SpontaneousDuck commented on August 19, 2024

Thanks for the help!

from finn-hlslib.

Related Issues (19)

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.