From 61b3940950edf77797d343c0d0c202f4e269689a Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <maltanar@gmail.com> Date: Fri, 8 May 2020 00:33:26 +0100 Subject: [PATCH] [Refactor] rename Compile to CompileCppSim --- .../finn/source_code/finn.transformation.fpgadataflow.rst | 4 ++-- notebooks/advanced/1_custom_transformation_pass.ipynb | 8 ++++---- notebooks/end2end_example/tfc_end2end_verification.ipynb | 6 +++--- .../fpgadataflow/{compile.py => compile_cppsim.py} | 2 +- src/finn/transformation/fpgadataflow/prepare_cppsim.py | 2 +- tests/end2end/test_end2end_cnv_w1a1.py | 4 ++-- tests/end2end/test_end2end_tfc_w1a1_throughput_test.py | 4 ++-- tests/end2end/test_end2end_tfc_w1a2.py | 4 ++-- tests/end2end/test_end2end_tfc_w2a2.py | 4 ++-- tests/fpgadataflow/test_compilation_trafo.py | 4 ++-- tests/fpgadataflow/test_convert_to_hls_layers_cnv.py | 4 ++-- tests/fpgadataflow/test_convert_to_hls_layers_fc.py | 6 +++--- .../fpgadataflow/test_fpgadataflow_convinputgenerator.py | 4 ++-- tests/fpgadataflow/test_fpgadataflow_fclayer.py | 4 ++-- tests/fpgadataflow/test_layer_streaming_maxpool_batch.py | 4 ++-- 15 files changed, 32 insertions(+), 32 deletions(-) rename src/finn/transformation/fpgadataflow/{compile.py => compile_cppsim.py} (98%) diff --git a/docs/finn/source_code/finn.transformation.fpgadataflow.rst b/docs/finn/source_code/finn.transformation.fpgadataflow.rst index 5a6acbe39..0e0842898 100644 --- a/docs/finn/source_code/finn.transformation.fpgadataflow.rst +++ b/docs/finn/source_code/finn.transformation.fpgadataflow.rst @@ -37,10 +37,10 @@ finn.transformation.fpgadataflow.codegen\_npysim :undoc-members: :show-inheritance: -finn.transformation.fpgadataflow.compile +finn.transformation.fpgadataflow.compile_cppsim ---------------------------------------- -.. automodule:: finn.transformation.fpgadataflow.compile +.. automodule:: finn.transformation.fpgadataflow.compile_cppsim :members: :undoc-members: :show-inheritance: diff --git a/notebooks/advanced/1_custom_transformation_pass.ipynb b/notebooks/advanced/1_custom_transformation_pass.ipynb index a35786a85..3f8de434d 100644 --- a/notebooks/advanced/1_custom_transformation_pass.ipynb +++ b/notebooks/advanced/1_custom_transformation_pass.ipynb @@ -377,7 +377,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "class Compile(NodeLocalTransformation):\n", + "class CompileCppSim(NodeLocalTransformation):\n", " \"\"\"For every node: compile C++ code in node attribute \"code_gen_dir_npysim\"\n", " and save path to executables in node attribute \"executable_path\".\n", " All nodes in the graph must have the fpgadataflow backend attribute.\n", @@ -424,9 +424,9 @@ } ], "source": [ - "from finn.transformation.fpgadataflow.compile import Compile\n", + "from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim\n", "\n", - "showSrc(Compile)" + "showSrc(CompileCppSim)" ] }, { @@ -441,7 +441,7 @@ "metadata": {}, "source": [ "At the moment FINN supports parallelization for the following transformations:\n", - "* `Compile` (Compilation of the generated c++ code for each node)\n", + "* `CompileCppSim` (Compilation of the generated c++ code for each node)\n", "* `HLSSynth_IPGen` (Synthesis and ip block generation of the hls code for each node)\n", "* `PrepareRTLSim` (Creation of the files to emulate a node using PyVerilator)" ] diff --git a/notebooks/end2end_example/tfc_end2end_verification.ipynb b/notebooks/end2end_example/tfc_end2end_verification.ipynb index 4b6f98678..76950adea 100644 --- a/notebooks/end2end_example/tfc_end2end_verification.ipynb +++ b/notebooks/end2end_example/tfc_end2end_verification.ipynb @@ -220,7 +220,7 @@ "source": [ "To generate the code for this simulation and to generate the executable two transformations are used:\n", "* `PrepareCppSim` which generates the C++ code for the corresponding hls layer\n", - "* `Compile` which compules the C++ code and stores the path to the executable" + "* `CompileCppSim` which compules the C++ code and stores the path to the executable" ] }, { @@ -230,10 +230,10 @@ "outputs": [], "source": [ "from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim\n", - "from finn.transformation.fpgadataflow.compile import Compile\n", + "from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim\n", "\n", "model_for_npysim = model_for_npysim.transform(PrepareCppSim())\n", - "model_for_npysim = model_for_npysim.transform(Compile())" + "model_for_npysim = model_for_npysim.transform(CompileCppSim())" ] }, { diff --git a/src/finn/transformation/fpgadataflow/compile.py b/src/finn/transformation/fpgadataflow/compile_cppsim.py similarity index 98% rename from src/finn/transformation/fpgadataflow/compile.py rename to src/finn/transformation/fpgadataflow/compile_cppsim.py index 512c9562c..dc663b662 100644 --- a/src/finn/transformation/fpgadataflow/compile.py +++ b/src/finn/transformation/fpgadataflow/compile_cppsim.py @@ -31,7 +31,7 @@ from finn.util.fpgadataflow import is_fpgadataflow_node from finn.transformation import NodeLocalTransformation -class Compile(NodeLocalTransformation): +class CompileCppSim(NodeLocalTransformation): """For every node: compile C++ code in node attribute "code_gen_dir_npysim" and save path to executables in node attribute "executable_path". All nodes in the graph must have the fpgadataflow backend attribute. diff --git a/src/finn/transformation/fpgadataflow/prepare_cppsim.py b/src/finn/transformation/fpgadataflow/prepare_cppsim.py index a68e37bc3..5477d2fb7 100644 --- a/src/finn/transformation/fpgadataflow/prepare_cppsim.py +++ b/src/finn/transformation/fpgadataflow/prepare_cppsim.py @@ -64,7 +64,7 @@ class PrepareCppSim(Transformation): Outcome if succesful: Node attribute "code_gen_dir_npysim" contains path to folder that contains generated C++ code that can be used to simulate node using npysim. - The subsequent transformation is Compile""" + The subsequent transformation is CompileCppSim""" def apply(self, model): for node in model.graph.node: diff --git a/tests/end2end/test_end2end_cnv_w1a1.py b/tests/end2end/test_end2end_cnv_w1a1.py index 536b1bb6b..802dd5acd 100644 --- a/tests/end2end/test_end2end_cnv_w1a1.py +++ b/tests/end2end/test_end2end_cnv_w1a1.py @@ -63,7 +63,7 @@ from finn.transformation.fpgadataflow.replace_verilog_relpaths import ( from finn.transformation.fpgadataflow.create_stitched_ip import CreateStitchedIP from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim from finn.transformation.fpgadataflow.make_pynq_driver import MakePYNQDriver from finn.transformation.fpgadataflow.make_pynq_proj import MakePYNQProject from finn.transformation.fpgadataflow.synth_pynq_proj import SynthPYNQProject @@ -190,7 +190,7 @@ def test_end2end_cnv_w1a1_verify_dataflow_part(): inp_dict = {inp_name: x} # npysim model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) model = model.transform(SetExecMode("npysim")) model.save(build_dir + "/end2end_cnv_w1a1_ipgen_npysim.onnx") ret_npysim = execute_onnx(model, inp_dict, True) diff --git a/tests/end2end/test_end2end_tfc_w1a1_throughput_test.py b/tests/end2end/test_end2end_tfc_w1a1_throughput_test.py index d73f79678..1829b9a9d 100644 --- a/tests/end2end/test_end2end_tfc_w1a1_throughput_test.py +++ b/tests/end2end/test_end2end_tfc_w1a1_throughput_test.py @@ -49,7 +49,7 @@ from finn.transformation.fold_constants import FoldConstants from finn.transformation.fpgadataflow.codegen_ipgen import CodeGen_ipgen from finn.transformation.fpgadataflow.create_stitched_ip import CreateStitchedIP from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim from finn.transformation.fpgadataflow.create_dataflow_partition import ( CreateDataflowPartition, ) @@ -176,7 +176,7 @@ def test_end2end_tfc_w1a1_verify_dataflow_part(): inp_dict = {inp_name: x} # npysim model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) model = model.transform(SetExecMode("npysim")) model.save(build_dir + "/end2end_tfc_w1a1_ipstitch_npysim.onnx") ret_npysim = execute_onnx(model, inp_dict, True) diff --git a/tests/end2end/test_end2end_tfc_w1a2.py b/tests/end2end/test_end2end_tfc_w1a2.py index e04c2866c..e8ce5612b 100644 --- a/tests/end2end/test_end2end_tfc_w1a2.py +++ b/tests/end2end/test_end2end_tfc_w1a2.py @@ -46,7 +46,7 @@ from finn.transformation.fold_constants import FoldConstants from finn.transformation.fpgadataflow.codegen_ipgen import CodeGen_ipgen from finn.transformation.fpgadataflow.create_stitched_ip import CreateStitchedIP from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim from finn.transformation.fpgadataflow.create_dataflow_partition import ( CreateDataflowPartition, ) @@ -168,7 +168,7 @@ def test_end2end_tfc_w1a2_verify_dataflow_part(): inp_dict = {inp_name: x} # npysim model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) model = model.transform(SetExecMode("npysim")) model.save(build_dir + "/end2end_tfc_w1a2_ipstitch_npysim.onnx") ret_npysim = execute_onnx(model, inp_dict, True) diff --git a/tests/end2end/test_end2end_tfc_w2a2.py b/tests/end2end/test_end2end_tfc_w2a2.py index 07ea53569..cef14862b 100644 --- a/tests/end2end/test_end2end_tfc_w2a2.py +++ b/tests/end2end/test_end2end_tfc_w2a2.py @@ -46,7 +46,7 @@ from finn.transformation.fold_constants import FoldConstants from finn.transformation.fpgadataflow.codegen_ipgen import CodeGen_ipgen from finn.transformation.fpgadataflow.create_stitched_ip import CreateStitchedIP from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim from finn.transformation.fpgadataflow.create_dataflow_partition import ( CreateDataflowPartition, ) @@ -168,7 +168,7 @@ def test_end2end_tfc_w2a2_verify_dataflow_part(): inp_dict = {inp_name: x} # npysim model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) model = model.transform(SetExecMode("npysim")) model.save(build_dir + "/end2end_tfc_w2a2_ipstitch_npysim.onnx") ret_npysim = execute_onnx(model, inp_dict, True) diff --git a/tests/fpgadataflow/test_compilation_trafo.py b/tests/fpgadataflow/test_compilation_trafo.py index 42f4bfc84..35eed02f4 100644 --- a/tests/fpgadataflow/test_compilation_trafo.py +++ b/tests/fpgadataflow/test_compilation_trafo.py @@ -34,7 +34,7 @@ import finn.util.basic as util from finn.core.datatype import DataType from finn.core.modelwrapper import ModelWrapper from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim def test_compilation_trafo(): @@ -79,7 +79,7 @@ def test_compilation_trafo(): model.set_initializer("weights", W) model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) for node in model.graph.node: compilation_attribute = util.get_by_name(node.attribute, "executable_path") executable = compilation_attribute.s.decode("UTF-8") diff --git a/tests/fpgadataflow/test_convert_to_hls_layers_cnv.py b/tests/fpgadataflow/test_convert_to_hls_layers_cnv.py index 273ebc952..de0cf55af 100644 --- a/tests/fpgadataflow/test_convert_to_hls_layers_cnv.py +++ b/tests/fpgadataflow/test_convert_to_hls_layers_cnv.py @@ -46,7 +46,7 @@ from finn.transformation.lower_convs_to_matmul import LowerConvsToMatMul from finn.transformation.bipolar_to_xnor import ConvertBipolarMatMulToXnorPopcount import finn.transformation.fpgadataflow.convert_to_hls_layers as to_hls from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode from finn.custom_op.registry import getCustomOp @@ -114,7 +114,7 @@ def test_convert_to_hls_layers_cnv_w1a1(): assert len(mp_nodes) == 2 # model.save("cnv-pre-compile.onnx") model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) model = model.transform(SetExecMode("npysim")) # model.save("cnv-post-compile.onnx") produced_ctx = oxe.execute_onnx(model, input_dict, True) diff --git a/tests/fpgadataflow/test_convert_to_hls_layers_fc.py b/tests/fpgadataflow/test_convert_to_hls_layers_fc.py index 7b18e8585..04af69077 100644 --- a/tests/fpgadataflow/test_convert_to_hls_layers_fc.py +++ b/tests/fpgadataflow/test_convert_to_hls_layers_fc.py @@ -43,7 +43,7 @@ from finn.custom_op.registry import getCustomOp from finn.transformation.bipolar_to_xnor import ConvertBipolarMatMulToXnorPopcount from finn.transformation.fold_constants import FoldConstants from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode from finn.transformation.general import GiveReadableTensorNames, GiveUniqueNodeNames from finn.transformation.infer_shapes import InferShapes @@ -108,7 +108,7 @@ def test_convert_to_hls_layers_tfc_w1a1(): fc3w.set_nodeattr("PE", 10) model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) model = model.transform(SetExecMode("npysim")) raw_i = get_data("finn", "data/onnx/mnist-conv/test_data_set_0/input_0.pb") @@ -172,7 +172,7 @@ def test_convert_to_hls_layers_tfc_w1a2(): fc3w.set_nodeattr("SIMD", 16) fc3w.set_nodeattr("PE", 10) model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) model = model.transform(SetExecMode("npysim")) raw_i = get_data("finn", "data/onnx/mnist-conv/test_data_set_0/input_0.pb") input_tensor = onnx.load_tensor_from_string(raw_i) diff --git a/tests/fpgadataflow/test_fpgadataflow_convinputgenerator.py b/tests/fpgadataflow/test_fpgadataflow_convinputgenerator.py index 68421d67d..99a69990b 100644 --- a/tests/fpgadataflow/test_fpgadataflow_convinputgenerator.py +++ b/tests/fpgadataflow/test_fpgadataflow_convinputgenerator.py @@ -35,7 +35,7 @@ from finn.core.datatype import DataType from finn.core.modelwrapper import ModelWrapper from finn.transformation.fpgadataflow.codegen_ipgen import CodeGen_ipgen from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim from finn.transformation.fpgadataflow.hlssynth_ipgen import HLSSynth_IPGen from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode from finn.transformation.fpgadataflow.prepare_rtlsim import PrepareRTLSim @@ -148,7 +148,7 @@ def test_fpgadataflow_slidingwindow(idt, k, ifm_dim, ifm_ch, stride, exec_mode, if exec_mode == "npysim": model = model.transform(SetExecMode("npysim")) model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) elif exec_mode == "rtlsim": model = model.transform(SetExecMode("rtlsim")) model = model.transform(GiveUniqueNodeNames()) diff --git a/tests/fpgadataflow/test_fpgadataflow_fclayer.py b/tests/fpgadataflow/test_fpgadataflow_fclayer.py index 75ebf80e2..bcee86264 100644 --- a/tests/fpgadataflow/test_fpgadataflow_fclayer.py +++ b/tests/fpgadataflow/test_fpgadataflow_fclayer.py @@ -40,7 +40,7 @@ from finn.core.modelwrapper import ModelWrapper from finn.custom_op.multithreshold import multithreshold from finn.transformation.fpgadataflow.codegen_ipgen import CodeGen_ipgen from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim from finn.transformation.fpgadataflow.hlssynth_ipgen import HLSSynth_IPGen from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode from finn.transformation.general import GiveUniqueNodeNames @@ -192,7 +192,7 @@ def test_fpgadataflow_fclayer_npysim(mem_mode, idt, wdt, act, nf, sf, mw, mh): inst.set_nodeattr("mem_mode", mem_mode) model = model.transform(SetExecMode("npysim")) model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) # prepare input data input_dict = prepare_inputs(x, idt, wdt) if wdt == DataType.BIPOLAR and idt == DataType.BIPOLAR: diff --git a/tests/fpgadataflow/test_layer_streaming_maxpool_batch.py b/tests/fpgadataflow/test_layer_streaming_maxpool_batch.py index 0e470a751..79a7cca30 100644 --- a/tests/fpgadataflow/test_layer_streaming_maxpool_batch.py +++ b/tests/fpgadataflow/test_layer_streaming_maxpool_batch.py @@ -35,7 +35,7 @@ from finn.core.datatype import DataType from finn.core.modelwrapper import ModelWrapper from finn.transformation.fpgadataflow.codegen_ipgen import CodeGen_ipgen from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim -from finn.transformation.fpgadataflow.compile import Compile +from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim from finn.transformation.fpgadataflow.hlssynth_ipgen import HLSSynth_IPGen from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode from finn.transformation.fpgadataflow.prepare_rtlsim import PrepareRTLSim @@ -139,7 +139,7 @@ def test_fpgadataflow_streamingmaxpool(idt, k, ifm_dim, ifm_ch, exec_mode): if exec_mode == "npysim": model = model.transform(SetExecMode("npysim")) model = model.transform(PrepareCppSim()) - model = model.transform(Compile()) + model = model.transform(CompileCppSim()) elif exec_mode == "rtlsim": model = model.transform(SetExecMode("rtlsim")) model = model.transform(GiveUniqueNodeNames()) -- GitLab