{ "cells": [ { "cell_type": "markdown", "id": "da6e9cca-6893-4273-a558-3dc18d49615e", "metadata": {}, "source": [ "# Getting started with ONNX IR 🌱\n", "The ONNX IR ships with the ONNX Script package and is available as `onnx_ir`.\n", "To create an IR object from ONNX file, load it as `ModelProto` and call\n", "`ir.from_proto()`:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Define an example model for this example\n", "MODEL_TEXT = r\"\"\"\n", "<\n", " ir_version: 8,\n", " opset_import: [\"\" : 18],\n", " producer_name: \"pytorch\",\n", " producer_version: \"2.0.0\"\n", ">\n", "torch_jit (float[5,5,5] input_0) => (float[5,5] val_19, float[5,5] val_6) {\n", " val_1 = Constant <value_int: ints = [1]> ()\n", " val_2 = Shape <start: int = 0> (val_1)\n", " val_3 = Size (val_2)\n", " val_4 = Constant <value: tensor = int64 {0}> ()\n", " val_5 = Equal (val_3, val_4)\n", " val_6 = ReduceMean <keepdims: int = 0, noop_with_empty_axes: int = 0> (input_0, val_1)\n", " val_7 = ReduceMean <keepdims: int = 1, noop_with_empty_axes: int = 0> (input_0, val_1)\n", " val_8 = Shape <start: int = 0> (input_0)\n", " val_9 = Gather <axis: int = 0> (val_8, val_1)\n", " val_10 = ReduceProd <keepdims: int = 0, noop_with_empty_axes: int = 0> (val_9)\n", " val_11 = Sub (input_0, val_7)\n", " val_12 = Mul (val_11, val_11)\n", " val_13 = ReduceMean <keepdims: int = 0, noop_with_empty_axes: int = 0> (val_12, val_1)\n", " val_14 = Cast <to: int = 1> (val_10)\n", " val_15 = Mul (val_13, val_14)\n", " val_16 = Constant <value: tensor = int64 {1}> ()\n", " val_17 = Sub (val_10, val_16)\n", " val_18 = Cast <to: int = 1> (val_17)\n", " val_19 = Div (val_15, val_18)\n", "}\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": null, "id": "cb5e7520-1aba-491b-b3e9-7d013e42d4ff", "metadata": {}, "outputs": [], "source": [ "import onnx\n", "\n", "import onnx_ir as ir\n", "\n", "# Load the model as onnx.ModelProto\n", "# You can also load the model from a file using onnx.load(\"model.onnx\")\n", "model_proto = onnx.parser.parse_model(MODEL_TEXT)\n", "\n", "# Create an IR object from the model\n", "model = ir.from_proto(model_proto)" ] }, { "cell_type": "markdown", "id": "8f02f283-93c3-4e8f-b8f4-275f360ace61", "metadata": {}, "source": [ "Now we can explore the IR object" ] }, { "cell_type": "code", "execution_count": 3, "id": "969233d0-5e7a-4554-b4bc-ea06f448dd98", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The main graph has 19 nodes.\n" ] } ], "source": [ "print(f\"The main graph has {len(model.graph)} nodes.\")" ] }, { "cell_type": "markdown", "id": "0422514a-72d3-40a0-9734-c58911ddefc9", "metadata": {}, "source": [ "All inputs" ] }, { "cell_type": "code", "execution_count": 4, "id": "7b5689d8-dd2e-468f-9a87-653e97be7cf9", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Input('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None)]\n" ] } ], "source": [ "print(model.graph.inputs)" ] }, { "cell_type": "markdown", "id": "d299db39-08f9-4646-856d-74e9cb18ee8a", "metadata": {}, "source": [ "All outputs" ] }, { "cell_type": "code", "execution_count": 5, "id": "e3fb01aa-2ca5-4839-80c4-2c2d1b916a1c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Value('val_19', type=Tensor(FLOAT), shape=[5,5], producer=, index=0), Value('val_6', type=Tensor(FLOAT), shape=[5,5], producer=, index=0)]\n" ] } ], "source": [ "print(model.graph.outputs)" ] }, { "cell_type": "markdown", "id": "1c52c8a2-52b4-40f3-996a-d44488e62623", "metadata": {}, "source": [ "Nodes that uses the first input" ] }, { "cell_type": "code", "execution_count": 6, "id": "c4894e97-7a8f-4f61-86dd-dd44aced02ed", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[(Node(name='', domain='', op_type='ReduceMean', inputs=(Input('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None), Value('val_1', type=None, shape=None, producer=, index=0)), attributes=OrderedDict([('keepdims', AttrInt64('keepdims', 0)), ('noop_with_empty_axes', AttrInt64('noop_with_empty_axes', 0))]), overload='', outputs=(Value('val_6', type=Tensor(FLOAT), shape=[5,5], producer=, index=0),), version=None, doc_string=None), 0), (Node(name='', domain='', op_type='ReduceMean', inputs=(Input('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None), Value('val_1', type=None, shape=None, producer=, index=0)), attributes=OrderedDict([('keepdims', AttrInt64('keepdims', 1)), ('noop_with_empty_axes', AttrInt64('noop_with_empty_axes', 0))]), overload='', outputs=(Value('val_7', type=None, shape=None, producer=, index=0),), version=None, doc_string=None), 0), (Node(name='', domain='', op_type='Shape', inputs=(Input('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None),), attributes=OrderedDict([('start', AttrInt64('start', 0))]), overload='', outputs=(Value('val_8', type=None, shape=None, producer=, index=0),), version=None, doc_string=None), 0), (Node(name='', domain='', op_type='Sub', inputs=(Input('input_0', type=Tensor(FLOAT), shape=[5,5,5], producer=None, index=None), Value('val_7', type=None, shape=None, producer=, index=0)), attributes=OrderedDict(), overload='', outputs=(Value('val_11', type=None, shape=None, producer=, index=0),), version=None, doc_string=None), 0)]\n" ] } ], "source": [ "print(list(model.graph.inputs[0].uses()))" ] }, { "cell_type": "markdown", "id": "36d935b0-1910-4e7b-a2d8-57f6fa129670", "metadata": {}, "source": [ "The node that produces the last output (as the i-th output)" ] }, { "cell_type": "code", "execution_count": 7, "id": "ac16cc49-9c82-4d5e-9c77-f0fd6260929b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "%\"val_6\"<FLOAT,[5,5]> ⬅️ ::ReduceMean(%\"input_0\", %\"val_1\") {keepdims=0, noop_with_empty_axes=0}\n", "0\n" ] } ], "source": [ "print(model.graph.outputs[-1].producer())\n", "print(model.graph.outputs[-1].index())" ] }, { "cell_type": "markdown", "id": "d70a097f-da71-4299-bbc4-63ad3cc7be67", "metadata": {}, "source": [ "Print the graph" ] }, { "cell_type": "code", "execution_count": 9, "id": "772e831d-8d9d-4446-81ed-e119e8f2c0d6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">graph</span><span style=\"font-weight: bold\">(</span>\n", " <span style=\"color: #808000; text-decoration-color: #808000\">name</span>=<span style=\"color: #800080; text-decoration-color: #800080\">torch_jit</span>,\n", " <span style=\"color: #808000; text-decoration-color: #808000\">inputs</span>=<span style=\"font-weight: bold\">(</span>\n", " %<span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"font-weight: bold\"><</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">FLOAT</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">></span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">outputs</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_19\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">>,</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_6\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">></span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">97555281104</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Constant</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">()</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">value_int</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">97554321872</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_2\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Shape</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">start</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578494032</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_3\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Size</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_2\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578494352</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_4\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Constant</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">()</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">value</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #800080; text-decoration-color: #800080\">TensorProtoTensor</span><span style=\"color: #000000; text-decoration-color: #000000\"><INT64,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[]</span><span style=\"color: #000000; text-decoration-color: #000000\">></span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">''</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">4</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578494512</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_5\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Equal</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_3\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_4\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578494992</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_6\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ReduceMean</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">keepdims</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #808000; text-decoration-color: #808000\">noop_with_empty_axes</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">6</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578495312</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_7\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ReduceMean</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">keepdims</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #808000; text-decoration-color: #808000\">noop_with_empty_axes</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">7</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578495472</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_8\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Shape</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">start</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">8</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578495632</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_9\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Gather</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_8\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">axis</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">9</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578495952</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_10\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ReduceProd</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_9\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">keepdims</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #808000; text-decoration-color: #808000\">noop_with_empty_axes</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">10</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578496272</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_11\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Sub</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"input_0\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_7\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">11</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578496592</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_12\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Mul</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_11\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_11\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">12</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578497072</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_13\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ReduceMean</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_12\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_1\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">keepdims</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #808000; text-decoration-color: #808000\">noop_with_empty_axes</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">13</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578497712</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_14\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Cast</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_10\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">to</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">14</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578498192</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_15\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Mul</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_13\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_14\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">15</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578498672</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_16\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Constant</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">()</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">value</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #800080; text-decoration-color: #800080\">TensorProtoTensor</span><span style=\"color: #000000; text-decoration-color: #000000\"><INT64,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[]</span><span style=\"color: #000000; text-decoration-color: #000000\">></span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">''</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">16</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578498832</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_17\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Sub</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_10\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_16\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">17</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578499152</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_18\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><?,?> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Cast</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_17\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #808000; text-decoration-color: #808000\">to</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">18</span><span style=\"color: #000000; text-decoration-color: #000000\"> | # :anonymous_no</span><span style=\"color: #00ff00; text-decoration-color: #00ff00; font-weight: bold\">de:1288</span><span style=\"color: #000000; text-decoration-color: #000000\">95578499632</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_19\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">> ⬅️ ::</span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Div</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">%</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_15\"</span><span style=\"color: #000000; text-decoration-color: #000000\">, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_18\"</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span>\n", "<span style=\"color: #000000; text-decoration-color: #000000\"> return %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_19\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"color: #000000; text-decoration-color: #000000\">>, %</span><span style=\"color: #008000; text-decoration-color: #008000\">\"val_6\"</span><span style=\"color: #000000; text-decoration-color: #000000\"><FLOAT,</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000\">,</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]</span><span style=\"font-weight: bold\">></span>\n", "<span style=\"font-weight: bold\">}</span>\n", "</pre>\n" ], "text/plain": [ "\u001b[1;35mgraph\u001b[0m\u001b[1m(\u001b[0m\n", " \u001b[33mname\u001b[0m=\u001b[35mtorch_jit\u001b[0m,\n", " \u001b[33minputs\u001b[0m=\u001b[1m(\u001b[0m\n", " %\u001b[32m\"input_0\"\u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mFLOAT\u001b[0m\u001b[39m,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m,\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[33moutputs\u001b[0m\u001b[39m=\u001b[0m\u001b[1;39m(\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_19\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>,\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_6\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m,\u001b[0m\n", "\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m97555281104\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mConstant\u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mvalue_int\u001b[0m\u001b[39m=\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;39m]\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m1\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m97554321872\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_2\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mShape\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mstart\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m2\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578494032\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_3\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mSize\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_2\"\u001b[0m\u001b[1;39m)\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m3\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578494352\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_4\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mConstant\u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mvalue\u001b[0m\u001b[39m=\u001b[0m\u001b[35mTensorProtoTensor\u001b[0m\u001b[39m<INT64,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>\u001b[0m\u001b[1;39m(\u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m''\u001b[0m\u001b[1;39m)\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m4\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578494512\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_5\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mEqual\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_3\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_4\"\u001b[0m\u001b[1;39m)\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578494992\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_6\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m> ⬅️ ::\u001b[0m\u001b[1;35mReduceMean\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"input_0\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mkeepdims\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[33mnoop_with_empty_axes\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m6\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578495312\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_7\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mReduceMean\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"input_0\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mkeepdims\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[39m, \u001b[0m\u001b[33mnoop_with_empty_axes\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m7\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578495472\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_8\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mShape\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"input_0\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mstart\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m8\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578495632\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_9\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mGather\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_8\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33maxis\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m9\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578495952\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_10\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mReduceProd\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_9\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mkeepdims\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[33mnoop_with_empty_axes\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m10\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578496272\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_11\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mSub\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"input_0\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_7\"\u001b[0m\u001b[1;39m)\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m11\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578496592\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_12\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mMul\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_11\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_11\"\u001b[0m\u001b[1;39m)\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m12\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578497072\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_13\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mReduceMean\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_12\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_1\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mkeepdims\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[39m, \u001b[0m\u001b[33mnoop_with_empty_axes\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m13\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578497712\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_14\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mCast\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_10\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mto\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m14\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578498192\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_15\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mMul\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_13\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_14\"\u001b[0m\u001b[1;39m)\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m15\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578498672\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_16\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mConstant\u001b[0m\u001b[1;39m(\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mvalue\u001b[0m\u001b[39m=\u001b[0m\u001b[35mTensorProtoTensor\u001b[0m\u001b[39m<INT64,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>\u001b[0m\u001b[1;39m(\u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m''\u001b[0m\u001b[1;39m)\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m16\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578498832\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_17\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mSub\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_10\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_16\"\u001b[0m\u001b[1;39m)\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m17\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578499152\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_18\"\u001b[0m\u001b[39m<?,?> ⬅️ ::\u001b[0m\u001b[1;35mCast\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_17\"\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m \u001b[0m\u001b[1;39m{\u001b[0m\u001b[33mto\u001b[0m\u001b[39m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;39m}\u001b[0m\n", "\u001b[39m \u001b[0m\u001b[1;36m18\u001b[0m\u001b[39m | # :anonymous_no\u001b[0m\u001b[1;92mde:1288\u001b[0m\u001b[39m95578499632\u001b[0m\n", "\u001b[39m %\u001b[0m\u001b[32m\"val_19\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m> ⬅️ ::\u001b[0m\u001b[1;35mDiv\u001b[0m\u001b[1;39m(\u001b[0m\u001b[39m%\u001b[0m\u001b[32m\"val_15\"\u001b[0m\u001b[39m, %\u001b[0m\u001b[32m\"val_18\"\u001b[0m\u001b[1;39m)\u001b[0m\n", "\u001b[39m return %\u001b[0m\u001b[32m\"val_19\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[39m>, %\u001b[0m\u001b[32m\"val_6\"\u001b[0m\u001b[39m<FLOAT,\u001b[0m\u001b[1;39m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[39m,\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;39m]\u001b[0m\u001b[1m>\u001b[0m\n", "\u001b[1m}\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "model.graph.display(\n", " page=False\n", ") # Set page=True to use a pager in the terminal so long outputs are scrollable" ] }, { "cell_type": "markdown", "id": "cf19aa88-2063-4fee-9dd8-5fdca1dab398", "metadata": {}, "source": [ "Convert from the IR object back to ModelProto" ] }, { "cell_type": "code", "execution_count": 10, "id": "3b146b60-602a-4cb1-a5f8-d8d22c2a6a72", "metadata": {}, "outputs": [], "source": [ "model_proto_back = ir.to_proto(model)" ] }, { "cell_type": "markdown", "id": "85a23c5b-81b8-4a73-96e0-c8553712d46f", "metadata": {}, "source": [ "## Next steps\n", "\n", "Read the introductions for a more detailed introduction of the IR\n", "(Documentation in progress 🚧)" ] } ], "metadata": { "kernelspec": { "display_name": "onnx", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 2 }