From 7dee77f3509c144f3c05ab12f6a962a9a9f8e83f Mon Sep 17 00:00:00 2001 From: Sergey Slashchinin Date: Thu, 20 Aug 2020 09:20:22 +0300 Subject: [PATCH] Add testdata for networks with parametrized input dims --- .../input_reshape_and_conv_parameter_dims.npy | Bin 0 -> 1328 bytes ...output_reshape_and_conv_parameter_dims.npy | Bin 0 -> 1328 bytes testdata/dnn/onnx/generate_onnx_models.py | 45 ++++++++++++++++++ .../reshape_and_conv_parameter_dims.onnx | Bin 0 -> 365 bytes 4 files changed, 45 insertions(+) create mode 100644 testdata/dnn/onnx/data/input_reshape_and_conv_parameter_dims.npy create mode 100644 testdata/dnn/onnx/data/output_reshape_and_conv_parameter_dims.npy create mode 100644 testdata/dnn/onnx/models/reshape_and_conv_parameter_dims.onnx diff --git a/testdata/dnn/onnx/data/input_reshape_and_conv_parameter_dims.npy b/testdata/dnn/onnx/data/input_reshape_and_conv_parameter_dims.npy new file mode 100644 index 0000000000000000000000000000000000000000..1b7ca316f6c2129fb9f5ab0c75a2350925242d62 GIT binary patch literal 1328 zcmbV=`#02S9DsGArjW~+C6p!nV%Tt|oRF0 zGn@k{E{AEOc@_E?JVA9`JrJ7vgCt-+Y|(DUwg=Z}p#6IgY4O44B?kv`9BGBhoye6p zKuuc#CH#1B`Xay<_5$3oYX)yAf0FKxNF|+SDx!3K#T%b%0Upm(q%PwTQ_{N@HU{NW zLwy0y{;3883)p;_dOe;qQsDU@TkMMqhY?N&TrqVay1gRG%5R}UjwTpxXruY!erj=$ zz=7&UsPYcwKbg9Z=HsQ<`0h1KI%p%gtA~&#f>ri8P-uJ+I#w_!39#TddJNN`hgV5M zb| z=n9vS%72pSzA!f5v3m$}ulX}Q4JVM-n~1fW=kPpQoT2IJU!ZP$4OM%t6YU=~po(uL zXD@kzu6LrT*QV3N=V=NV6qoYm>r|1DORtH}$Q$xGQ;6*|{XpMyFAi}csA-ppJouLa zCfHe%DcU85A0O0^!F~}Qv)#$qM4RE)nD=ySaugDbJ7|G?idSY>0M6TDpg->hytUYd zkCT;2PlxqcaS zs7@x#U^=Y{9p)u=9wHa?3ShNdN-Tz&$jz4lv^MPn^Z3s-gk9;4>Et5@b!w23bt}-s zyqpxMorjR$ofM}q_P^!6lX9$|0<)aRn6ETy+zMNWP$yKS)?|)6%?9&kffJ|zh$q) zLC<<%akGhajWuk@O+^D|j$3YlY z$V@(z;B{FG>0NFFimYX@aCb4<95aD~`dUa{6~Mg8W}fW47-Gx>(3n()Ys*t$uh$f9 zaH~MksYLKuR{_rtSYvUeF7yOQ$@EPY^JyRhy*IyQZnsubXR}tg;j)G>8I8oj-GIJx zGY21yTpF_K3i^ulXfwk?n@J6nNWwrvcRLQ%Z34YKDO?e$uxbf|f7d<7@yWBiDxEA` zEW88GM_w=ss@O2$ZbuK9r7?>J(&3EdZpapYq}p$`VzR3Nd6@eVMpezk*n1JyE;Y@R=ig#Mh0YvYGGB;-Bze8>L;>98wi8Z@Kh3s-!fN~vHl}5j literal 0 HcmV?d00001 diff --git a/testdata/dnn/onnx/data/output_reshape_and_conv_parameter_dims.npy b/testdata/dnn/onnx/data/output_reshape_and_conv_parameter_dims.npy new file mode 100644 index 0000000000000000000000000000000000000000..55b777010f4a4b95331b6d8dd891c9ffa28e034b GIT binary patch literal 1328 zcmb7@>o=7N9EFjzDs(Xug(%n2QO6<-&i>7~q>h*=YSLwmBaW0yArnz@%McltR70p# zlzT|L?@J|VCh3rd!V=S*Vu?y&Dx*JP_FB(}{e0YO?R1wd&Of@#%7n@sHt_Ne-W_CM zrEOp%HZ$O98;ApgLV`pAKL-YRd4KWiM1H~EGd_5aXutPNH#FgCoAR_x_+R*jryZ&N zzcVkY#+9Z9)hI`wPf}ke3Yp)9T+b$(alRc1+GFTwvKb|c_R)G1eTwqcB7uwzOnT~3 zAdC|fWv64ZID>3ru9DGJ0oqzS@LKo~Y7yZy)pHAPOp+L%x9%uVOr#gNS|qVwNNR#e zK}(oDY>f;MTQ-CVjz@OCH6eGQG7V_zk>sW+Jjd41BiE($u}7B)2p3|Bx(b`ZXpy?` z2s#d%(P`mEcGFkMWHB8|l^51hK({Q-tAC8MA=lxhbO*yatH|cwMhdF4rUJe$6^?cZ zW-E9x{A5*brCloZZPB3SRbdRjT!-dtGbWX?#UxQHLYjQO&G0r6Wz;R=KBOj4x8h#1 z<%Lj#y*pLQyHK=-6|FU`L~ryttW@pB$LwT5&2dHA^TaE6Y5DU2&_ z!uRB)U{w7DMl1bTVQVO@^ROTlYeTwd9!Q6dsFPdTFciNeIJOf!t0Uus65?_UmTtz_HG3tOZzarrvP{K z0`OpaA&fR$!YLky`1!SX?3jrWV+o?e{z7#GAG@->pqk=@rCR6l-aHuvze{mys2@8O zF5`J*E()dRaj|m@pDLbX*gFTca>*DNJ%y4h_Lr8Db!Ym*MVs9bT&&g14#YyBx24OS}r)zat(7gE6^Vaa!mUw3r-f} z7<;;vY?Yos7_U#}`Nim)@I%$;BrDZ*W;X_`;684<#Ey=q5Kpg+p52{fmv0JYT%(>b z-&YWIE`P#Y8F1ygweGXtsxefOaRPF0x1i^`{>&rVSjP=AT&9CHQ~twc95^7)x};g+ zXhIw;hsW6k19iC4B0`s*C#M!R#uon@!(~Q`QCd{TDoR_SD2d|Sc0^E@XgxLLF_3k9 zDflPKfoaTiV$1DUux>x4;MopY>e$_hjwXN9$S>j)+MGG==%3vFeeu*EJsV3}g`B7> z9J(3hX!meLzpEx2;=^?>Uf45ht3_9Q*NmTHq0kVEZU+G|mPd;Z7S#%Vvc zait17z? jz;`bKkliexsI3RV= 0: + dim_proto.dim_value = dim + else: + dim_proto.dim_param = dim_param_prefix + str(i) + '_' + str(j) + elif isinstance(dim, str): + dim_proto.dim_param = dim + else: + raise ValueError('Only int or str is accepted as dimension value, incorrect type: {}'.format(type(dim))) + + for i, input_dim_arr in enumerate(input_dims): + for j, dim in enumerate(input_dim_arr): + update_dim(model.graph.input[i], dim, i, j, 'in_') + + onnx.checker.check_model(model) + return model + + onnx_model = update_inputs_dims(onnx_model, [[3, 'height', 'width']]) + onnx.save(onnx_model, model_path) + +class ReshapeAndConv(nn.Module): + def __init__(self): + super(ReshapeAndConv, self).__init__() + self.conv = nn.Conv2d(3, 3, kernel_size=1, stride=1, padding=0) + def forward(self, x): + x = x.unsqueeze(axis=0) + out = self.conv(x) + return out + +x = Variable(torch.randn(3, 10, 10)) +model = ReshapeAndConv() +save_data_and_model("reshape_and_conv_parameter_dims", x, model) +postprocess_model("models/reshape_and_conv_parameter_dims.onnx") diff --git a/testdata/dnn/onnx/models/reshape_and_conv_parameter_dims.onnx b/testdata/dnn/onnx/models/reshape_and_conv_parameter_dims.onnx new file mode 100644 index 0000000000000000000000000000000000000000..409a3a7b5c1e07223929df367ef3e594804222da GIT binary patch literal 365 zcmd;J5n?Z>EXglQ&X8g@)HAla#>6GZ#b_YJXspB;npa#{nwnabs>RL4l30;i?7*;q zk)5lFk&Droi#s_#uS~BzH8VY}bh)F^MU^nY#WtQlsRutqHm1xOwFbgm`Azb3cvrM1We%Ic$b_GTAY_)7Tn1PUy zgAu3*+3j8`osqNlHB8!Ny`ZebZb77_?Sf8M+lD2RZGDno>|?lTY3sJ>j9ruxC{Sd% zq&XOc#JQL_n7KHF*fJoVXBT2E&rB)FNRsAaG!YWx5&^0a0IFdGt7GEe0@7SgOahz$ D1E^gs literal 0 HcmV?d00001