Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce support for generic elementwise binary operations #1040

Draft
wants to merge 28 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9bb8313
Introduce support for generic elementwise binary operations
iksnagreb Apr 12, 2024
f61a538
[Streamline] Fix FoldQuantWeights input order and shape annotations
iksnagreb Nov 13, 2023
8691d3f
Make quantized activation handlers data layout aware
iksnagreb Nov 20, 2023
24acc18
[Streamline] Fix AbsorbAddIntoMultiThreshold assumed input order
iksnagreb Nov 13, 2023
e632328
Fix clipping range issue in RoundAndClipThresholds transformation
iksnagreb Mar 13, 2024
8dd85f4
Rework RoundAndClipThresholds to avoid range and type promotion issues
iksnagreb Apr 6, 2024
8b7c2eb
[Thresholding] Make sure the output of python simulation is float32
iksnagreb Apr 17, 2024
f01d02f
[Tests] Rework test-cases for reworked RoundAndClipThresholds
iksnagreb Apr 6, 2024
023d950
[Streamline] Check validity of broadcasting Add into MultiThreshold
iksnagreb Apr 17, 2024
945db12
[Streamline] Fix backwards-propagating shapes in MoveAddPastMul
iksnagreb Apr 17, 2024
3f13673
[Elementwise] Add InferElementwiseBinaryOperation transformation
iksnagreb Apr 18, 2024
6a6616a
[Tests] Add simple integration test for ElementwiseBinaryOperation
iksnagreb Apr 18, 2024
fd1aedd
[Elementwise] Some cleanup / simplification of generated code
iksnagreb Apr 19, 2024
f010d18
[Streamline] Fix shape propagation of MoveLinearPastEltwiseAdd
iksnagreb Apr 19, 2024
7aaf739
[Tests] Add missing streamlining for testing ElementwiseBinaryOperation
iksnagreb Apr 19, 2024
5268ffe
[Elementwise] Implement bit-width minimization for all specializations
iksnagreb Apr 19, 2024
4769d8e
[Elementwise] Add support for floating-point operations
iksnagreb Apr 19, 2024
87fc002
[Elementwise] Implement get_exp_cycles for ElementwiseBinaryOperation
iksnagreb May 3, 2024
efb1cc9
[Elementwise] Add support for ElementwiseBinaryOperation to SetFolding
iksnagreb May 3, 2024
f34dcfc
[Elementwise] Remove FIFO depths attribute overloads
iksnagreb May 10, 2024
e361cb9
[Elementwise] Add ARRAY_PARTITION and BIND_STORAGE directives
iksnagreb May 17, 2024
653673b
[Streamline] Prevent FactorOutMulSignMagnitude from handling join-nodes
iksnagreb Aug 8, 2024
de97911
[Streamline] Delete initializer datatype annotation after MoveAddPastMul
iksnagreb Aug 8, 2024
dd68078
[Elementwise] Reintroduce FIFO depths attribute overloads
iksnagreb Aug 28, 2024
48be8a5
Merge remote-tracking branch 'xilinx/dev' into elementwise-binary
iksnagreb Jan 20, 2025
2501f58
[Thresholding] Remove second offset left in due to merge conflict
iksnagreb Jan 28, 2025
57625f6
[Deps] flatten is now part of finn-hlslib but we do not have ap_float
iksnagreb Jan 28, 2025
91140a2
[Elementwise] Add rudimentary support for ElementwiseBitShift
iksnagreb Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ sections=FUTURE,STDLIB,TEST,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
default_section=THIRDPARTY
multi_line_output=3
profile=black
ignore_comments=true
ignore_whitespace=true
honor_noqa=true
4 changes: 2 additions & 2 deletions fetch-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ FINN_EXP_COMMIT="0724be21111a21f0d81a072fccc1c446e053f851"
BREVITAS_COMMIT="d4834bd2a0fad3c1fbc0ff7e1346d5dcb3797ea4"
PYVERILATOR_COMMIT="ce0a08c20cb8c1d1e84181d6f392390f846adbd1"
CNPY_COMMIT="4e8810b1a8637695171ed346ce68f6984e585ef4"
HLSLIB_COMMIT="16e5847a5e3ef76cffe84c8fad2f010d593457d3"
HLSLIB_COMMIT="bfc44f96763ecf6aded6e9fa8e48a1a3bfd8551a"
OMX_COMMIT="0b59762f9e4c4f7e5aa535ee9bc29f292434ca7a"
AVNET_BDF_COMMIT="2d49cfc25766f07792c0b314489f21fe916b639b"
XIL_BDF_COMMIT="8cf4bb674a919ac34e3d99d8d71a9e60af93d14e"
Expand All @@ -45,7 +45,7 @@ FINN_EXP_URL="https://github.com/Xilinx/finn-experimental.git"
BREVITAS_URL="https://github.com/Xilinx/brevitas.git"
PYVERILATOR_URL="https://github.com/maltanar/pyverilator.git"
CNPY_URL="https://github.com/rogersce/cnpy.git"
HLSLIB_URL="https://github.com/Xilinx/finn-hlslib.git"
HLSLIB_URL="https://github.com/iksnagreb/finn-hlslib.git"
OMX_URL="https://github.com/maltanar/oh-my-xilinx.git"
AVNET_BDF_URL="https://github.com/Avnet/bdf.git"
XIL_BDF_URL="https://github.com/Xilinx/XilinxBoardStore.git"
Expand Down
29 changes: 27 additions & 2 deletions src/finn/custom_op/fpgadataflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,33 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# The base class of all generic custom operations before specializing to either
# HLS or RTL backend
from finn.custom_op.fpgadataflow.hwcustomop import HWCustomOp

# Dictionary of HWCustomOp implementations
custom_op = dict()


# Registers a class into the custom_op dictionary
# Note: This must be defined first, before importing any custom op
# implementation to avoid "importing partially initialized module" issues.
def register_custom_op(cls):
# The class must actually implement HWCustomOp
assert issubclass(cls, HWCustomOp), f"{cls} must subclass {HWCustomOp}"
# Insert the class into the custom_op dictionary by its name
custom_op[cls.__name__] = cls # noqa: Some weird type annotation issue?
# Pass through the class unmodified
return cls


# flake8: noqa
# Disable linting from here, as all import will be flagged E402 and maybe F401


# Import the submodule containing specializations of ElementwiseBinaryOperation
# Note: This will automatically register all decorated classes into this domain
import finn.custom_op.fpgadataflow.elementwise_binary
from finn.custom_op.fpgadataflow.addstreams import AddStreams
from finn.custom_op.fpgadataflow.channelwise_op import ChannelwiseOp
from finn.custom_op.fpgadataflow.concat import StreamingConcat
Expand Down Expand Up @@ -55,8 +82,6 @@
from finn.custom_op.fpgadataflow.upsampler import UpsampleNearestNeighbour
from finn.custom_op.fpgadataflow.vectorvectoractivation import VVAU

custom_op = dict()

# make sure new HLSCustomOp subclasses are imported here so that they get
# registered and plug in correctly into the infrastructure
custom_op["MVAU"] = MVAU
Expand Down
Loading