{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-10-05T04:27:58.407132Z","iopub.execute_input":"2023-10-05T04:27:58.407913Z","iopub.status.idle":"2023-10-05T04:27:58.854954Z","shell.execute_reply.started":"2023-10-05T04:27:58.407874Z","shell.execute_reply":"2023-10-05T04:27:58.853841Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### dataset\n- https://github.com/google-research-datasets/tpu_graphs#dataset","metadata":{}},{"cell_type":"code","source":"!curl https://raw.githubusercontent.com/google-research-datasets/tpu_graphs/main/echo_download_commands.py | python | bash","metadata":{"execution":{"iopub.status.busy":"2023-10-05T04:40:47.201585Z","iopub.execute_input":"2023-10-05T04:40:47.202022Z","iopub.status.idle":"2023-10-05T04:45:00.732524Z","shell.execute_reply.started":"2023-10-05T04:40:47.201990Z","shell.execute_reply":"2023-10-05T04:45:00.730469Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Load the NPZ archive\narchive = np.load(\"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/random/train/albert_en_base_batch_size_32_test.npz\")\nprint(archive.files)","metadata":{"execution":{"iopub.status.busy":"2023-10-05T04:38:26.853655Z","iopub.execute_input":"2023-10-05T04:38:26.854082Z","iopub.status.idle":"2023-10-05T04:38:26.881441Z","shell.execute_reply.started":"2023-10-05T04:38:26.854048Z","shell.execute_reply":"2023-10-05T04:38:26.880553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"archive = np.load(\"/kaggle/input/predict-ai-model-runtime/npz_all/npz/tile/xla/test/0070642211d5a98a16b94f4d7df229fe.npz\")\nprint(archive.files)","metadata":{"execution":{"iopub.status.busy":"2023-10-05T05:15:01.327552Z","iopub.execute_input":"2023-10-05T05:15:01.328152Z","iopub.status.idle":"2023-10-05T05:15:01.338391Z","shell.execute_reply.started":"2023-10-05T05:15:01.328097Z","shell.execute_reply":"2023-10-05T05:15:01.337452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\n\ntry:\n    archive = np.load(\"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/random/train/albert_en_base_batch_size_32_test.npz\")\n\n    value = archive[\"node_config_ids\"]\nexcept KeyError:\n    print(\"The key 'node_config_ids' does not exist in the archive.\")\n","metadata":{"execution":{"iopub.status.busy":"2023-10-05T04:39:49.471440Z","iopub.execute_input":"2023-10-05T04:39:49.472105Z","iopub.status.idle":"2023-10-05T04:39:49.489773Z","shell.execute_reply.started":"2023-10-05T04:39:49.472057Z","shell.execute_reply":"2023-10-05T04:39:49.488664Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install torch_geometric","metadata":{"execution":{"iopub.status.busy":"2023-10-05T04:55:13.921347Z","iopub.execute_input":"2023-10-05T04:55:13.921801Z","iopub.status.idle":"2023-10-05T04:55:39.624600Z","shell.execute_reply.started":"2023-10-05T04:55:13.921768Z","shell.execute_reply":"2023-10-05T04:55:39.622934Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\ndata1 = np.load('/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_base_batch_size_32_test.npz')\ndata2 = np.load('/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/test/23559853d9702baaaacbb0c83fd32266.npz')\ndata3 = np.load('/kaggle/input/predict-ai-model-runtime/npz_all/npz/tile/xla/train/alexnet_train_batch_32_-282ddd3271de7d28.npz')\ndata4 = np.load('/kaggle/input/predict-ai-model-runtime/npz_all/npz/tile/xla/test/0070642211d5a98a16b94f4d7df229fe.npz')\n\n# Extract arrays to plot\narray1 = data1.get('node_splits')\narray2 = data2.get('config_runtime')\narray3 = data3.get('node_feat')\narray4 = data4.get('config_runtime_normalizers')\n\nplt.plot(array1, label='Array 1')\nplt.plot(array2, label='Array 2')\nplt.plot(array3, label='Array 3')\nplt.plot(array4, label='Array 4')\n\nplt.xlabel('x-axis')\nplt.ylabel('y-axis')\nplt.title('Plot')\n\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-10-05T05:16:00.306267Z","iopub.execute_input":"2023-10-05T05:16:00.306745Z","iopub.status.idle":"2023-10-05T05:16:00.667392Z","shell.execute_reply.started":"2023-10-05T05:16:00.306708Z","shell.execute_reply":"2023-10-05T05:16:00.665927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# \"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_base_batch_size_32_test.npz\",\n# \"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_base_batch_size_64_train.npz\", \n# \"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_large_batch_size_16_train.npz\"\n","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"archive1 = np.load(\"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_base_batch_size_32_test.npz\")\nprint(archive1.files)\narchive2 = np.load(\"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_base_batch_size_64_train.npz\")\nprint(archive2.files)\narchive2 = np.load(\"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_large_batch_size_16_train.npz\")\nprint(archive2.files)","metadata":{"execution":{"iopub.status.busy":"2023-10-05T05:32:13.348918Z","iopub.execute_input":"2023-10-05T05:32:13.349480Z","iopub.status.idle":"2023-10-05T05:32:13.369089Z","shell.execute_reply.started":"2023-10-05T05:32:13.349438Z","shell.execute_reply":"2023-10-05T05:32:13.367888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport matplotlib.animation as animation\n\nfiles = [\"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_base_batch_size_32_test.npz\", \"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_base_batch_size_64_train.npz\", \"/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_large_batch_size_16_train.npz\"]\ndata = []\nfor file in files:\n    data.append(np.load(file))","metadata":{"execution":{"iopub.status.busy":"2023-10-05T05:36:27.308170Z","iopub.execute_input":"2023-10-05T05:36:27.308666Z","iopub.status.idle":"2023-10-05T05:36:27.324477Z","shell.execute_reply.started":"2023-10-05T05:36:27.308627Z","shell.execute_reply":"2023-10-05T05:36:27.323181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plot_data(data):\n    x = data[\"node_config_feat\"]\n    y = data[\"config_runtime\"]\n\n    plt.plot(x, y, label=file)\n\n    plt.xlabel(\"node_config_feat\")\n    plt.ylabel(\"config_runtime\")\n\n    plt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-10-05T05:37:20.009330Z","iopub.execute_input":"2023-10-05T05:37:20.009856Z","iopub.status.idle":"2023-10-05T05:37:20.016574Z","shell.execute_reply.started":"2023-10-05T05:37:20.009819Z","shell.execute_reply":"2023-10-05T05:37:20.015523Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plot_data(data):\n    fig = plt.figure()\n\n    # axes object\n    ax = fig.add_subplot(111)\n\n    # line object for each .npz file\n    lines = []\n    for file in data:\n        lines.append(ax.plot([], [], label=file)[0])\n\n    # function to update the plot\n    def update(i):\n        for i, line in enumerate(lines):\n            line.set_data(data[i][\"x\"], data[i][\"y\"])\n\n        ax.set_xlim(0, 10)\n        ax.set_ylim(0, 10)\n\n        # Redraw the plot\n        fig.canvas.draw()\n\n    # Create an animation object\n    anim = animation.FuncAnimation(fig, update, interval=100)\n\n    plt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-10-05T05:37:27.083132Z","iopub.execute_input":"2023-10-05T05:37:27.083606Z","iopub.status.idle":"2023-10-05T05:37:27.091974Z","shell.execute_reply.started":"2023-10-05T05:37:27.083569Z","shell.execute_reply":"2023-10-05T05:37:27.090376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data(data)\n","metadata":{"execution":{"iopub.status.busy":"2023-10-05T05:37:33.728908Z","iopub.execute_input":"2023-10-05T05:37:33.729498Z","iopub.status.idle":"2023-10-05T05:37:33.947571Z","shell.execute_reply.started":"2023-10-05T05:37:33.729453Z","shell.execute_reply":"2023-10-05T05:37:33.946104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import numpy as np\n# import matplotlib.pyplot as plt\n\n# with np.load('/kaggle/input/predict-ai-model-runtime/npz_all/npz/layout/nlp/default/train/albert_en_base_batch_size_32_test.npz') as data:\n#     array1 = data['node_opcode']\n#     array2 = data['config_runtime']\n\n# # mean and standard deviation of the arrays\n# mean_array1 = np.mean(array1)\n# std_array1 = np.std(array1)\n# mean_array2 = np.mean(array2)\n# std_array2 = np.std(array2)\n\n# # correlation coefficient between arrays\n# corr_coef = np.corrcoef(array1, array2)[0, 1]\n\n# print('Mean of array1:', mean_array1)\n# print('Standard deviation of array1:', std_array1)\n# print('Mean of array2:', mean_array2)\n# print('Standard deviation of array2:', std_array2)\n# print('Correlation coefficient between array1 and array2:', corr_coef)\n\n# # Create a scatter plot of array1 vs. array2\n# plt.scatter(array1, array2)\n# plt.xlabel('Array 1')\n# plt.ylabel('Array 2')\n# plt.title('Plot of Array 1 vs. Array 2')\n# plt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-10-05T05:42:03.768842Z","iopub.execute_input":"2023-10-05T05:42:03.769264Z","iopub.status.idle":"2023-10-05T05:42:03.775736Z","shell.execute_reply.started":"2023-10-05T05:42:03.769233Z","shell.execute_reply":"2023-10-05T05:42:03.774241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}