da4ml 0.3.1__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of da4ml might be problematic. Click here for more details.

Files changed (98) hide show
  1. {da4ml-0.3.1 → da4ml-0.3.2}/.clang-format +10 -10
  2. da4ml-0.3.2/.github/workflows/sphinx-build.yml +60 -0
  3. {da4ml-0.3.1 → da4ml-0.3.2}/.gitignore +3 -0
  4. da4ml-0.3.2/PKG-INFO +66 -0
  5. da4ml-0.3.2/README.md +37 -0
  6. da4ml-0.3.2/docs/Makefile +21 -0
  7. da4ml-0.3.2/docs/_static/example.svg +1537 -0
  8. da4ml-0.3.2/docs/_static/icon.svg +4719 -0
  9. da4ml-0.3.2/docs/_static/stage1.svg +1199 -0
  10. da4ml-0.3.2/docs/_static/stage2.svg +1250 -0
  11. da4ml-0.3.2/docs/_static/workflow.svg +678 -0
  12. da4ml-0.3.2/docs/cmvm.md +34 -0
  13. da4ml-0.3.2/docs/conf.py +68 -0
  14. da4ml-0.3.1/DAIS-spec.md → da4ml-0.3.2/docs/dais.md +10 -8
  15. da4ml-0.3.2/docs/faq.md +32 -0
  16. da4ml-0.3.2/docs/getting_started.md +88 -0
  17. da4ml-0.3.2/docs/index.rst +69 -0
  18. da4ml-0.3.2/docs/install.md +12 -0
  19. da4ml-0.3.2/docs/status.md +23 -0
  20. da4ml-0.3.2/interperter/DAISInterpreter.cc +311 -0
  21. {da4ml-0.3.1 → da4ml-0.3.2}/interperter/DAISInterpreter.hh +5 -9
  22. {da4ml-0.3.1 → da4ml-0.3.2}/pyproject.toml +1 -0
  23. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/_version.py +16 -3
  24. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/cmvm/types.py +12 -2
  25. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/cpp_codegen.py +4 -1
  26. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/comb.py +19 -11
  27. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/source/binder_util.hh +8 -6
  28. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/source/ioutil.hh +2 -1
  29. da4ml-0.3.2/src/da4ml/codegen/verilog/source/multiplier.v +37 -0
  30. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/verilog_model.py +2 -3
  31. da4ml-0.3.2/src/da4ml/converter/__init__.py +3 -0
  32. da4ml-0.3.2/src/da4ml/converter/hgq2/__init__.py +3 -0
  33. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/converter/hgq2/parser.py +60 -10
  34. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/converter/hgq2/replica.py +125 -35
  35. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/trace/fixed_variable.py +133 -20
  36. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/trace/fixed_variable_array.py +55 -7
  37. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/trace/ops/__init__.py +4 -4
  38. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/trace/ops/einsum_utils.py +5 -2
  39. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/trace/ops/reduce_utils.py +4 -2
  40. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/trace/pipeline.py +6 -4
  41. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/trace/tracer.py +27 -13
  42. da4ml-0.3.2/src/da4ml.egg-info/PKG-INFO +66 -0
  43. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml.egg-info/SOURCES.txt +17 -1
  44. da4ml-0.3.2/src/da4ml.egg-info/requires.txt +9 -0
  45. da4ml-0.3.1/PKG-INFO +0 -107
  46. da4ml-0.3.1/README.md +0 -84
  47. da4ml-0.3.1/interperter/DAISInterpreter.cc +0 -314
  48. da4ml-0.3.1/src/da4ml/converter/__init__.py +0 -0
  49. da4ml-0.3.1/src/da4ml.egg-info/PKG-INFO +0 -107
  50. da4ml-0.3.1/src/da4ml.egg-info/requires.txt +0 -2
  51. {da4ml-0.3.1 → da4ml-0.3.2}/.github/workflows/python-publish.yml +0 -0
  52. {da4ml-0.3.1 → da4ml-0.3.2}/.pre-commit-config.yaml +0 -0
  53. {da4ml-0.3.1 → da4ml-0.3.2}/LICENSE +0 -0
  54. {da4ml-0.3.1 → da4ml-0.3.2}/setup.cfg +0 -0
  55. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/__init__.py +0 -0
  56. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/cmvm/__init__.py +0 -0
  57. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/cmvm/api.py +0 -0
  58. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/cmvm/core/__init__.py +0 -0
  59. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/cmvm/core/indexers.py +0 -0
  60. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/cmvm/core/state_opr.py +0 -0
  61. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/cmvm/util/__init__.py +0 -0
  62. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/cmvm/util/bit_decompose.py +0 -0
  63. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/cmvm/util/mat_decompose.py +0 -0
  64. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/__init__.py +0 -0
  65. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/__init__.py +0 -0
  66. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/hls_model.py +0 -0
  67. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_binary.h +0 -0
  68. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_common.h +0 -0
  69. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_decl.h +0 -0
  70. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_fixed.h +0 -0
  71. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_fixed_base.h +0 -0
  72. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_fixed_ref.h +0 -0
  73. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_fixed_special.h +0 -0
  74. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_int.h +0 -0
  75. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_int_base.h +0 -0
  76. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_int_ref.h +0 -0
  77. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_int_special.h +0 -0
  78. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/ap_shift_reg.h +0 -0
  79. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/etc/ap_private.h +0 -0
  80. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/hls_math.h +0 -0
  81. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/hls_stream.h +0 -0
  82. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/ap_types/utils/x_hls_utils.h +0 -0
  83. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/binder_util.hh +0 -0
  84. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/build_binder.mk +0 -0
  85. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/cpp/source/vitis_bitshift.hh +0 -0
  86. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/__init__.py +0 -0
  87. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/io_wrapper.py +0 -0
  88. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/pipeline.py +0 -0
  89. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/source/build_binder.mk +0 -0
  90. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/source/build_prj.tcl +0 -0
  91. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/source/mux.v +0 -0
  92. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/source/negative.v +0 -0
  93. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/source/shift_adder.v +0 -0
  94. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/codegen/verilog/source/template.xdc +0 -0
  95. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/trace/__init__.py +0 -0
  96. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml/trace/ops/conv_utils.py +0 -0
  97. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml.egg-info/dependency_links.txt +0 -0
  98. {da4ml-0.3.1 → da4ml-0.3.2}/src/da4ml.egg-info/top_level.txt +0 -0
