Neural Network Quantization with AI Model Efficiency Toolkit (AIMET)

https://arxiv.org/pdf/2201.08442.pdf

Google Colaboratory

위 pdf의 14페이지 내용으로,

siren model에 QuantizationSimModel을 적용해보는 것이다.

import torch
from torchvision import models
#from pipelines import evaluate_model -> 함수로 그냥 간단하게 생성
from aimet_torch.quantsim import QuantizationSimModel
from siren import Siren

(conv1 layer) + (conv2_x layer) + (conv3_x layer) + (conv4_x layer) + (conv5_x layer) + (pool layer)

= 1+2×2+2×2+2×2+2×2+1=18

Untitled

m = models.resnet18().cuda()
# input dimension 3*224*224, number of layer 1 
sim = QuantizationSimModel(m, dummy_input=torch.rand(1, 3, 224, 224).cuda(),default_output_bw=8,
default_param_bw=8))
# siren model
model = Siren(
    dim_in=2,
    dim_hidden=28,
    dim_out=3,
    num_layers=10,
    final_activation=torch.nn.Identity(),
    w0_initial=30.0,
    w0=30.0
    ).to(torch.device('cuda'))