Hello!
I want to deploy a pytorch model trained in quantization-aware training method and then convert the model to other inference deep learning frame works(such as MACE) to deploy on mobile devices.
I am using a model based on https://github.com/pytorch/vision/blob/master/torchvision/models/mobilenet.py
my modification is:
1: change change bias=False to bias=True
2: change out_features of classifier to 20 because I have only 20 classes.
I use torch.jit to trace my model and save it.
The traced model is available in:

  
      github.com
  
  
    icyhearts/mobilenetv2_bias/blob/master/33.pt
PK	33/data/0FBZZZZZZZZZZZZZZZZZZZZZÀW<U»Vr<=½¯Ï¼ïcà;,,<6µ½Ãp¼p«<&Á»sxv<Í£<W½ap»²9<¸½»¼PrÎ¼âð¤¼_ó"¼r7¼p7ï¼ÈËx¼éÙ¼R½½+Æ¼å}z½Bp¼Æ´<Ì@	>lÆ>AãE=C¾f¾b½»½·p}=²[h;R©>^z??7Þ=Mñ­¾@N¿î¿½ê1¼iH»dñ<yE=:>á;øÜ½,|)¾8÷ºõÎË½cÔ= ;Ý»QÍ¾o??úC¡¾Þ+¿6Ín?{¾ ë½L>$½CR¿CM«?ô¿Ò¿
½?JHï¾±Æ¼k¤¼_(=gÞR¾+éÄ>Á0¾a¾4Aã>Ò¾\Ú:Æ7½·	¨=#ëq=t´M>Â,¾h7<&>Ó®¾tlã»q½ó£©=R=ó?îC¿3b=8²&?ö4¿MO¼ÏÝ¼Kh¯<[´C=në¸=/½°;¼Ã=ÚØ¾½}YÄ<é4Å<jw;º»¶½ò­½
KÝ=É­ð½Í+£¾çK¢<n=4V{¼¡¨=ª\¾~¯¾RG>þ{d¾j¿ICò».»<°1½ÔH¼Ô½|Õ½´y<Ç)½$Ôö½r&>å2>êýw¾I^>6Ä'?>%(¾7!?nõ-?¥;òó
¾SI;u#½|ê¾×¾¢4¿¼w½J¾À¾Ä¾Hy½ºÇu>f:½?äÎ¾/Á÷½¤g(>¯ÏÉ¾÷¾úà¬¼ÿ¼Í£·¹4îé>Þ ¾ûZ¾Ô>bô½ß=½N}½II¼Ø¸<Øtm?f­¾Í/î¾l>¿v{¾ù½½F<µÇ<!L;ÉÙq>*Ê½Kõ½´ûc=:U½_öÔ¼ª<Àç¼Ìò½ºg¼¦Ú»=ãg>òd¼°5>,¼>Î¼rµ½°6¾®L#<lYK>JUÀ>Ëñ;Véµ>M(?b¤»H¼B½Y¾<uó<Sò=åïÆ<¨¬=äÍ> õH=ãé*=Û¾ @¾R0?³¿+ö<:?á/¿j¢½ ,>FÔR¾®®¾¹{?«k¿8><#g?°ãz¿r	P=ñói¼¹A&¼rì½9ÈÍ>Ì«¾I
</¸Í>ôÉ¾Ä8=îB;n\;/:F¬9dV;àíû9'ò6ºî¦:!KÖ:¾@;îI¥:YÔ:S¼:!h;ã¨:³j
:c:;{)¼;f;÷_;ëR;]{M;K¶®;±;±3/;;×im½ô0¾2êÈ½Ç"p¾³¾¢"¸½ù¨<ïïl¼0½äR>Ñ»>ø>fçw=`p>å>®>QQ«>?>gèÞ<tú¾`u¾uËz¾(J«¾Ö»¾,S½c{¤½ÛÍ;¾{½½­aÖ<¬Ñ~=c=½\Ö=Q
.¼Î§½Ýã >Ó!x>©Ò[;4Y=°]¼e<¼û>/W½Xù½G,ã>ÞNà>wX¼&ºð;=!¸=¹ß¼OÒ½,Ê>>s>z¡#¾¤£¾Íª½B7>>¬>2ù¸=D;K½&#½cë<k¿¢¾[ª'¿Ða¾g?®)?	Ö)>a§ð½bÚÆ½+üC¼°½Ù¾ªã,½qê=¯I>x¹å< º¼¤ª¼xlÐ<ô>§6ª<ÿ.<¦¬¦=½ìSa:ÿ´<SÎÐ:¿i¾¼M?¥=^-=Ð><qO½pf=ÎÊG½o;êá"½¦>dü¨½ÐA½Ît¾q­½­	»Ö»<ÅÑ=LL ½ù¼!;¬Îm:X;!:Åâ~;	y9­O;C;°H-;hÐã¸Çb:(yÜ¹&^:=áá¹â³¹0l;*d:ìØ¹Üµ:-!È¹{¹ë:H+¬87^º¦µ :ÒÛ
;¿÷øºQÙ;o;Cd;©<;¨ØE;V¦E;Ì;Ä[<:U,; ÅºèºnáäºPÖ©ºäk®9ô¨:Äfë9ÆC$:Ü':n:+ºßÐ)º·£º9ß£ú9aI#8WÙ:èÉÖ:­¯¹®{¹Àü9ó0;0§:R<à¹ª<3:Á<"»Þ/³:»Çóºÿõ;ÀºÖr<sò<0¼»×»
ð¹Ó@²:b\£»Ø¬º)ºãxK;	Ï<·Ö¸/é»ºâ»UóL: PÉ:¸:tºñ1»B&9ÆËºZÁÓº\5a9g`N»&éº<ZºÐW»=²»x<¹È »¦}u»cUÇ»aü:êF:Läó9Ï:
É	»4Ô 9HÝºNB»º¥0º4h=+¼P½Äð¼Do<èê!=Bí½±Ü¨=ÎB>	¸Ü<¥^É¼2Ù½fÒ¼<ï=²q=q÷½Ö^>Ð>g~<. <È *½ÔK¼y«¼¯æ<SK¼7·<a>Â;Ñk^¾Ã¾zd¾Oó¾+¿ÇÍù½>Ø¾ÕÏ¬¾Rõ=b\ê=(á·=¥«=s=tl=æÊ>Þî­=:=Á¹ò½;b¹=¾á=¡J«=oy×>ªå>À¬<G>q}w>û.´¼ §¾íîºéT<-¾Ã¿L¼Ë,Ê= ·=
ö=e÷a¾´¾Ì¾:½½:OÈ½G¿§½4aò½õè<î>Y½±H>|¾ñd>7m=F¨¾y»uÑS<æ½<¨y$=Yd
¾(Ñ·½e9>)t>3Ì¾ÏyR½î½¡{=8´½o®é½î{#¾\Àî>ý>¹8¿ïo½¿¾J'¼~¡¾mÀ½Rì»wOÊ=À>Ér6¾/À<.Áê½òý=ÝØ½Õ¢=éôQ>Á+>MÑ²>*¿>­®G>©¾Ýõ­¼¨»>Gt¾Éé¾{!µ¾ú¾Ctê¾Üô¿QÌ¸¾7a
¿V­®¾®ç½$>Û¨¡>Aà>´ 0?7Aá>öè=aT1>=>5y;o8:Cz9ÛÅ:~?Ã9nõºm.ö9öñI»²»¥»st;M;eé9;};l'6;¿5¡:U?:E :6/Rºm-n;@è;8À:)©Ò;í¬;ZK¸ìH7cíü¸?ïw»@=Ó==l<|ú»9¥½iî½Ç1½G=<Hä=A/>¡¼vMH¾ëKy=ræ¾}c¾]Îv=l®=Ö C>ª ¾p=%¾´L»¾ÂVÌ¼ßöÎ½Xàx¾ãXí½3Ï<|Ü<ç(~<z=î¬¼,uê½hî¡>yè?Aº=!~¥¾¿S§ö<x=Þ`<ùMF¾ýÝ?ÙÍz?ô[!>®ï¿·Õt¿äT=7Àñ¼;h©¼$'½!>ãí>
X=cD¾k¾¶¹ä»9éL=9çw½*/,=Y¹½Ì@Í½)]ô;Äk½{{¾Õ¾q=¸5à<Ò¼f]=í:¾i¿X¾Ý,>ãÈ.¾g[°¾FÂD½e5=¹¨³=[¢"<ò	¼RÖ£:NL<><V(¾vÛU>AÄ=AÞ¼Ñ_e¾èþ½å>É`>yd>ã^ý<A7\>Ãû@¾ÿ8¾}U2¿ÃE¿ËV¾U{>d!>s¾ðá=w=ÀPH<ï ¾Gâ><é=¼>æ¿b>`þ+½7õ<Ð=#ö1>æ·³=û«=®(>Æ=F¾$Á½]:í¼x
b½aüÈ¼è<=½#-¼æ¯Í=õ(¾ï¬=#Â×½â®½ôné½²ì½Bþ¾,p¾fz.½SÌ¾Ù	ê½{W¾;]øE¼q»;ñ+ü<¤ÿY½;Tº½+¯>ø½\¾tf@=<kTR=tú=OÞ½Þ¾K&>½54B¾çp<5Ç»<UÚ=]«s=E½À¼C@½ >cg½>l,¾Î¾åã0=I5¤>ç>Ç<?íÌE?ÆjÊ>9Y?  6>¤1
½ô,¾¿ø'¾ji9¾}ÿ¬¾¦Î¾]¾,±¾j³¾õ> »=º"¾Èp»¥­Y¾J¾Ò;¾Ç[¾ö=&?;ºñ<ÓÇ¼	R½¦½´;I;ÿ=Yþú¼º1ù<Ìñ>>QÃ<âS<Áå¼Ñyo¼@Z=i 6>&=º=îy>ÄÒ·¼Ü;
½öþ½
üL½(,Ü<gä=?TÊ»ÔË6="ã=PKÚ­

PK		33/data/1FBZZZZZPP3¤¬:lû»Ò)8»ûÖw½éó¼ÁG½Ùß§<ÓÏ»ÏÖV<´R»û,<3x9,Û»þZ=pÓ;Õè#¼(>;(;=,A¼Æãc;=Í¹¼þÝºUo¼æ>¼ê»PKêQPK		33/data/2FBZZZZZzà=1>B²>ðO>É<u>p«>JE>í>Y?A>oC<tâ>4_>"1>îQ>'ý9<)<"	R<h¬;haò=	eá>À>N;E>?;À,å>Ýèq>(Ä°>ÊÕ¤>­(¼>ãZ>P¬ò>¥Ç&>PKTkPK		33/data/3FBZZZZZ~}¬½§:?3µ°>Â>k?J!?Rpí>!§?¨®?ªá¹,¾B#s?ïÓæ>fÅ¾`sº®¼;,½°ç¼Ó¬ª>Ãy$>¸|¾*»û>Â>bò}¼gtï¾!?1Á¾Á?þ¡ã½aÚ½B^¶>z:>PK|§PK		33/data/4FBZZZZZTì½|";á¾:ß#ñ:E¥[=[¿è}<¥LÀ½¡î;{¯;|vÓ½\í·½Ö@9nÚ½ksZ»ãU»L²ºD97½5?ìI=;=ä=>èÕc;ÄwA¾>e=»Å=Ý<F¾$\ò<o%¿ó®4½PK¬+{PK		33/data/5FBZZZZZ_×=7W>Äpn?5¸>åC@[ß<@nÍ>M²@{?èÈ:~@;?0ÛS@Z[>°×?§ªÙ9L
L:O<y	¡9Å;?ür@¼:Ã?ë?ÆÝ?"I9-@&¶û>`*×?Sc?G@yB^>¬äi@ÅÅC?PKN³7PK		33/data/6FBZZZZZ¢àPK§
ñÝPK	A33/data/7FB=ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZPKß¥PK	33/data/8FBZZZZPKïÒPK	33/data/9FBZZZZ¤ß8;PKvÃPK
33/data/10FBPKiß"ePK
@33/data/11FB<ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ4PK©

  This file has been truncated. show original

  
  
    
    
  
  


I find the graph created by jit is not optimized:
graph1411×968 122 KB
The consants are not folded so there are add, sqrt, div and mul before conv layer,  the bias of conv layer is added twice, BN parameters are not folded into Conv layer.
Is there any suggestion to optimize a jit model to do these folds?
I want to deploy the model in mobile device so these folds can be useful.
Many thanks.