From c124579451c11bed265132e012cd89ffc798d325 Mon Sep 17 00:00:00 2001 From: Michal Danilowicz Date: Mon, 15 Jul 2024 14:31:12 +0000 Subject: [PATCH] pre-commit applied Signed-off-by: Michal Danilowicz --- src/finn/qnn-data/templates/driver/driver_base.py | 2 +- src/finn/qnn-data/templates/driver/validate.py | 2 +- src/finn/transformation/fpgadataflow/make_pynq_driver.py | 4 +++- tests/end2end/test_ext_weights.py | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/finn/qnn-data/templates/driver/driver_base.py b/src/finn/qnn-data/templates/driver/driver_base.py index 9a5eb60af7..88ec644f3b 100644 --- a/src/finn/qnn-data/templates/driver/driver_base.py +++ b/src/finn/qnn-data/templates/driver/driver_base.py @@ -145,7 +145,7 @@ def load_external_weights(self): # weight_buf.sync_to_device() weight_buf.flush() - input_shape = self._io_shape_dict['external_weights_input_shapes'][idma_name] + input_shape = self._io_shape_dict["external_weights_input_shapes"][idma_name] # NHWC input? if len(input_shape) == 4: num_repeats = input_shape[1] * input_shape[2] diff --git a/src/finn/qnn-data/templates/driver/validate.py b/src/finn/qnn-data/templates/driver/validate.py index eac23b0f10..342c9a3ac3 100644 --- a/src/finn/qnn-data/templates/driver/validate.py +++ b/src/finn/qnn-data/templates/driver/validate.py @@ -100,7 +100,7 @@ driver.copy_output_data_from_device(obuf_normal) batch_ok = (obuf_normal.flatten() == exp.flatten()).sum() ok += batch_ok - nok += (bsize - batch_ok) + nok += bsize - batch_ok print("batch %d / %d : total OK %d NOK %d" % (i + 1, n_batches, ok, nok)) acc = 100.0 * ok / (total) diff --git a/src/finn/transformation/fpgadataflow/make_pynq_driver.py b/src/finn/transformation/fpgadataflow/make_pynq_driver.py index a1bc62804e..d61046c586 100644 --- a/src/finn/transformation/fpgadataflow/make_pynq_driver.py +++ b/src/finn/transformation/fpgadataflow/make_pynq_driver.py @@ -242,7 +242,9 @@ def apply(self, model): dma_target_model = ModelWrapper(dma_target_sdp.get_nodeattr("model")) iodma_output_tensor = iodma_node.onnx_node.output[0] dma_consumer = dma_target_model.find_consumer(iodma_output_tensor) - ext_weight_shapes_dict[idma_name] = dma_target_model.get_tensor_shape(dma_consumer.output[0]) + ext_weight_shapes_dict[idma_name] = dma_target_model.get_tensor_shape( + dma_consumer.output[0] + ) init_tensor = df_model.get_initializer(iodma_node.onnx_node.input[0]) ext_weight_dma_cnt += 1 diff --git a/tests/end2end/test_ext_weights.py b/tests/end2end/test_ext_weights.py index b1cd930617..49bd1b326a 100644 --- a/tests/end2end/test_ext_weights.py +++ b/tests/end2end/test_ext_weights.py @@ -29,11 +29,11 @@ import pytest +import json import os import shutil import subprocess import wget -import json import finn.builder.build_dataflow as build import finn.builder.build_dataflow_config as build_cfg @@ -67,7 +67,7 @@ def get_checkpoint_name(step, topology): else: # other checkpoints are onnx files return build_dir + "/end2end_" + topology + "_ext_weights_%s.onnx" % (step) - + def verify_runtime_weights(folding_config_file, runtime_weights_dir): with open(folding_config_file) as file: @@ -79,7 +79,7 @@ def verify_runtime_weights(folding_config_file, runtime_weights_dir): num_ext_weights += 1 runtime_weights_files = os.listdir(runtime_weights_dir) for idx in range(num_ext_weights): - expected_file = 'idma{}.npy'.format(idx) + expected_file = "idma{}.npy".format(idx) assert expected_file in runtime_weights_files