From ee338b10476b5ef77058f259097084af63a21030 Mon Sep 17 00:00:00 2001
From: auphelia <jakobapk@web.de>
Date: Tue, 28 Jan 2020 12:40:33 +0000
Subject: [PATCH] [CustomOps] Added empty functions to guarantee no errors with
 abstract methods in HLSCustomOp class

---
 .../fpgadataflow/convolutioninputgenerator.py |  6 +++++
 .../fpgadataflow/streamingfclayer_batch.py    | 23 ++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py b/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py
index 91460fdac..4bf9bbf56 100644
--- a/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py
+++ b/src/finn/custom_op/fpgadataflow/convolutioninputgenerator.py
@@ -36,6 +36,12 @@ class ConvolutionInputGenerator(HLSCustomOp):
     def verify_node(self):
         pass
 
+    def bram_estimation(self):
+        pass
+
+    def lut_estimation(self):
+        pass
+
     def get_input_datatype(self):
         return DataType[self.get_nodeattr("inputDataType")]
 
diff --git a/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py b/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py
index 8d3d063c7..7bbd6e9b0 100644
--- a/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py
+++ b/src/finn/custom_op/fpgadataflow/streamingfclayer_batch.py
@@ -1,5 +1,5 @@
 import os
-
+import math
 import numpy as np
 
 from finn.backend.fpgadataflow.utils import numpy_to_hls_code
@@ -141,6 +141,27 @@ class StreamingFCLayer_Batch(HLSCustomOp):
 
         return info_messages
 
+    def bram_estimation(self):
+        P = self.get_nodeattr("PE")
+        Q = self.get_nodeattr("SIMD")
+        wdt = self.get_weight_datatype()
+        W = wdt.bitwidth()
+        D_in = self.get_instream_width()
+        D_out = self.get_outstream_width()
+        omega = (D_in * D_out) / (Q * P)
+        return P * (math.ceil(omega / 512)) * (math.ceil((Q * W) / 36))
+
+    def lut_estimation(self):
+        P = self.get_nodeattr("PE")
+        Q = self.get_nodeattr("SIMD")
+        wdt = self.get_weight_datatype()
+        W = wdt.bitwidth()
+        tdt = DataType.INT32
+        A = tdt.bitwidth()
+        c0 = 300
+        c1 = 1.1
+        return c0 + c1 * (P * Q) * (W * A)
+
     def get_input_datatype(self):
         return DataType[self.get_nodeattr("inputDataType")]
 
-- 
GitLab