diff --git a/src/finn/custom_op/fpgadataflow/addstreams_batch.py b/src/finn/custom_op/fpgadataflow/addstreams_batch.py index aaf8687de1ace42c20bd55362850707bfeddcd88..fa80e47485eef4f289b0272fd73ac185bd1c2c5e 100644 --- a/src/finn/custom_op/fpgadataflow/addstreams_batch.py +++ b/src/finn/custom_op/fpgadataflow/addstreams_batch.py @@ -29,7 +29,6 @@ import numpy as np import os import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -84,12 +83,7 @@ class AddStreams_Batch(HLSCustomOp): assert ishape == exp_ishape, "Unexpected input1 shape." ishape = tuple(model.get_tensor_shape(self.onnx_node.input[1])) assert ishape == exp_ishape, "Unexpected input2 shape." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/channelwise_op_batch.py b/src/finn/custom_op/fpgadataflow/channelwise_op_batch.py index 083ee894f470fa309027979ba0f596d1844ead25..4961f6148231252d255c1830ced418308032ce41 100644 --- a/src/finn/custom_op/fpgadataflow/channelwise_op_batch.py +++ b/src/finn/custom_op/fpgadataflow/channelwise_op_batch.py @@ -30,7 +30,6 @@ import numpy as np import os import warnings from math import ceil -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -125,12 +124,7 @@ class ChannelwiseOp_Batch(HLSCustomOp): def make_shape_compatible_op(self, model): oshape = self.get_normal_output_shape() # implement tensor with correct shape - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py b/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py index def0b20b0801fc9c91eaba4401f9676a8237bd4a..a4018836846257c15ad203b1cef54c03cd081e45 100644 --- a/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py +++ b/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py @@ -29,7 +29,6 @@ import math import numpy as np import os -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -148,12 +147,7 @@ class ConvolutionInputGenerator(HLSCustomOp): ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == exp_ishape, "Unexpect input shape for ConvInpGen." # implement tensor with correct shape - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/convolutioninputgenerator1d.py b/src/finn/custom_op/fpgadataflow/convolutioninputgenerator1d.py index 6a81b917703e35d0d10cfbabafe7f40073eb3903..c4cf804126328b27fd56091d70f0b6e658b5b3c1 100644 --- a/src/finn/custom_op/fpgadataflow/convolutioninputgenerator1d.py +++ b/src/finn/custom_op/fpgadataflow/convolutioninputgenerator1d.py @@ -29,7 +29,6 @@ import math import numpy as np import os -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -137,12 +136,7 @@ class ConvolutionInputGenerator1D(HLSCustomOp): oshape = self.get_normal_output_shape() ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == exp_ishape, "Unexpect input shape for ConvInpGen." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/downsampler.py b/src/finn/custom_op/fpgadataflow/downsampler.py index 9dcbb5e14400008f662feb2419fa54dfd3face03..6a0667f67dc9f127637bd80cc3e88f682a320cbb 100644 --- a/src/finn/custom_op/fpgadataflow/downsampler.py +++ b/src/finn/custom_op/fpgadataflow/downsampler.py @@ -1,7 +1,6 @@ import numpy as np import os import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -83,12 +82,7 @@ class DownSampler(HLSCustomOp): oshape = self.get_normal_output_shape() ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == exp_ishape, "Unexpect input shape for DownSampler." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/fmpadding_batch.py b/src/finn/custom_op/fpgadataflow/fmpadding_batch.py index dd761956695786f10feebb60dd12dc21d751b801..f29ea431ffc95d6291407c35c17d943647cf45df 100644 --- a/src/finn/custom_op/fpgadataflow/fmpadding_batch.py +++ b/src/finn/custom_op/fpgadataflow/fmpadding_batch.py @@ -1,7 +1,6 @@ import numpy as np import os import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -99,12 +98,7 @@ class FMPadding_Batch(HLSCustomOp): oshape = self.get_normal_output_shape() ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == exp_ishape, "Unexpect input shape for SameResize." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/globalaccpool_batch.py b/src/finn/custom_op/fpgadataflow/globalaccpool_batch.py index d6f860db150c554804477243bc4b9582bdaba8b0..6d4a55ee5c86b68776f4c7c2e58930034bb0be02 100644 --- a/src/finn/custom_op/fpgadataflow/globalaccpool_batch.py +++ b/src/finn/custom_op/fpgadataflow/globalaccpool_batch.py @@ -29,7 +29,6 @@ import numpy as np import os import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -95,12 +94,7 @@ class GlobalAccPool_Batch(HLSCustomOp): oshape = self.get_normal_output_shape() ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == exp_ishape, "Unexpected input shape." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/iodma.py b/src/finn/custom_op/fpgadataflow/iodma.py index 34842181c3d66a01a52a895fadb812ea939a5b0a..802c7e78515336ef884e5ff09356085b5cc6069f 100644 --- a/src/finn/custom_op/fpgadataflow/iodma.py +++ b/src/finn/custom_op/fpgadataflow/iodma.py @@ -29,7 +29,6 @@ import math import numpy as np import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -146,12 +145,7 @@ class IODMA(HLSCustomOp): oshape = self.get_normal_output_shape() ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == exp_ishape, "Unexpected input shape." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/labelselect_batch.py b/src/finn/custom_op/fpgadataflow/labelselect_batch.py index 4d34de8fcc3c0f6c9000b4c456e5a6d772d65245..1eb5962fdbc54092eaeb4796806b3a623c65aea8 100644 --- a/src/finn/custom_op/fpgadataflow/labelselect_batch.py +++ b/src/finn/custom_op/fpgadataflow/labelselect_batch.py @@ -106,8 +106,10 @@ class LabelSelect_Batch(HLSCustomOp): "RandomNormal", inputs=[], outputs=[self.onnx_node.output[0]], - shape=list(oshape), + mean=0.0, + scale=1.0, dtype=TensorProto.INT64, + shape=list(oshape), ) def infer_node_datatype(self, model): diff --git a/src/finn/custom_op/fpgadataflow/pool_batch.py b/src/finn/custom_op/fpgadataflow/pool_batch.py index 332b400c0db1bfb2a0da1d3d44010e3d98d4a82b..ba8a446f2cf7541c0bd2e1dff731afe2397942ef 100644 --- a/src/finn/custom_op/fpgadataflow/pool_batch.py +++ b/src/finn/custom_op/fpgadataflow/pool_batch.py @@ -28,7 +28,6 @@ import numpy as np import os -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -163,12 +162,7 @@ class Pool_Batch(HLSCustomOp): oshape = self.get_normal_output_shape() ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == exp_ishape, "Unexpected input shape for Pool_Batch." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/streamingdatawidthconverter_batch.py b/src/finn/custom_op/fpgadataflow/streamingdatawidthconverter_batch.py index aaf796b15b8eb2b60f1dafd8a9eaf8db8b841560..1791706afa217d5eb453064547c1ea66b306d227 100644 --- a/src/finn/custom_op/fpgadataflow/streamingdatawidthconverter_batch.py +++ b/src/finn/custom_op/fpgadataflow/streamingdatawidthconverter_batch.py @@ -30,7 +30,6 @@ import math import numpy as np import os import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -165,12 +164,7 @@ class StreamingDataWidthConverter_Batch(HLSCustomOp): oshape = self.get_normal_output_shape() ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == tuple(exp_ishape), "Unexpect input shape for StreamingDWC." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py b/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py index ccc9780ff4efe5a651eaa4cb826e9f296399b22c..90abb66e66bc54bc9d1f4c7a08c58ca58e6d1741 100644 --- a/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py +++ b/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py @@ -31,7 +31,6 @@ import numpy as np import os import textwrap import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -151,12 +150,7 @@ class StreamingFCLayer_Batch(HLSCustomOp): def make_shape_compatible_op(self, model): oshape = self.get_normal_output_shape() - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/streamingfifo.py b/src/finn/custom_op/fpgadataflow/streamingfifo.py index 02d9a1915ce0a31a7c36d147525d43a4ed799d26..91f6ed5b8d29fd72ea1fbb8a3da94cfc103af88e 100644 --- a/src/finn/custom_op/fpgadataflow/streamingfifo.py +++ b/src/finn/custom_op/fpgadataflow/streamingfifo.py @@ -30,7 +30,6 @@ import numpy as np import os import subprocess import warnings -from onnx import helper from shutil import copy from finn.core.datatype import DataType @@ -78,12 +77,7 @@ class StreamingFIFO(HLSCustomOp): oshape = self.get_normal_output_shape() ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == tuple(exp_ishape), "Unexpect input shape for StreamingFIFO." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/streamingmaxpool_batch.py b/src/finn/custom_op/fpgadataflow/streamingmaxpool_batch.py index 5574d67066dcde7e7df7f4ff043f50e2b1e9fb4b..1e66a5c204cc62bb7620907f82fcd5b2072bc184 100644 --- a/src/finn/custom_op/fpgadataflow/streamingmaxpool_batch.py +++ b/src/finn/custom_op/fpgadataflow/streamingmaxpool_batch.py @@ -29,7 +29,6 @@ import numpy as np import os import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -140,12 +139,7 @@ class StreamingMaxPool_Batch(HLSCustomOp): oshape = self.get_normal_output_shape() ishape = tuple(model.get_tensor_shape(self.onnx_node.input[0])) assert ishape == exp_ishape, "Unexpect input shape for StreamingMaxPool." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/thresholding_batch.py b/src/finn/custom_op/fpgadataflow/thresholding_batch.py index d5fa86abdd2fbb99d90615641b6a579425fee57c..610139f44ee7e8be1320b47c99222667fa6ed850 100644 --- a/src/finn/custom_op/fpgadataflow/thresholding_batch.py +++ b/src/finn/custom_op/fpgadataflow/thresholding_batch.py @@ -31,7 +31,6 @@ import os import textwrap import warnings from math import ceil, log2 -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -112,12 +111,7 @@ class Thresholding_Batch(HLSCustomOp): def make_shape_compatible_op(self, model): oshape = self.get_normal_output_shape() - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/upsampler.py b/src/finn/custom_op/fpgadataflow/upsampler.py index 60052b46a11f4347a2938494e35fc827fdf0b6d3..d5f809305b6bf30285e58e1c702bfe9d21f5fa03 100644 --- a/src/finn/custom_op/fpgadataflow/upsampler.py +++ b/src/finn/custom_op/fpgadataflow/upsampler.py @@ -1,7 +1,6 @@ import numpy as np import os import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -69,12 +68,7 @@ class UpsampleNearestNeighbour_Batch(HLSCustomOp): assert ( ishape == exp_ishape ), "Unexpect input shape for UpsampleNearestNeighbour_Batch." - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node diff --git a/src/finn/custom_op/fpgadataflow/vector_vector_activate_batch.py b/src/finn/custom_op/fpgadataflow/vector_vector_activate_batch.py index 0ad03f37cda75e577e5543cf5aeaf61dbc192fda..c67eb0f21bd3a3a21bd92d3b4595ab66bd703b93 100644 --- a/src/finn/custom_op/fpgadataflow/vector_vector_activate_batch.py +++ b/src/finn/custom_op/fpgadataflow/vector_vector_activate_batch.py @@ -2,7 +2,6 @@ import math import numpy as np import os import warnings -from onnx import helper from finn.core.datatype import DataType from finn.custom_op.fpgadataflow.hlscustomop import HLSCustomOp @@ -129,12 +128,7 @@ class Vector_Vector_Activate_Batch(HLSCustomOp): def make_shape_compatible_op(self, model): oshape = self.get_normal_output_shape() - return helper.make_node( - "RandomNormal", - inputs=[], - outputs=[self.onnx_node.output[0]], - shape=list(oshape), - ) + return super().make_const_shape_op(oshape) def infer_node_datatype(self, model): node = self.onnx_node