Skip to content

Commit

Permalink
test cleanup and bringing up to updated finn-hlslib commit. Potential…
Browse files Browse the repository at this point in the history
… failing cases might exist due to removal of extra iteration in inWidth < OutWidth c

ases
  • Loading branch information
lstasytis committed Nov 26, 2024
1 parent 120edd9 commit 38f897c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 279 deletions.
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="35a04fcfc58044cbbbdd6ef07a38a247aa76efb6"
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/lstasytis/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
18 changes: 8 additions & 10 deletions src/finn/custom_op/fpgadataflow/hls/iodma_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def get_ap_int_max_w(self):
def docompute(self):
direction = self.get_nodeattr("direction")
mode = self.get_nodeattr("burstMode")
dwc_func = "StreamingDataWidthConverter_Batch"
dwc_func = "StreamingDataWidthConverterGeneralized_Batch"
if direction == "in":
if mode == "wrap":
func = "Mem2Stream_Batch_external_wmem"
Expand All @@ -236,7 +236,7 @@ def docompute(self):
raise ValueError("Invalid IODMA direction, please set to in or out")
# define templates for instantiation
dma_inst_template = func + "<DataWidth1, NumBytes1>(%s, %s, numReps);"
dwc_inst_template = dwc_func + "<%d, %d, %d, %d, %d>(%s, %s, numReps);"
dwc_inst_template = dwc_func + "<%d, %d, %d, %d>(%s, %s, numReps);"
# do stream infrastructure and instantiations
intfw = self.get_nodeattr("intfWidth")
strmw = self.get_nodeattr("streamWidth")
Expand All @@ -252,10 +252,10 @@ def docompute(self):

numInWords = total_bits // inWidth
numOutWords = total_bits // outWidth
totalIters = max(numInWords, numOutWords)
# totalIters = max(numInWords, numOutWords)

if outWidth > inWidth:
totalIters += int(np.floor(outWidth / inWidth) + 1) - 1
# if outWidth > inWidth:
# totalIters += int(np.floor(outWidth / inWidth) + 1) - 1

# AXI MM -> IODMA -> (DWCs) -> out
# DWCs depend on AXI MM and out interface width
Expand All @@ -277,7 +277,6 @@ def docompute(self):
outWidth,
numInWords,
numOutWords,
totalIters,
"dma2dwc",
"out_" + self.hls_sname(),
),
Expand All @@ -289,10 +288,10 @@ def docompute(self):

numInWords = total_bits // inWidth
numOutWords = total_bits // outWidth
totalIters = max(numInWords, numOutWords)
# totalIters = max(numInWords, numOutWords)

if outWidth > inWidth:
totalIters += int(np.floor(outWidth / inWidth) + 1) - 1
# if outWidth > inWidth:
# totalIters += int(np.floor(outWidth / inWidth) + 1) - 1

# in0 -> (DWCs) -> IODMA -> AXI MM
# DWCs depend on AXI MM and out interface width
Expand All @@ -313,7 +312,6 @@ def docompute(self):
outWidth,
numInWords,
numOutWords,
totalIters,
"in0_" + self.hls_sname(),
"dwc2dma",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
# 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.

import math
import numpy as np
import os
from qonnx.core.datatype import DataType
import math

from finn.custom_op.fpgadataflow.hlsbackend import HLSBackend
from finn.custom_op.fpgadataflow.streamingdatawidthconverter import (
StreamingDataWidthConverter,
Expand Down Expand Up @@ -60,30 +61,19 @@ def defines(self, var):
# so we use numReps to represent the first 2 dimensions
# + batching if shape[0] != 1
numReps = int(np.prod(self.get_folded_input_shape()[:-2]))
# numReps = 1

# assuming folded shapes are at least 2 dim-long
numInWords = int(np.prod(self.get_folded_input_shape()[-2:-1]))
numOutWords = int(np.prod(self.get_folded_output_shape()[-2:-1]))

# numInWords = int(np.prod(self.get_folded_input_shape()[-2:]))
# numOutWords = int(np.prod(self.get_folded_output_shape()[-2:]))

inWidth = self.get_nodeattr("inWidth")
outWidth = self.get_nodeattr("outWidth")
totalIters = max(numInWords, numOutWords)

# if we are building up a word, the overall loop count is longer
if outWidth > inWidth:
totalIters += int(np.floor(outWidth / inWidth) + 1) - 1


self.code_gen_dict["$DEFINES$"] = [
"#define InWidth %d " % inWidth,
"#define OutWidth %d " % outWidth,
"#define NumInWords %d " % numInWords,
"#define NumOutWords %d " % numOutWords,
"#define totalIters %d " % totalIters,
"#define numReps %d" % numReps,
]

Expand All @@ -106,8 +96,8 @@ def docompute(self):
op = "StreamingDataWidthConverterGeneralized_Batch"

self.code_gen_dict["$DOCOMPUTE$"] = [
"%s<InWidth, OutWidth, NumInWords,NumOutWords," % op
+ " totalIters>(in0_%s, out_%s, numReps);" % (self.hls_sname(), self.hls_sname())
"%s<InWidth, OutWidth, NumInWords,NumOutWords" % op
+ ">(in0_%s, out_%s, numReps);" % (self.hls_sname(), self.hls_sname())
]

def blackboxfunction(self):
Expand Down Expand Up @@ -243,7 +233,6 @@ def execute_node(self, context, graph):
), """Output
shape doesn't match expected shape, should be same as input shape"""


def lut_estimation(self):
"""Calculates resource estimations for LUTs"""

Expand All @@ -270,6 +259,6 @@ def lut_estimation(self):
cset_luts += intw + outw

# generalized DWC cost penalty, this value is temporary
cnt_luts *=8
cnt_luts *= 8

return int(cnt_luts + cset_luts)
return int(cnt_luts + cset_luts)
Loading

0 comments on commit 38f897c

Please sign in to comment.