From c5051b51ac5d8db7b5d235419a1538258a35a8a7 Mon Sep 17 00:00:00 2001 From: Shan Li Date: Fri, 3 Nov 2023 17:44:45 -0700 Subject: [PATCH] No public description PiperOrigin-RevId: 579349096 Change-Id: Ieff86598351a0d9a614299fe77d8b0db2f2559ed --- qkeras/qtools/{ => DnC}/divide_and_conquer.py | 9 ++++++--- qkeras/qtools/{ => DnC}/dnc_layer_cost_ace.py | 0 tests/qtools_model_test.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) rename qkeras/qtools/{ => DnC}/divide_and_conquer.py (99%) rename qkeras/qtools/{ => DnC}/dnc_layer_cost_ace.py (100%) diff --git a/qkeras/qtools/divide_and_conquer.py b/qkeras/qtools/DnC/divide_and_conquer.py similarity index 99% rename from qkeras/qtools/divide_and_conquer.py rename to qkeras/qtools/DnC/divide_and_conquer.py index 41a37827..f92db071 100644 --- a/qkeras/qtools/divide_and_conquer.py +++ b/qkeras/qtools/DnC/divide_and_conquer.py @@ -36,7 +36,7 @@ from qkeras.qtools import qgraph from qkeras.qtools import qtools_util from qkeras.qtools import generate_layer_data_type_map -from qkeras.qtools import dnc_layer_cost_ace +from qkeras.qtools.DnC import dnc_layer_cost_ace class CostMode(enum.Enum): @@ -262,10 +262,13 @@ def get_per_layer_cost(layer_quantizer_bitwidth, layer_mac_count, layer_shapes, wbit=layer_quantizer_bitwidth["weight_bits"], abit=layer_quantizer_bitwidth["acc_bits"], regen_params=False) - pe_area = (mac_gates * layer_mac_count * cin_unroll * cout_unroll * - kh_unroll * kw_unroll) + + # pe_area is not dependent on total num of MACs in the layer. + pe_area = (mac_gates * cin_unroll * cout_unroll * kh_unroll * kw_unroll) # Memory includes input, output and weight memory, translated to gates. + # TODO(lishanok@): weights could be stored in either SRAM or ROM, dependent + # on user specification. memory_area = ( InElementPerClk * layer_quantizer_bitwidth["input_bits"] * dnc_layer_cost_ace.MemoryGatesPerBit["Register"] + diff --git a/qkeras/qtools/dnc_layer_cost_ace.py b/qkeras/qtools/DnC/dnc_layer_cost_ace.py similarity index 100% rename from qkeras/qtools/dnc_layer_cost_ace.py rename to qkeras/qtools/DnC/dnc_layer_cost_ace.py diff --git a/tests/qtools_model_test.py b/tests/qtools_model_test.py index 4076f612..80267f1d 100644 --- a/tests/qtools_model_test.py +++ b/tests/qtools_model_test.py @@ -38,7 +38,7 @@ from qkeras.utils import model_save_quantized_weights from qkeras.qtools.quantized_operators import adder_impl from qkeras.qtools.quantized_operators import quantizer_impl -from qkeras.qtools import divide_and_conquer +from qkeras.qtools.DnC import divide_and_conquer def qdense_model_fork():