@@ -8,17 +8,17 @@ AlwaysBreakAfterDefinitionReturnType: None
8
8
  AlwaysBreakAfterReturnType: None
9
9
  BreakBeforeBraces: Custom
10
10
  BraceWrapping:
11
- AfterClass: true
12
- AfterControlStatement: true
13
- AfterEnum: true
14
- AfterFunction: true
15
- AfterNamespace: true
16
- AfterStruct: true
17
- AfterUnion: true
11
+ AfterClass: false
12
+ AfterControlStatement: false
13
+ AfterEnum: false
14
+ AfterFunction: false
15
+ AfterNamespace: false
16
+ AfterStruct: false
17
+ AfterUnion: false
18
18
  AfterExternBlock: true
19
19
  BeforeCatch: true
20
20
  BeforeElse: true
21
- IndentBraces: true
21
+ IndentBraces: false
22
22
  SplitEmptyFunction: false
23
23
  SplitEmptyRecord: false
24
24
  SplitEmptyNamespace: false
@@ -28,11 +28,11 @@ Cpp11BracedListStyle: true
28
28
  KeepEmptyLinesAtTheStartOfBlocks: false
29
29
  Language: Cpp
30
30
  NamespaceIndentation: All
31
- PenaltyExcessCharacter: 100
31
+ PenaltyExcessCharacter: 120
32
32
  PenaltyReturnTypeOnItsOwnLine: 1
33
33
  PointerAlignment: Right
34
34
  SortIncludes: false
35
- SpaceBeforeParens: Never
35
+ SpaceBeforeParens: ControlStatements
36
36
  SpacesInContainerLiterals: false
37
37
  Standard: Cpp11
38
38
  BinPackArguments: false
