diff --git a/notebooks/9-FINN-EndToEndFlow.ipynb b/notebooks/9-FINN-EndToEndFlow.ipynb index 39f5177fd8398efc5961a7e2492e958092c6ad71..6d1360aace7fed6a7c08ca385d37e7f2ffd85042 100644 --- a/notebooks/9-FINN-EndToEndFlow.ipynb +++ b/notebooks/9-FINN-EndToEndFlow.ipynb @@ -13,7 +13,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -309,10 +309,53 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "class Streamline(Transformation):\n", + " \"\"\"Apply the streamlining transform, see arXiv:1709.04060.\"\"\"\n", + "\n", + " def apply(self, model):\n", + " streamline_transformations = [\n", + " ConvertSubToAdd(),\n", + " BatchNormToAffine(),\n", + " ConvertSignToThres(),\n", + " MoveScalarAddPastMatMul(),\n", + " MoveScalarMulPastMatMul(),\n", + " MoveAddPastMul(),\n", + " CollapseRepeatedAdd(),\n", + " CollapseRepeatedMul(),\n", + " AbsorbAddIntoMultiThreshold(),\n", + " FactorOutMulSignMagnitude(),\n", + " AbsorbMulIntoMultiThreshold(),\n", + " Absorb1BitMulIntoMatMul(),\n", + " RoundAndClipThresholds(),\n", + " ]\n", + " for trn in streamline_transformations:\n", + " model = model.transform(trn)\n", + " model = model.transform(GiveUniqueNodeNames())\n", + " model = model.transform(GiveReadableTensorNames())\n", + " model = model.transform(InferDataTypes())\n", + " return (model, False)\n", + "\n" + ] + } + ], + "source": [ + "from finn.transformation.streamline import Streamline\n", + "showSrc(Streamline)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As can be seen, several transformations are involved in the streamlining transformation. There are move and collapse transformations. In the last step the operations are transformed into multithresholds. The involved transformations can be viewed in detail [here](https://github.com/Xilinx/finn/tree/dev/src/finn/transformation/streamline). After each transformation, three of the basic transformations (`GiveUniqueNodeNames`, `GiveReadableTensorNames` and `InferDataTypes`) are applied to the model as clean up." + ] }, { "cell_type": "markdown",