Refresh some of our Colab notebooks. (#6162)
* Change license header style to collapsed sections (see discussion: https://github.com/google/iree/pull/5990#discussion_r643414147)
* Restore original copyright years (errant find/replace set all to 2020)
* Run notebooks
* Update for errors (e.g. swap `mhlo` op -> `std` op in low_level_invoke_function)
* Switch resnet from vmvx to llvmaot (vmvx was way too slow)
---
I did not update these notebooks:
* mnist_training.ipynb (is currently broken with a crash in `iree-import-tf`: https://github.com/google/iree/issues/6163)
* tflite_text_classification.ipynb (is currently broken from an importer change, `tosa` ops exist and no `-iree-input-type=` flag is set)
diff --git a/colab/tensorflow_hub_import.ipynb b/colab/tensorflow_hub_import.ipynb
index a4d7209..9a5b7b3 100644
--- a/colab/tensorflow_hub_import.ipynb
+++ b/colab/tensorflow_hub_import.ipynb
@@ -6,7 +6,8 @@
"name": "tensorflow_hub_import.ipynb",
"provenance": [],
"collapsed_sections": [
- "-V0X0E7LkEa4"
+ "-V0X0E7LkEa4",
+ "FH3IRpYTta2v"
]
},
"kernelspec": {
@@ -21,19 +22,27 @@
{
"cell_type": "markdown",
"metadata": {
- "id": "license"
+ "id": "FH3IRpYTta2v"
},
"source": [
- "```\n",
- "Copyright 2020 The IREE Authors\n",
- "\n",
- "Licensed under the Apache License v2.0 with LLVM Exceptions.\n",
- "See https://llvm.org/LICENSE.txt for license information.\n",
- "SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n",
- "```\n"
+ "##### Copyright 2021 The IREE Authors"
]
},
{
+ "cell_type": "code",
+ "metadata": {
+ "id": "mWGa71_Ct2ug",
+ "cellView": "form"
+ },
+ "source": [
+ "#@title Licensed under the Apache License v2.0 with LLVM Exceptions.\n",
+ "# See https://llvm.org/LICENSE.txt for license information.\n",
+ "# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception"
+ ],
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
"cell_type": "markdown",
"metadata": {
"id": "Qb3S0mSjpK7J"
@@ -70,7 +79,7 @@
"%%capture\n",
"!python -m pip install iree-compiler-snapshot iree-runtime-snapshot iree-tools-tf-snapshot -f https://github.com/google/iree/releases"
],
- "execution_count": 1,
+ "execution_count": 2,
"outputs": []
},
{
@@ -80,7 +89,7 @@
"colab": {
"base_uri": "https://localhost:8080/"
},
- "outputId": "15da7042-578c-4cc9-8c54-e1e22d4fc6f1"
+ "outputId": "31418cc7-ecd5-4c73-c595-ff1d6caf03cc"
},
"source": [
"import os\n",
@@ -98,7 +107,7 @@
"os.makedirs(ARTIFACTS_DIR, exist_ok=True)\n",
"print(f\"Using artifacts directory '{ARTIFACTS_DIR}'\")"
],
- "execution_count": 2,
+ "execution_count": 3,
"outputs": [
{
"output_type": "stream",
@@ -130,7 +139,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "7fd0vmnloZo9",
- "outputId": "71ac2d17-d7ea-4982-c3d6-f709e394a37e"
+ "outputId": "fcb260e8-672a-479d-c428-2a93d306d4b2"
},
"source": [
"#@title Download the pretrained model\n",
@@ -141,7 +150,7 @@
"model_path = hub.resolve(HUB_PATH)\n",
"print(f\"Downloaded model from tfhub to path: '{model_path}'\")"
],
- "execution_count": 3,
+ "execution_count": 4,
"outputs": [
{
"output_type": "stream",
@@ -175,7 +184,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "qiO66oEYQmsd",
- "outputId": "23dabcab-5e97-488f-a133-7614666f6609"
+ "outputId": "5d7e4f7d-e77e-45f1-c37e-11e38ed05ce2"
},
"source": [
"#@title Check for serving signatures\n",
@@ -192,7 +201,7 @@
"print(\"Checking for signature_defs using saved_model_cli:\\n\")\n",
"!saved_model_cli show --dir {model_path} --tag_set serve --signature_def serving_default"
],
- "execution_count": 4,
+ "execution_count": 5,
"outputs": [
{
"output_type": "stream",
@@ -230,7 +239,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "OlDG2OuqOBGC",
- "outputId": "0e3be224-a373-441f-cb8f-aaf2b19e0d26"
+ "outputId": "044bb741-a563-4fe2-b0d9-8b47bcc5f286"
},
"source": [
"#@title Look up input signatures to use when exporting\n",
@@ -242,7 +251,7 @@
"!saved_model_cli show --dir {model_path} --all \\\n",
" 2> /dev/null | grep \"inputs: TensorSpec\" | tail -n 1"
],
- "execution_count": 5,
+ "execution_count": 6,
"outputs": [
{
"output_type": "stream",
@@ -260,7 +269,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "gnb4HhMmkgiT",
- "outputId": "9a223ee5-cc52-4580-be88-5073a75dd97a"
+ "outputId": "3318bc8e-321c-417f-d9b0-b4cc9dcca8de"
},
"source": [
"#@title Re-export the model using the known signature\n",
@@ -290,7 +299,7 @@
"print(\"Checking for signature_defs using saved_model_cli:\\n\")\n",
"!saved_model_cli show --dir {resaved_model_path} --tag_set serve --signature_def serving_default"
],
- "execution_count": 6,
+ "execution_count": 7,
"outputs": [
{
"output_type": "stream",
@@ -336,7 +345,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "GLkjlHE5mdmg",
- "outputId": "d174d83d-350e-490e-f5e8-d4419f0c633a"
+ "outputId": "d057d2dc-001c-4fe4-cf4b-9517d4cf598e"
},
"source": [
"#@title Import from SavedModel\n",
@@ -370,7 +379,7 @@
"print(f\"Saved tf_input to '{tf_input}'\")\n",
"print(f\"Saved iree_input to '{iree_input}'\")"
],
- "execution_count": 7,
+ "execution_count": 8,
"outputs": [
{
"output_type": "stream",
@@ -391,7 +400,7 @@
"height": 102
},
"id": "IEJAzOb5qASI",
- "outputId": "3515b4ef-fd6a-4f14-ecd1-0676e246a089"
+ "outputId": "52da0e1f-a512-4ee8-ea65-e716de9a3cf2"
},
"source": [
"#@title Download compilation artifacts\n",
@@ -406,14 +415,14 @@
"print(\"Downloading the artifacts zip file...\")\n",
"files.download(ARTIFACTS_ZIP)"
],
- "execution_count": 8,
+ "execution_count": 9,
"outputs": [
{
"output_type": "stream",
"text": [
"Zipping '/tmp/iree/colab_artifacts' to '/tmp/mobilenet_colab_artifacts.zip' for download...\n",
- " adding: mobilenet_v2_iree_input.mlir (deflated 47%)\n",
" adding: mobilenet_v2.vmfb (deflated 8%)\n",
+ " adding: mobilenet_v2_iree_input.mlir (deflated 46%)\n",
" adding: mobilenet_v2_tf_input.mlir (deflated 47%)\n",
"Downloading the artifacts zip file...\n"
],
@@ -477,7 +486,7 @@
"output_type": "display_data",
"data": {
"application/javascript": [
- "download(\"download_64f7173f-1d8f-42f2-b184-0c2feb0700f4\", \"mobilenet_colab_artifacts.zip\", 43803643)"
+ "download(\"download_173f97e9-1e2d-401a-8aad-646463432451\", \"mobilenet_colab_artifacts.zip\", 59101356)"
],
"text/plain": [
"<IPython.core.display.Javascript object>"