{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# TVM 初探" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "\n", "# 载入自定义模块\n", "from mod import torchq\n", "\n", "import set_env" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from torch import nn, jit\n", "from torchvision.models import quantization as qmodels\n", "from torch.ao.quantization import get_default_qat_qconfig" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "def create_model(model_name='resnet18',\n", " quantize=False,\n", " pretrained=True):\n", " '''定义模型'''\n", " mod = getattr(qmodels, model_name)\n", " return mod(pretrained=pretrained,\n", " quantize=quantize)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# 设置 warnings\n", "import warnings\n", "warnings.filterwarnings(\n", " action='ignore',\n", " category=DeprecationWarning,\n", " module='.*'\n", ")\n", "warnings.filterwarnings(\n", " action='ignore',\n", " module='torch.ao.quantization'\n", ")\n", "# 载入自定义模块\n", "from mod import torchq\n", "\n", "from torchq.helper import evaluate, print_size_of_model, load_model\n", "\n", "def print_info(model, model_type, criterion, test_iter):\n", " '''打印信息'''\n", " num_eval = len(test_iter)\n", " print_size_of_model(model)\n", " top1, top5 = evaluate(model, criterion, test_iter)\n", " print(f'\\n{model_type}:\\n\\t'\n", " f'在 {num_eval} 批次图片上评估 accuracy 为: {top1.avg:2.5f}')\n", " return top1, top5" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from utils.loader import get_val_loader\n", "\n", "saved_model_dir = 'models/'\n", "model_name = 'resnet18'\n", "float_model_file = f'{model_name}_pretrained_float.pth'\n", "float_model_path = saved_model_dir + float_model_file\n", "batch_size = 8\n", "\n", "val_loader = get_val_loader(batch_size)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "模型大小:46.837645 MB\n", "Batch 0 ~ Acc@1 75.00 ( 75.00)\t Acc@5 100.00 (100.00)\n", "Batch 500 ~ Acc@1 100.00 ( 74.28)\t Acc@5 100.00 ( 91.89)\n", "Batch 1000 ~ Acc@1 75.00 ( 77.78)\t Acc@5 87.50 ( 92.87)\n", "Batch 1500 ~ Acc@1 0.00 ( 75.97)\t Acc@5 100.00 ( 93.03)\n", "Batch 2000 ~ Acc@1 87.50 ( 75.61)\t Acc@5 100.00 ( 93.35)\n", "Batch 2500 ~ Acc@1 50.00 ( 76.28)\t Acc@5 87.50 ( 93.47)\n", "Batch 3000 ~ Acc@1 50.00 ( 74.50)\t Acc@5 75.00 ( 92.22)\n", "Batch 3500 ~ Acc@1 100.00 ( 72.89)\t Acc@5 100.00 ( 91.26)\n", "Batch 4000 ~ Acc@1 87.50 ( 72.02)\t Acc@5 87.50 ( 90.55)\n", "Batch 4500 ~ Acc@1 50.00 ( 71.30)\t Acc@5 75.00 ( 90.17)\n", "Batch 5000 ~ Acc@1 87.50 ( 70.59)\t Acc@5 87.50 ( 89.57)\n", "Batch 5500 ~ Acc@1 87.50 ( 69.91)\t Acc@5 87.50 ( 89.13)\n", "Batch 6000 ~ Acc@1 75.00 ( 69.82)\t Acc@5 100.00 ( 89.07)\n", "\n", "浮点模型:\n", "\t在 6250 批次图片上评估 accuracy 为: 69.76000\n" ] } ], "source": [ "backend = 'fbgemm'\n", "\n", "qat_model = create_model(model_name, quantize=False)\n", "qat_model.fuse_model()\n", "qat_model.qconfig = get_default_qat_qconfig(backend=backend)\n", "model_type = '浮点模型'\n", "criterion = nn.CrossEntropyLoss(reduction=\"none\")\n", "top1, top5 = print_info(qat_model, model_type, criterion, val_loader)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(tensor(69.7600), tensor(89.0820))" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "top1.avg, top5.avg" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "模型大小:11.838625 MB\n", "Batch 0 ~ Acc@1 75.00 ( 75.00)\t Acc@5 100.00 (100.00)\n", "Batch 500 ~ Acc@1 100.00 ( 74.23)\t Acc@5 100.00 ( 92.02)\n", "Batch 1000 ~ Acc@1 75.00 ( 77.68)\t Acc@5 87.50 ( 93.01)\n", "Batch 1500 ~ Acc@1 0.00 ( 75.77)\t Acc@5 100.00 ( 93.12)\n", "Batch 2000 ~ Acc@1 87.50 ( 75.32)\t Acc@5 100.00 ( 93.35)\n", "Batch 2500 ~ Acc@1 50.00 ( 75.97)\t Acc@5 75.00 ( 93.43)\n", "Batch 3000 ~ Acc@1 62.50 ( 74.21)\t Acc@5 87.50 ( 92.13)\n", "Batch 3500 ~ Acc@1 100.00 ( 72.59)\t Acc@5 100.00 ( 91.12)\n", "Batch 4000 ~ Acc@1 75.00 ( 71.76)\t Acc@5 87.50 ( 90.46)\n", "Batch 4500 ~ Acc@1 50.00 ( 71.03)\t Acc@5 75.00 ( 90.05)\n", "Batch 5000 ~ Acc@1 87.50 ( 70.31)\t Acc@5 87.50 ( 89.46)\n", "Batch 5500 ~ Acc@1 87.50 ( 69.66)\t Acc@5 87.50 ( 89.01)\n", "Batch 6000 ~ Acc@1 87.50 ( 69.58)\t Acc@5 100.00 ( 88.90)\n", "\n", "浮点模型:\n", "\t在 6250 批次图片上评估 accuracy 为: 69.48800\n" ] } ], "source": [ "backend = 'fbgemm'\n", "\n", "qat_model = create_model(model_name, quantize=True)\n", "# qat_model.fuse_model()\n", "# qat_model.qconfig = get_default_qat_qconfig(backend=backend)\n", "model_type = '浮点模型'\n", "criterion = nn.CrossEntropyLoss(reduction=\"none\")\n", "top1, top5 = print_info(qat_model, model_type, criterion, val_loader)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "tensor(69.4880) tensor(88.9000)\n" ] } ], "source": [ "print(top1.avg, top5.avg)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "torch.qint8" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "qat_model.conv1.weight().dtype" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "scripted_qat_model_file = 'qat_resnet18.pth'\n", "jit.save(jit.script(qat_model), saved_model_dir + scripted_qat_model_file)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "from torchvision.models import quantization" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from torch import jit\n", "import torch" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "scripted_qat_model_file = '/media/pc/data/4tb/lxw/work/torch-quantization/docs/tutorial/models/mobilenet_qat_scripted_quantized.pth'\n", "m = jit.load(scripted_qat_model_file)" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [], "source": [ "input_shape = 1, 3, 224, 224\n", "input_data = torch.randn(input_shape)\n", "# scripted_model = jit.trace(m, input_data).eval()\n", "y = m(input_data)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "RecursiveScriptModule(\n", " original_name=QuantizableMobileNetV2\n", " (features): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(original_name=Conv2d)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (2): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (3): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (4): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (5): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (6): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (7): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (8): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (9): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (10): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (11): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (12): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (13): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (14): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (15): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (16): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (17): RecursiveScriptModule(\n", " original_name=QuantizableInvertedResidual\n", " (conv): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (1): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (2): RecursiveScriptModule(original_name=Conv2d)\n", " (3): RecursiveScriptModule(original_name=Identity)\n", " )\n", " (skip_add): RecursiveScriptModule(\n", " original_name=QFunctional\n", " (activation_post_process): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (18): RecursiveScriptModule(\n", " original_name=ConvNormActivation\n", " (0): RecursiveScriptModule(original_name=ConvReLU2d)\n", " (1): RecursiveScriptModule(original_name=Identity)\n", " (2): RecursiveScriptModule(original_name=Identity)\n", " )\n", " )\n", " (classifier): RecursiveScriptModule(\n", " original_name=Sequential\n", " (0): RecursiveScriptModule(original_name=Dropout)\n", " (1): RecursiveScriptModule(\n", " original_name=Linear\n", " (_packed_params): RecursiveScriptModule(original_name=LinearPackedParams)\n", " )\n", " )\n", " (quant): RecursiveScriptModule(original_name=Quantize)\n", " (dequant): RecursiveScriptModule(original_name=DeQuantize)\n", ")" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "interpreter": { "hash": "ccd751c8c176f1a7084878738c6c59984a17d1189ffe2fae146e3d74e2010826" }, "kernelspec": { "display_name": "Python 3.10.4 (conda)", "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.10.4" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }