From aba6e49b8bf43d6c3527efe2f3518fbb46dc3c66 Mon Sep 17 00:00:00 2001 From: Neta Zmora <neta.zmora@intel.com> Date: Wed, 3 Oct 2018 18:40:46 +0300 Subject: [PATCH] Jupyter notebooks: Add details to the Performance notebook Showing various details about the performance of ResNet50 --- jupyter/performance.ipynb | 87 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/jupyter/performance.ipynb b/jupyter/performance.ipynb index 29a00d5..c26a5cb 100644 --- a/jupyter/performance.ipynb +++ b/jupyter/performance.ipynb @@ -38,7 +38,7 @@ "metadata": {}, "outputs": [], "source": [ - "model = models.create_model(pretrained=False, dataset='imagenet', arch='resnet18', parallel=False)" + "model = models.create_model(pretrained=False, dataset='imagenet', arch='resnet50', parallel=False)" ] }, { @@ -56,6 +56,49 @@ "print(\"Total MACs: \" + \"{:,}\".format(total_macs))" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Let's take a look at how our compute is distibuted:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(\"MAC distribution:\")\n", + "counts = df['MACs'].value_counts()\n", + "print(counts)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Let's look at which convolutions kernel sizes we're using, and how many instances:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(\"Convolution kernel size distribution:\")\n", + "counts = df['Attrs'].value_counts()\n", + "print(counts)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Let's look at how the MACs are distributed between the layers and the convolution kernel sizes" + ] + }, { "cell_type": "code", "execution_count": null, @@ -64,11 +107,30 @@ }, "outputs": [], "source": [ + "def get_layer_color(layer_type, attrs):\n", + " if layer_type == \"Conv2d\":\n", + " if attrs == 'k=(1, 1)':\n", + " return 'tomato'\n", + " elif attrs == 'k=(3, 3)':\n", + " return 'limegreen'\n", + " else:\n", + " return 'steelblue'\n", + " return 'indigo'\n", + "\n", "df_compute = df['MACs']\n", - "ax = df_compute.plot.bar(figsize=[15,10], title=\"MACs\");\n", + "ax = df_compute.plot.bar(figsize=[15,10], title=\"MACs\", \n", + " color=[get_layer_color(layer_type, attrs) for layer_type,attrs in zip(df['Type'], df['Attrs'])])\n", + "\n", "ax.set_xticklabels(df.Name, rotation=90);" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### How do the Weights and Feature-maps footprints distribute across the layers:" + ] + }, { "cell_type": "code", "execution_count": null, @@ -81,6 +143,27 @@ "ax.set_xticklabels(df.Name, rotation=90);" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### How the Arithmetic Intensity distributes across the layers:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df_performance = df\n", + "df_performance['raw traffic'] = df_footprint['FM volume'] + df_footprint['Weights volume']\n", + "df_performance['arithmetic intensity'] = df['MACs'] / df_performance['raw traffic']\n", + "df_performance2 = df_performance['arithmetic intensity']\n", + "ax = df_performance2.plot.bar(figsize=[15,10], title=\"Arithmetic Intensity\");\n", + "ax.set_xticklabels(df.Name, rotation=90);" + ] + }, { "cell_type": "markdown", "metadata": {}, -- GitLab