{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "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"
     ]
    }
   ],
   "source": [
    "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))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The model is valid!\n"
     ]
    }
   ],
   "source": [
    "# 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!\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
