{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-06T20:16:44.956148Z",
     "iopub.status.busy": "2023-03-06T20:16:44.956148Z",
     "iopub.status.idle": "2023-03-06T20:16:45.015963Z",
     "shell.execute_reply": "2023-03-06T20:16:45.015963Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The model is:\n",
      "ir_version: 3\n",
      "producer_name: \"backend-test\"\n",
      "graph {\n",
      "  node {\n",
      "    input: \"x\"\n",
      "    output: \"y\"\n",
      "    name: \"test\"\n",
      "    op_type: \"Relu\"\n",
      "  }\n",
      "  name: \"SingleRelu\"\n",
      "  input {\n",
      "    name: \"x\"\n",
      "    type {\n",
      "      tensor_type {\n",
      "        elem_type: 1\n",
      "        shape {\n",
      "          dim {\n",
      "            dim_value: 1\n",
      "          }\n",
      "          dim {\n",
      "            dim_value: 2\n",
      "          }\n",
      "        }\n",
      "      }\n",
      "    }\n",
      "  }\n",
      "  output {\n",
      "    name: \"y\"\n",
      "    type {\n",
      "      tensor_type {\n",
      "        elem_type: 1\n",
      "        shape {\n",
      "          dim {\n",
      "            dim_value: 1\n",
      "          }\n",
      "          dim {\n",
      "            dim_value: 2\n",
      "          }\n",
      "        }\n",
      "      }\n",
      "    }\n",
      "  }\n",
      "}\n",
      "opset_import {\n",
      "  version: 6\n",
      "}\n",
      "\n",
      "The model is valid!\n"
     ]
    }
   ],
   "source": [
    "# NBVAL_SKIP\n",
    "# Protobuf 4 and Protobuf 3 might output different order of protobuf fields\n",
    "\n",
    "import onnx\n",
    "import os\n",
    "\n",
    "\n",
    "# Preprocessing: load the ONNX model\n",
    "model_path = os.path.join(\"resources\", \"single_relu.onnx\")\n",
    "onnx_model = onnx.load(model_path)\n",
    "\n",
    "print(\"The model is:\\n{}\".format(onnx_model))\n",
    "\n",
    "# Check the model\n",
    "try:\n",
    "    onnx.checker.check_model(onnx_model)\n",
    "except onnx.checker.ValidationError as e:\n",
    "    print(\"The model is invalid: %s\" % e)\n",
    "else:\n",
    "    print(\"The model is valid!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.11"
  },
  "vscode": {
   "interpreter": {
    "hash": "f9fa6017a53cd3e89c2ae5d3938d7461048c25b2aa8e520267fca421440325a1"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
