diff --git a/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py b/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py index 3c16e8dabeca6848daf595a6b12e14595a38581d..55b9a2753b50f76c57fb08c7a24b29b49d82c8b8 100644 --- a/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py +++ b/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py @@ -34,7 +34,6 @@ from finn.core.datatype import DataType from finn.custom_op.fpgadataflow import HLSCustomOp from finn.custom_op.im2col import compute_conv_output_dim from onnx import TensorProto, helper -from finn.util.basic import roundup_to_integer_multiple from finn.util.data_packing import npy_to_rtlsim_input, rtlsim_output_to_npy # ONNX i/o tensor shape assumptions for ConvolutionInputGenerator: @@ -136,7 +135,7 @@ class ConvolutionInputGenerator(HLSCustomOp): """Returns FINN DataType of output.""" return DataType[self.get_nodeattr("outputDataType")] - def get_instream_width(self, axi_strm_padding=False): + def get_instream_width(self): """Returns stream width, input and output stream width are equal for the sliding window function""" ibits = self.get_input_datatype().bitwidth() @@ -144,15 +143,13 @@ class ConvolutionInputGenerator(HLSCustomOp): ifm_ch = self.get_nodeattr("IFMChannels") assert simd == ifm_ch, "SWG currently requires SIMD=IFM" in_width = simd * ibits - if axi_strm_padding is True: - in_width = roundup_to_integer_multiple(in_width, 8) return in_width - def get_outstream_width(self, axi_strm_padding=False): + def get_outstream_width(self): """Returns stream width, input and output stream width are equal for the sliding window function, so the function to determine the input stream width can be reused.""" - return self.get_instream_width(axi_strm_padding) + return self.get_instream_width() def get_number_output_values(self): folded_oshape = self.get_folded_output_shape() diff --git a/src/finn/custom_op/fpgadataflow/streamingdatawidthconverter_batch.py b/src/finn/custom_op/fpgadataflow/streamingdatawidthconverter_batch.py index ce4f883fa029225a5748c08463858e3bf1bfd35c..f30871909b1c70f3b5df148f1b6eae22fdbadc25 100644 --- a/src/finn/custom_op/fpgadataflow/streamingdatawidthconverter_batch.py +++ b/src/finn/custom_op/fpgadataflow/streamingdatawidthconverter_batch.py @@ -32,7 +32,6 @@ import numpy as np from finn.custom_op.fpgadataflow import HLSCustomOp from finn.core.datatype import DataType from onnx import TensorProto, helper -from finn.util.basic import roundup_to_integer_multiple from finn.util.data_packing import npy_to_rtlsim_input, rtlsim_output_to_npy # does not do anything at the ONNX node-by-node level, and input-output @@ -151,16 +150,12 @@ class StreamingDataWidthConverter_Batch(HLSCustomOp): folded_ishape = self.get_folded_input_shape() return np.prod(folded_ishape[:-1]) - def get_instream_width(self, axi_strm_padding=False): + def get_instream_width(self): in_width = self.get_nodeattr("inWidth") - if axi_strm_padding is True: - in_width = roundup_to_integer_multiple(in_width, 8) return in_width - def get_outstream_width(self, axi_strm_padding=False): + def get_outstream_width(self): out_width = self.get_nodeattr("outWidth") - if axi_strm_padding is True: - out_width = roundup_to_integer_multiple(out_width, 8) return out_width def make_shape_compatible_op(self, model): diff --git a/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py b/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py index f04ee7ca7830760f4ed2804b8b71f8fe5d29325f..994c17e688337bc4ef7b9f47700197370377631a 100644 --- a/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py +++ b/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py @@ -279,27 +279,21 @@ class StreamingFCLayer_Batch(HLSCustomOp): """Returns FINN DataType of output.""" return DataType[self.get_nodeattr("outputDataType")] - def get_instream_width(self, axi_strm_padding=False): + def get_instream_width(self): i_bits = self.get_input_datatype().bitwidth() in_width = i_bits * self.get_nodeattr("SIMD") - if axi_strm_padding is True: - in_width = roundup_to_integer_multiple(in_width, 8) return in_width - def get_outstream_width(self, axi_strm_padding=False): + def get_outstream_width(self): o_bits = self.get_output_datatype().bitwidth() out_width = o_bits * self.get_nodeattr("PE") - if axi_strm_padding is True: - out_width = roundup_to_integer_multiple(out_width, 8) return out_width - def get_weightstream_width(self, axi_strm_padding=False): + def get_weightstream_width(self): pe = self.get_nodeattr("PE") simd = self.get_nodeattr("SIMD") wp = self.get_weight_datatype().bitwidth() w_width = pe * simd * wp - if axi_strm_padding is True: - w_width = roundup_to_integer_multiple(w_width, 8) return w_width def get_ap_int_max_w(self): @@ -982,13 +976,13 @@ class StreamingFCLayer_Batch(HLSCustomOp): "{}_{}".format(self.onnx_node.name, self.onnx_node.name) ] # make instream width a multiple of 8 for AXI stream interface - in_width = roundup_to_integer_multiple(self.get_instream_width(), 8) + in_width = self.get_instream_width_padded() self.code_gen_dict["$IN_RANGE$"] = ["[{}:0]".format(in_width - 1)] self.code_gen_dict["$OUT_RANGE$"] = [ - "[{}:0]".format(self.get_outstream_width(axi_strm_padding=True) - 1) + "[{}:0]".format(self.get_outstream_width_padded - 1) ] # make weight stream width a multiple of 8 for AXI stream interface - weight_width = roundup_to_integer_multiple(self.get_weightstream_width(), 8) + weight_width = self.get_weightstream_width_padded() self.code_gen_dict["$WEIGHT_RANGE$"] = ["[{}:0]".format(weight_width - 1)] self.code_gen_dict["$WEIGHT_WIDTH$"] = [str(weight_width)] self.code_gen_dict["$WSTREAM_DEPTH$"] = [str(self.calc_wmem())] diff --git a/src/finn/custom_op/fpgadataflow/streamingmaxpool_batch.py b/src/finn/custom_op/fpgadataflow/streamingmaxpool_batch.py index ef1a5ee1bdc0bbe5c773aa375bf4402a8cb16ddb..83bc19030ebba66907e08c5b1e52d7c0ff9207a6 100644 --- a/src/finn/custom_op/fpgadataflow/streamingmaxpool_batch.py +++ b/src/finn/custom_op/fpgadataflow/streamingmaxpool_batch.py @@ -33,7 +33,6 @@ from finn.custom_op.fpgadataflow import HLSCustomOp from finn.custom_op.im2col import compute_conv_output_dim from finn.core.datatype import DataType from onnx import TensorProto, helper -from finn.util.basic import roundup_to_integer_multiple from finn.util.data_packing import npy_to_rtlsim_input, rtlsim_output_to_npy @@ -88,17 +87,15 @@ class StreamingMaxPool_Batch(HLSCustomOp): folded_oshape = self.get_folded_output_shape() return np.prod(folded_oshape[:-1]) - def get_instream_width(self, axi_strm_padding=False): + def get_instream_width(self): dt_bits = self.get_input_datatype().bitwidth() ifm_ch = self.get_nodeattr("NumChannels") in_width = int(dt_bits * ifm_ch) - if axi_strm_padding is True: - in_width = roundup_to_integer_multiple(in_width, 8) return in_width - def get_outstream_width(self, axi_strm_padding=False): + def get_outstream_width(self): """For streaming maxpool out stream with is the same as in stream width""" - return self.get_instream_width(axi_strm_padding) + return self.get_instream_width() def make_shape_compatible_op(self, model): exp_ishape = self.get_normal_input_shape() diff --git a/src/finn/custom_op/fpgadataflow/tlastmarker.py b/src/finn/custom_op/fpgadataflow/tlastmarker.py index a04b2a886984f3f98bd765ce617be6ca7c0170a8..4d4dee6506f04909c53cd05e4898a7ad77e4a83a 100644 --- a/src/finn/custom_op/fpgadataflow/tlastmarker.py +++ b/src/finn/custom_op/fpgadataflow/tlastmarker.py @@ -27,7 +27,6 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from finn.custom_op.fpgadataflow import HLSCustomOp -from finn.util.basic import roundup_to_integer_multiple class TLastMarker(HLSCustomOp): @@ -134,16 +133,12 @@ class TLastMarker(HLSCustomOp): def get_folded_output_shape(self): return self.get_folded_input_shape() - def get_instream_width(self, axi_strm_padding=False): + def get_instream_width(self): stream_width = self.get_nodeattr("StreamWidth") - if axi_strm_padding is True: - stream_width = roundup_to_integer_multiple(stream_width, 8) return stream_width - def get_outstream_width(self, axi_strm_padding=False): + def get_outstream_width(self): stream_width = self.get_nodeattr("StreamWidth") - if axi_strm_padding is True: - stream_width = roundup_to_integer_multiple(stream_width, 8) return stream_width def strm_decl(self):