@@ -0,0 +1,60 @@
1
+ name: Documentation
2
+
3
+ on:
4
+ # Runs on pushes targeting the default branch
5
+ push:
6
+ branches: ["master"]
7
+
8
+ # Allows you to run this workflow manually from the Actions tab
9
+ workflow_dispatch:
10
+
11
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12
+ permissions:
13
+ contents: read
14
+ pages: write
15
+ id-token: write
16
+
17
+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18
+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19
+ concurrency:
20
+ group: "pages"
21
+ cancel-in-progress: false
22
+
23
+ jobs:
24
+ # Build job
25
+ build:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - name: Checkout
29
+ uses: actions/checkout@v4
30
+ with:
31
+ fetch-depth: 0
32
+ - name: Setup Pages
33
+ uses: actions/configure-pages@v3
34
+ - uses: actions/setup-python@v4
35
+ with:
36
+ python-version: "3.11"
37
+ - name: Install dependencies
38
+ run: |
39
+ pip3 install ".[docs]"
40
+ pip3 install jax
41
+ - name: Build
42
+ run: |
43
+ cd docs
44
+ KERAS_BACKEND=jax make html
45
+ - name: Upload artifact
46
+ uses: actions/upload-pages-artifact@v3
47
+ with:
48
+ path: "docs/_build/html"
49
+
50
+ # Deployment job
51
+ deploy:
52
+ environment:
53
+ name: github-pages
54
+ url: ${{ steps.deployment.outputs.page_url }}
55
+ runs-on: ubuntu-latest
56
+ needs: build
57
+ steps:
58
+ - name: Deploy to GitHub Pages
59
+ id: deployment
60
+ uses: actions/deploy-pages@v4
@@ -1,3 +1,6 @@
1
+ # autodoc
2
+ docs/autodoc/
3
+
1
4
  # test files
2
5
  _*_codegen/
3
6
 
da4ml-0.3.2/PKG-INFO ADDED
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: da4ml
3
+ Version: 0.3.2
4
+ Summary: Digital Arithmetic for Machine Learning
5
+ Author-email: Chang Sun <chsun@cern.ch>
6
+ License: GNU Lesser General Public License v3 (LGPLv3)
7
+ Project-URL: repository, https://github.com/calad0i/da4ml
8
+ Keywords: CMVM,distributed arithmetic,hls4ml,MCM,subexpression elimination
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: llvmlite>=0.44
21
+ Requires-Dist: numba>=0.61
22
+ Provides-Extra: docs
23
+ Requires-Dist: hgq2; extra == "docs"
24
+ Requires-Dist: myst-parser; extra == "docs"
25
+ Requires-Dist: pyparsing; extra == "docs"
26
+ Requires-Dist: sphinx; extra == "docs"
27
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
28
+ Dynamic: license-file
29
+
30
+ # da4ml: Distributed Arithmetic for Machine Learning
31
+
32
+ [![LGPLv3](https://img.shields.io/badge/License-LGPLv3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
33
+ [![Documentation](https://github.com/calad0i/da4ml/actions/workflows/sphinx-build.yml/badge.svg)](https://calad0i.github.io/da4ml/)
34
+ [![PyPI version](https://badge.fury.io/py/da4ml.svg)](https://badge.fury.io/py/da4ml)
35
+ [![ArXiv](https://img.shields.io/badge/arXiv-2507.04535-b31b1b.svg)](https://arxiv.org/abs/2507.04535)
36
+
37
+ da4ml is a library for implementing distributed arithmetic (DA) based algorithms for ultra-low latency machine learning (ML) applications on FPGAs. It as two major components:
38
+ - A fast and performant constant-matrix-vector multiplications (CMVM) optimizer to implement them as
39
+ efficient adder trees. Common sub-expressions elimination (CSE) with graph-based pre-optimization are
40
+ performed to reduce the firmware footprint and improve the performance.
41
+ - Low-level symbolic tracing frameworks for generating combinational/fully pipelined logics in HDL or HLS
42
+ code. For fully pipelined networks, da4ml can generate the firmware for the whole network standalone.
43
+ Alternatively, da4ml be used as a plugin in hls4ml to optimize the CMVM operations in the network.
44
+
45
+
46
+ Key Features
47
+ ------------
48
+
49
+ - **Optimized Algorithms**: Comparing to hls4ml's latency strategy, da4ml's CMVM implementation uses no DSO and consumes up to 50% less LUT usage.
50
+ - **Fast code generation**: da4ml can generate HDL for a fully pipelined network in seconds. For the same models, high-level synthesis tools like Vivado/Vitis HLS can take up to days to generate the HDL code.
51
+ - **Low-level symbolic tracing**: As long as the operation can be expressed by a combination of the low-level operations supported, adding new operations is straightforward by "replaying" the operation on the symbolic tensor provided. In most cases, adding support for a new operation/layer takes just a few lines of code in numpy flavor.
52
+ - **Automatic model conversion**: da4ml can automatically convert models trained in `HGQ2 <https://github.com/calad0i/hgq2>`_.
53
+ - **Bit-accurate Simulation**: All operation in da4ml is bit-accurate, meaning the generated HDL code will produce the same output as the original model. da4ml's computation is converted to a RISC-like, instruction set level intermediate representation, distributed arithmetic instruction set (DAIS), which can be easily simulated in multiple ways.
54
+ - **hls4ml integration**: da4ml can be used as a plugin in hls4ml to optimize the CMVM operations in the network by setting `strategy='distributed_arithmetic'` for the strategy of the Dense, EinsumDense, or Conv1/2D layers.
55
+
56
+ Installation
57
+ ------------
58
+
59
+ ```bash
60
+ pip install da4ml
61
+ ```
62
+
63
+ Getting Started
64
+ ---------------
65
+
66
+ See the [Getting Started](https://calad0i.github.io/da4ml/getting_started.html) guide for a quick introduction to using da4ml.
da4ml-0.3.2/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # da4ml: Distributed Arithmetic for Machine Learning
2
+
3
+ [![LGPLv3](https://img.shields.io/badge/License-LGPLv3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
4
+ [![Documentation](https://github.com/calad0i/da4ml/actions/workflows/sphinx-build.yml/badge.svg)](https://calad0i.github.io/da4ml/)
5
+ [![PyPI version](https://badge.fury.io/py/da4ml.svg)](https://badge.fury.io/py/da4ml)
6
+ [![ArXiv](https://img.shields.io/badge/arXiv-2507.04535-b31b1b.svg)](https://arxiv.org/abs/2507.04535)
7
+
8
+ da4ml is a library for implementing distributed arithmetic (DA) based algorithms for ultra-low latency machine learning (ML) applications on FPGAs. It as two major components:
9
+ - A fast and performant constant-matrix-vector multiplications (CMVM) optimizer to implement them as
10
+ efficient adder trees. Common sub-expressions elimination (CSE) with graph-based pre-optimization are
11
+ performed to reduce the firmware footprint and improve the performance.
12
+ - Low-level symbolic tracing frameworks for generating combinational/fully pipelined logics in HDL or HLS
13
+ code. For fully pipelined networks, da4ml can generate the firmware for the whole network standalone.
14
+ Alternatively, da4ml be used as a plugin in hls4ml to optimize the CMVM operations in the network.
15
+
16
+
17
+ Key Features
18
+ ------------
19
+
20
+ - **Optimized Algorithms**: Comparing to hls4ml's latency strategy, da4ml's CMVM implementation uses no DSO and consumes up to 50% less LUT usage.
21
+ - **Fast code generation**: da4ml can generate HDL for a fully pipelined network in seconds. For the same models, high-level synthesis tools like Vivado/Vitis HLS can take up to days to generate the HDL code.
22
+ - **Low-level symbolic tracing**: As long as the operation can be expressed by a combination of the low-level operations supported, adding new operations is straightforward by "replaying" the operation on the symbolic tensor provided. In most cases, adding support for a new operation/layer takes just a few lines of code in numpy flavor.
23
+ - **Automatic model conversion**: da4ml can automatically convert models trained in `HGQ2 <https://github.com/calad0i/hgq2>`_.
24
+ - **Bit-accurate Simulation**: All operation in da4ml is bit-accurate, meaning the generated HDL code will produce the same output as the original model. da4ml's computation is converted to a RISC-like, instruction set level intermediate representation, distributed arithmetic instruction set (DAIS), which can be easily simulated in multiple ways.
25
+ - **hls4ml integration**: da4ml can be used as a plugin in hls4ml to optimize the CMVM operations in the network by setting `strategy='distributed_arithmetic'` for the strategy of the Dense, EinsumDense, or Conv1/2D layers.
26
+
27
+ Installation
28
+ ------------
29
+
30
+ ```bash
31
+ pip install da4ml
32
+ ```
33
+
34
+ Getting Started
35
+ ---------------
36
+
37
+ See the [Getting Started](https://calad0i.github.io/da4ml/getting_started.html) guide for a quick introduction to using da4ml.
@@ -0,0 +1,21 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @sphinx-apidoc -f -o autodoc/ ../src/da4ml
21
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)