上传肢体识别相关本地库

chenghonghao_branch
MikkoAyaka 2 years ago
parent f7f957a18c
commit 1e9adb6bde

@ -0,0 +1,254 @@
7767517
252 280
Input input 0 1 input
Split splitncnn_input0 1 2 input input_splitncnn_0 input_splitncnn_1
Convolution Conv_0 1 1 input_splitncnn_1 623 0=13 1=3 3=2 4=1 6=351
Pooling MaxPool_1 1 1 input_splitncnn_0 624 1=3 2=2 3=1 5=1
Concat Concat_2 2 1 623 624 625
BatchNorm BatchNormalization_3 1 1 625 626 0=16
PReLU PRelu_5 1 1 626 628 0=1
Split splitncnn_0 1 2 628 628_splitncnn_0 628_splitncnn_1
Pooling MaxPool_6 1 1 628_splitncnn_1 629 1=2 2=2 5=1
Convolution Conv_7 1 1 628_splitncnn_0 631 0=4 1=2 3=2 5=1 6=256
PReLU PRelu_10 1 1 631 633 0=1
Convolution Conv_11 1 1 633 635 0=4 1=3 4=1 5=1 6=144
PReLU PRelu_14 1 1 635 637 0=1
Convolution Conv_15 1 1 637 639 0=64 1=1 5=1 6=256
PReLU PRelu_18 1 1 639 641 0=1
Concat Concat_41 1 1 629 664
BinaryOp Add_42 2 1 664 641 665
PReLU PRelu_44 1 1 665 667 0=1
Split splitncnn_1 1 2 667 667_splitncnn_0 667_splitncnn_1
Convolution Conv_45 1 1 667_splitncnn_1 669 0=16 1=1 5=1 6=1024
PReLU PRelu_48 1 1 669 671 0=1
Convolution Conv_49 1 1 671 673 0=16 1=3 4=1 5=1 6=2304
PReLU PRelu_52 1 1 673 675 0=1
Convolution Conv_53 1 1 675 677 0=64 1=1 5=1 6=1024
PReLU PRelu_56 1 1 677 679 0=1
BinaryOp Add_57 2 1 667_splitncnn_0 679 680
PReLU PRelu_59 1 1 680 682 0=1
Split splitncnn_2 1 2 682 682_splitncnn_0 682_splitncnn_1
Convolution Conv_60 1 1 682_splitncnn_1 684 0=16 1=1 5=1 6=1024
PReLU PRelu_63 1 1 684 686 0=1
Convolution Conv_64 1 1 686 688 0=16 1=3 4=1 5=1 6=2304
PReLU PRelu_67 1 1 688 690 0=1
Convolution Conv_68 1 1 690 692 0=64 1=1 5=1 6=1024
PReLU PRelu_71 1 1 692 694 0=1
BinaryOp Add_72 2 1 682_splitncnn_0 694 695
PReLU PRelu_74 1 1 695 697 0=1
Split splitncnn_3 1 2 697 697_splitncnn_0 697_splitncnn_1
Convolution Conv_75 1 1 697_splitncnn_1 699 0=16 1=1 5=1 6=1024
PReLU PRelu_78 1 1 699 701 0=1
Convolution Conv_79 1 1 701 703 0=16 1=3 4=1 5=1 6=2304
PReLU PRelu_82 1 1 703 705 0=1
Convolution Conv_83 1 1 705 707 0=64 1=1 5=1 6=1024
PReLU PRelu_86 1 1 707 709 0=1
BinaryOp Add_87 2 1 697_splitncnn_0 709 710
PReLU PRelu_89 1 1 710 712 0=1
Split splitncnn_4 1 2 712 712_splitncnn_0 712_splitncnn_1
Convolution Conv_90 1 1 712_splitncnn_1 714 0=16 1=1 5=1 6=1024
PReLU PRelu_93 1 1 714 716 0=1
Convolution Conv_94 1 1 716 718 0=16 1=3 4=1 5=1 6=2304
PReLU PRelu_97 1 1 718 720 0=1
Convolution Conv_98 1 1 720 722 0=64 1=1 5=1 6=1024
PReLU PRelu_101 1 1 722 724 0=1
BinaryOp Add_102 2 1 712_splitncnn_0 724 725
PReLU PRelu_104 1 1 725 727 0=1
Split splitncnn_5 1 2 727 727_splitncnn_0 727_splitncnn_1
Pooling MaxPool_105 1 1 727_splitncnn_1 728 1=2 2=2 5=1
Convolution Conv_106 1 1 727_splitncnn_0 730 0=16 1=2 3=2 5=1 6=4096
PReLU PRelu_109 1 1 730 732 0=1
Convolution Conv_110 1 1 732 734 0=16 1=3 4=1 5=1 6=2304
PReLU PRelu_113 1 1 734 736 0=1
Convolution Conv_114 1 1 736 738 0=128 1=1 5=1 6=2048
PReLU PRelu_117 1 1 738 740 0=1
Concat Concat_140 1 1 728 763
BinaryOp Add_141 2 1 763 740 764
PReLU PRelu_143 1 1 764 766 0=1
Split splitncnn_6 1 2 766 766_splitncnn_0 766_splitncnn_1
Convolution Conv_144 1 1 766_splitncnn_1 768 0=32 1=1 5=1 6=4096
PReLU PRelu_147 1 1 768 770 0=1
Convolution Conv_148 1 1 770 772 0=32 1=3 4=1 5=1 6=9216
PReLU PRelu_151 1 1 772 774 0=1
Convolution Conv_152 1 1 774 776 0=128 1=1 5=1 6=4096
PReLU PRelu_155 1 1 776 778 0=1
BinaryOp Add_156 2 1 766_splitncnn_0 778 779
PReLU PRelu_158 1 1 779 781 0=1
Split splitncnn_7 1 2 781 781_splitncnn_0 781_splitncnn_1
Convolution Conv_159 1 1 781_splitncnn_1 783 0=32 1=1 5=1 6=4096
PReLU PRelu_162 1 1 783 785 0=1
Convolution Conv_163 1 1 785 787 0=32 1=3 2=2 4=2 5=1 6=9216
PReLU PRelu_166 1 1 787 789 0=1
Convolution Conv_167 1 1 789 791 0=128 1=1 5=1 6=4096
PReLU PRelu_170 1 1 791 793 0=1
BinaryOp Add_171 2 1 781_splitncnn_0 793 794
PReLU PRelu_173 1 1 794 796 0=1
Split splitncnn_8 1 2 796 796_splitncnn_0 796_splitncnn_1
Convolution Conv_174 1 1 796_splitncnn_1 798 0=32 1=1 5=1 6=4096
PReLU PRelu_177 1 1 798 800 0=1
Convolution Conv_178 1 1 800 802 0=32 1=1 11=5 14=2 5=1 6=5120
PReLU PRelu_181 1 1 802 804 0=1
Convolution Conv_182 1 1 804 806 0=32 1=5 11=1 4=2 14=0 5=1 6=5120
PReLU PRelu_185 1 1 806 808 0=1
Convolution Conv_186 1 1 808 810 0=128 1=1 5=1 6=4096
PReLU PRelu_189 1 1 810 812 0=1
BinaryOp Add_190 2 1 796_splitncnn_0 812 813
PReLU PRelu_192 1 1 813 815 0=1
Split splitncnn_9 1 2 815 815_splitncnn_0 815_splitncnn_1
Convolution Conv_193 1 1 815_splitncnn_1 817 0=32 1=1 5=1 6=4096
PReLU PRelu_196 1 1 817 819 0=1
Convolution Conv_197 1 1 819 821 0=32 1=3 2=4 4=4 5=1 6=9216
PReLU PRelu_200 1 1 821 823 0=1
Convolution Conv_201 1 1 823 825 0=128 1=1 5=1 6=4096
PReLU PRelu_204 1 1 825 827 0=1
BinaryOp Add_205 2 1 815_splitncnn_0 827 828
PReLU PRelu_207 1 1 828 830 0=1
Split splitncnn_10 1 2 830 830_splitncnn_0 830_splitncnn_1
Convolution Conv_208 1 1 830_splitncnn_1 832 0=32 1=1 5=1 6=4096
PReLU PRelu_211 1 1 832 834 0=1
Convolution Conv_212 1 1 834 836 0=32 1=3 4=1 5=1 6=9216
PReLU PRelu_215 1 1 836 838 0=1
Convolution Conv_216 1 1 838 840 0=128 1=1 5=1 6=4096
PReLU PRelu_219 1 1 840 842 0=1
BinaryOp Add_220 2 1 830_splitncnn_0 842 843
PReLU PRelu_222 1 1 843 845 0=1
Split splitncnn_11 1 2 845 845_splitncnn_0 845_splitncnn_1
Convolution Conv_223 1 1 845_splitncnn_1 847 0=32 1=1 5=1 6=4096
PReLU PRelu_226 1 1 847 849 0=1
Convolution Conv_227 1 1 849 851 0=32 1=3 2=8 4=8 5=1 6=9216
PReLU PRelu_230 1 1 851 853 0=1
Convolution Conv_231 1 1 853 855 0=128 1=1 5=1 6=4096
PReLU PRelu_234 1 1 855 857 0=1
BinaryOp Add_235 2 1 845_splitncnn_0 857 858
PReLU PRelu_237 1 1 858 860 0=1
Split splitncnn_12 1 2 860 860_splitncnn_0 860_splitncnn_1
Convolution Conv_238 1 1 860_splitncnn_1 862 0=32 1=1 5=1 6=4096
PReLU PRelu_241 1 1 862 864 0=1
Convolution Conv_242 1 1 864 866 0=32 1=1 11=5 14=2 5=1 6=5120
PReLU PRelu_245 1 1 866 868 0=1
Convolution Conv_246 1 1 868 870 0=32 1=5 11=1 4=2 14=0 5=1 6=5120
PReLU PRelu_249 1 1 870 872 0=1
Convolution Conv_250 1 1 872 874 0=128 1=1 5=1 6=4096
PReLU PRelu_253 1 1 874 876 0=1
BinaryOp Add_254 2 1 860_splitncnn_0 876 877
PReLU PRelu_256 1 1 877 879 0=1
Split splitncnn_13 1 2 879 879_splitncnn_0 879_splitncnn_1
Convolution Conv_257 1 1 879_splitncnn_1 881 0=32 1=1 5=1 6=4096
PReLU PRelu_260 1 1 881 883 0=1
Convolution Conv_261 1 1 883 885 0=32 1=3 2=16 4=16 5=1 6=9216
PReLU PRelu_264 1 1 885 887 0=1
Convolution Conv_265 1 1 887 889 0=128 1=1 5=1 6=4096
PReLU PRelu_268 1 1 889 891 0=1
BinaryOp Add_269 2 1 879_splitncnn_0 891 892
PReLU PRelu_271 1 1 892 894 0=1
Split splitncnn_14 1 2 894 894_splitncnn_0 894_splitncnn_1
Convolution Conv_272 1 1 894_splitncnn_1 896 0=32 1=1 5=1 6=4096
PReLU PRelu_275 1 1 896 898 0=1
Convolution Conv_276 1 1 898 900 0=32 1=3 4=1 5=1 6=9216
PReLU PRelu_279 1 1 900 902 0=1
Convolution Conv_280 1 1 902 904 0=128 1=1 5=1 6=4096
PReLU PRelu_283 1 1 904 906 0=1
BinaryOp Add_284 2 1 894_splitncnn_0 906 907
PReLU PRelu_286 1 1 907 909 0=1
Split splitncnn_15 1 2 909 909_splitncnn_0 909_splitncnn_1
Convolution Conv_287 1 1 909_splitncnn_1 911 0=32 1=1 5=1 6=4096
PReLU PRelu_290 1 1 911 913 0=1
Convolution Conv_291 1 1 913 915 0=32 1=3 2=2 4=2 5=1 6=9216
PReLU PRelu_294 1 1 915 917 0=1
Convolution Conv_295 1 1 917 919 0=128 1=1 5=1 6=4096
PReLU PRelu_298 1 1 919 921 0=1
BinaryOp Add_299 2 1 909_splitncnn_0 921 922
PReLU PRelu_301 1 1 922 924 0=1
Split splitncnn_16 1 2 924 924_splitncnn_0 924_splitncnn_1
Convolution Conv_302 1 1 924_splitncnn_1 926 0=32 1=1 5=1 6=4096
PReLU PRelu_305 1 1 926 928 0=1
Convolution Conv_306 1 1 928 930 0=32 1=1 11=5 14=2 5=1 6=5120
PReLU PRelu_309 1 1 930 932 0=1
Convolution Conv_310 1 1 932 934 0=32 1=5 11=1 4=2 14=0 5=1 6=5120
PReLU PRelu_313 1 1 934 936 0=1
Convolution Conv_314 1 1 936 938 0=128 1=1 5=1 6=4096
PReLU PRelu_317 1 1 938 940 0=1
BinaryOp Add_318 2 1 924_splitncnn_0 940 941
PReLU PRelu_320 1 1 941 943 0=1
Split splitncnn_17 1 2 943 943_splitncnn_0 943_splitncnn_1
Convolution Conv_321 1 1 943_splitncnn_1 945 0=32 1=1 5=1 6=4096
PReLU PRelu_324 1 1 945 947 0=1
Convolution Conv_325 1 1 947 949 0=32 1=3 2=4 4=4 5=1 6=9216
PReLU PRelu_328 1 1 949 951 0=1
Convolution Conv_329 1 1 951 953 0=128 1=1 5=1 6=4096
PReLU PRelu_332 1 1 953 955 0=1
BinaryOp Add_333 2 1 943_splitncnn_0 955 956
PReLU PRelu_335 1 1 956 958 0=1
Split splitncnn_18 1 2 958 958_splitncnn_0 958_splitncnn_1
Convolution Conv_336 1 1 958_splitncnn_1 960 0=32 1=1 5=1 6=4096
PReLU PRelu_339 1 1 960 962 0=1
Convolution Conv_340 1 1 962 964 0=32 1=3 4=1 5=1 6=9216
PReLU PRelu_343 1 1 964 966 0=1
Convolution Conv_344 1 1 966 968 0=128 1=1 5=1 6=4096
PReLU PRelu_347 1 1 968 970 0=1
BinaryOp Add_348 2 1 958_splitncnn_0 970 971
PReLU PRelu_350 1 1 971 973 0=1
Split splitncnn_19 1 2 973 973_splitncnn_0 973_splitncnn_1
Convolution Conv_351 1 1 973_splitncnn_1 975 0=32 1=1 5=1 6=4096
PReLU PRelu_354 1 1 975 977 0=1
Convolution Conv_355 1 1 977 979 0=32 1=3 2=8 4=8 5=1 6=9216
PReLU PRelu_358 1 1 979 981 0=1
Convolution Conv_359 1 1 981 983 0=128 1=1 5=1 6=4096
PReLU PRelu_362 1 1 983 985 0=1
BinaryOp Add_363 2 1 973_splitncnn_0 985 986
PReLU PRelu_365 1 1 986 988 0=1
Split splitncnn_20 1 2 988 988_splitncnn_0 988_splitncnn_1
Convolution Conv_366 1 1 988_splitncnn_1 990 0=32 1=1 5=1 6=4096
PReLU PRelu_369 1 1 990 992 0=1
Convolution Conv_370 1 1 992 994 0=32 1=1 11=5 14=2 5=1 6=5120
PReLU PRelu_373 1 1 994 996 0=1
Convolution Conv_374 1 1 996 998 0=32 1=5 11=1 4=2 14=0 5=1 6=5120
PReLU PRelu_377 1 1 998 1000 0=1
Convolution Conv_378 1 1 1000 1002 0=128 1=1 5=1 6=4096
PReLU PRelu_381 1 1 1002 1004 0=1
BinaryOp Add_382 2 1 988_splitncnn_0 1004 1005
PReLU PRelu_384 1 1 1005 1007 0=1
Split splitncnn_21 1 2 1007 1007_splitncnn_0 1007_splitncnn_1
Convolution Conv_385 1 1 1007_splitncnn_1 1009 0=32 1=1 5=1 6=4096
PReLU PRelu_388 1 1 1009 1011 0=1
Convolution Conv_389 1 1 1011 1013 0=32 1=3 2=16 4=16 5=1 6=9216
PReLU PRelu_392 1 1 1013 1015 0=1
Convolution Conv_393 1 1 1015 1017 0=128 1=1 5=1 6=4096
PReLU PRelu_396 1 1 1017 1019 0=1
BinaryOp Add_397 2 1 1007_splitncnn_0 1019 1020
PReLU PRelu_399 1 1 1020 1022 0=1
Split splitncnn_22 1 2 1022 1022_splitncnn_0 1022_splitncnn_1
Convolution Conv_400 1 1 1022_splitncnn_1 1024 0=64 1=1 5=1 6=8192
Interp Resize_430 1 1 1024 1053 0=2 3=128 4=128
Convolution Conv_431 1 1 1022_splitncnn_0 1056 0=32 1=1 5=1 6=4096 9=1
Deconvolution ConvTranspose_434 1 1 1056 1059 0=32 1=2 3=2 5=1 6=4096 9=1
Convolution Conv_437 1 1 1059 1062 0=64 1=1 5=1 6=2048 9=1
BinaryOp Add_440 2 1 1053 1062 1063
ReLU Relu_441 1 1 1063 1064
Split splitncnn_23 1 2 1064 1064_splitncnn_0 1064_splitncnn_1
Convolution Conv_442 1 1 1064_splitncnn_1 1067 0=16 1=1 5=1 6=1024 9=1
Convolution Conv_445 1 1 1067 1070 0=16 1=3 4=1 5=1 6=2304 9=1
Convolution Conv_448 1 1 1070 1073 0=64 1=1 5=1 6=1024 9=1
BinaryOp Add_451 2 1 1064_splitncnn_0 1073 1074
ReLU Relu_452 1 1 1074 1075
Split splitncnn_24 1 2 1075 1075_splitncnn_0 1075_splitncnn_1
Convolution Conv_453 1 1 1075_splitncnn_1 1078 0=16 1=1 5=1 6=1024 9=1
Convolution Conv_456 1 1 1078 1081 0=16 1=3 4=1 5=1 6=2304 9=1
Convolution Conv_459 1 1 1081 1084 0=64 1=1 5=1 6=1024 9=1
BinaryOp Add_462 2 1 1075_splitncnn_0 1084 1085
ReLU Relu_463 1 1 1085 1086
Split splitncnn_25 1 2 1086 1086_splitncnn_0 1086_splitncnn_1
Convolution Conv_464 1 1 1086_splitncnn_1 1088 0=16 1=1 5=1 6=1024
Interp Resize_494 1 1 1088 1117 0=2 3=256 4=256
Convolution Conv_495 1 1 1086_splitncnn_0 1120 0=16 1=1 5=1 6=1024 9=1
Deconvolution ConvTranspose_498 1 1 1120 1123 0=16 1=2 3=2 5=1 6=1024 9=1
Convolution Conv_501 1 1 1123 1126 0=16 1=1 5=1 6=256 9=1
BinaryOp Add_504 2 1 1117 1126 1127
ReLU Relu_505 1 1 1127 1128
Split splitncnn_26 1 2 1128 1128_splitncnn_0 1128_splitncnn_1
Convolution Conv_506 1 1 1128_splitncnn_1 1131 0=4 1=1 5=1 6=64 9=1
Convolution Conv_509 1 1 1131 1134 0=4 1=3 4=1 5=1 6=144 9=1
Convolution Conv_512 1 1 1134 1137 0=16 1=1 5=1 6=64 9=1
BinaryOp Add_515 2 1 1128_splitncnn_0 1137 1138
ReLU Relu_516 1 1 1138 1139
Deconvolution ConvTranspose_517 1 1 1139 output 0=20 1=3 3=2 4=1 18=1 6=2880

@ -0,0 +1,92 @@
7767517
90 105
Input data 0 1 data -23330=4,3,320,320,3 0=320 1=320 2=3
Convolution 0_22 1 1 data 0_22_bn_relu -23330=4,3,160,160,16 0=16 1=3 3=2 4=1 5=1 6=432 9=1
ConvolutionDepthWise 1_31 1 1 0_22_bn_relu 1_31_bn_relu -23330=4,3,160,160,16 0=16 1=3 4=1 5=1 6=144 7=16 9=1
Convolution 2_40 1 1 1_31_bn_relu 2_40_bn -23330=4,3,160,160,8 0=8 1=1 5=1 6=128
Convolution 3_49 1 1 2_40_bn 3_49_bn_relu -23330=4,3,160,160,48 0=48 1=1 5=1 6=384 9=1
ConvolutionDepthWise 4_58 1 1 3_49_bn_relu 4_58_bn_relu -23330=4,3,80,80,48 0=48 1=3 3=2 4=1 5=1 6=432 7=48 9=1
Convolution 5_67 1 1 4_58_bn_relu 5_67_bn -23330=4,3,80,80,12 0=12 1=1 5=1 6=576
Split 5_67_bn_split 1 2 5_67_bn 5_67_bn_split_0 5_67_bn_split_1 -23330=8,3,80,80,12,3,80,80,12
Convolution 6_76 1 1 5_67_bn_split_0 6_76_bn_relu -23330=4,3,80,80,72 0=72 1=1 5=1 6=864 9=1
ConvolutionDepthWise 7_85 1 1 6_76_bn_relu 7_85_bn_relu -23330=4,3,80,80,72 0=72 1=3 4=1 5=1 6=648 7=72 9=1
Convolution 8_94 1 1 7_85_bn_relu 8_94_bn -23330=4,3,80,80,12 0=12 1=1 5=1 6=864
Eltwise 9_103 2 1 8_94_bn 5_67_bn_split_1 9_103 -23330=4,3,80,80,12 0=1
Convolution 10_107 1 1 9_103 10_107_bn_relu -23330=4,3,80,80,72 0=72 1=1 5=1 6=864 9=1
ConvolutionDepthWise 11_116 1 1 10_107_bn_relu 11_116_bn_relu -23330=4,3,40,40,72 0=72 1=3 3=2 4=1 5=1 6=648 7=72 9=1
Convolution 12_125 1 1 11_116_bn_relu 12_125_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1152
Split 12_125_bn_split 1 2 12_125_bn 12_125_bn_split_0 12_125_bn_split_1 -23330=8,3,40,40,16,3,40,40,16
Convolution 13_134 1 1 12_125_bn_split_0 13_134_bn_relu -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 14_143 1 1 13_134_bn_relu 14_143_bn_relu -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=1
Convolution 15_152 1 1 14_143_bn_relu 15_152_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1536
Eltwise 16_161 2 1 15_152_bn 12_125_bn_split_1 16_161 -23330=4,3,40,40,16 0=1
Split 16_161_split 1 2 16_161 16_161_split_0 16_161_split_1 -23330=8,3,40,40,16,3,40,40,16
Convolution 17_165 1 1 16_161_split_0 17_165_bn_relu -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 18_174 1 1 17_165_bn_relu 18_174_bn_relu -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=1
Convolution 19_183 1 1 18_174_bn_relu 19_183_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1536
Eltwise 20_192 2 1 19_183_bn 16_161_split_1 20_192 -23330=4,3,40,40,16 0=1
Convolution 21_196 1 1 20_192 21_196_bn_relu -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 22_205 1 1 21_196_bn_relu 22_205_bn_relu -23330=4,3,20,20,96 0=96 1=3 3=2 4=1 5=1 6=864 7=96 9=1
Convolution 23_214 1 1 22_205_bn_relu 23_214_bn -23330=4,3,20,20,32 0=32 1=1 5=1 6=3072
Split 23_214_bn_split 1 2 23_214_bn 23_214_bn_split_0 23_214_bn_split_1 -23330=8,3,20,20,32,3,20,20,32
Convolution 24_223 1 1 23_214_bn_split_0 24_223_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=6144 9=1
ConvolutionDepthWise 25_232 1 1 24_223_bn_relu 25_232_bn_relu -23330=4,3,20,20,192 0=192 1=3 4=1 5=1 6=1728 7=192 9=1
Convolution 26_241 1 1 25_232_bn_relu 26_241_bn -23330=4,3,20,20,32 0=32 1=1 5=1 6=6144
Eltwise 27_250 2 1 26_241_bn 23_214_bn_split_1 27_250 -23330=4,3,20,20,32 0=1
Split 27_250_split 1 2 27_250 27_250_split_0 27_250_split_1 -23330=8,3,20,20,32,3,20,20,32
Convolution 28_254 1 1 27_250_split_0 28_254_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=6144 9=1
ConvolutionDepthWise 29_263 1 1 28_254_bn_relu 29_263_bn_relu -23330=4,3,20,20,192 0=192 1=3 4=1 5=1 6=1728 7=192 9=1
Convolution 30_272 1 1 29_263_bn_relu 30_272_bn -23330=4,3,20,20,32 0=32 1=1 5=1 6=6144
Eltwise 31_281 2 1 30_272_bn 27_250_split_1 31_281 -23330=4,3,20,20,32 0=1
Split 31_281_split 1 2 31_281 31_281_split_0 31_281_split_1 -23330=8,3,20,20,32,3,20,20,32
Convolution 32_285 1 1 31_281_split_0 32_285_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=6144 9=1
ConvolutionDepthWise 33_294 1 1 32_285_bn_relu 33_294_bn_relu -23330=4,3,20,20,192 0=192 1=3 4=1 5=1 6=1728 7=192 9=1
Convolution 34_303 1 1 33_294_bn_relu 34_303_bn -23330=4,3,20,20,32 0=32 1=1 5=1 6=6144
Eltwise 35_312 2 1 34_303_bn 31_281_split_1 35_312 -23330=4,3,20,20,32 0=1
Convolution 36_316 1 1 35_312 36_316_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=6144 9=1
ConvolutionDepthWise 37_325 1 1 36_316_bn_relu 37_325_bn_relu -23330=4,3,20,20,192 0=192 1=3 4=1 5=1 6=1728 7=192 9=1
Convolution 38_334 1 1 37_325_bn_relu 38_334_bn -23330=4,3,20,20,48 0=48 1=1 5=1 6=9216
Split 38_334_bn_split 1 2 38_334_bn 38_334_bn_split_0 38_334_bn_split_1 -23330=8,3,20,20,48,3,20,20,48
Convolution 39_343 1 1 38_334_bn_split_0 39_343_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=13824 9=1
ConvolutionDepthWise 40_352 1 1 39_343_bn_relu 40_352_bn_relu -23330=4,3,20,20,288 0=288 1=3 4=1 5=1 6=2592 7=288 9=1
Convolution 41_361 1 1 40_352_bn_relu 41_361_bn -23330=4,3,20,20,48 0=48 1=1 5=1 6=13824
Eltwise 42_370 2 1 41_361_bn 38_334_bn_split_1 42_370 -23330=4,3,20,20,48 0=1
Split 42_370_split 1 2 42_370 42_370_split_0 42_370_split_1 -23330=8,3,20,20,48,3,20,20,48
Convolution 43_374 1 1 42_370_split_0 43_374_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=13824 9=1
ConvolutionDepthWise 44_383 1 1 43_374_bn_relu 44_383_bn_relu -23330=4,3,20,20,288 0=288 1=3 4=1 5=1 6=2592 7=288 9=1
Convolution 45_392 1 1 44_383_bn_relu 45_392_bn -23330=4,3,20,20,48 0=48 1=1 5=1 6=13824
Eltwise 46_401 2 1 45_392_bn 42_370_split_1 46_401 -23330=4,3,20,20,48 0=1
Convolution 47_405 1 1 46_401 47_405_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=13824 9=1
Split 47_405_bn_relu_split 1 2 47_405_bn_relu 47_405_bn_relu_split_0 47_405_bn_relu_split_1 -23330=8,3,20,20,288,3,20,20,288
ConvolutionDepthWise 48_414 1 1 47_405_bn_relu_split_0 48_414_bn_relu -23330=4,3,10,10,288 0=288 1=3 3=2 4=1 5=1 6=2592 7=288 9=1
Convolution 49_423 1 1 48_414_bn_relu 49_423_bn -23330=4,3,10,10,80 0=80 1=1 5=1 6=23040
Split 49_423_bn_split 1 2 49_423_bn 49_423_bn_split_0 49_423_bn_split_1 -23330=8,3,10,10,80,3,10,10,80
Convolution 50_432 1 1 49_423_bn_split_0 50_432_bn_relu -23330=4,3,10,10,480 0=480 1=1 5=1 6=38400 9=1
ConvolutionDepthWise 51_441 1 1 50_432_bn_relu 51_441_bn_relu -23330=4,3,10,10,480 0=480 1=3 4=1 5=1 6=4320 7=480 9=1
Convolution 52_450 1 1 51_441_bn_relu 52_450_bn -23330=4,3,10,10,80 0=80 1=1 5=1 6=38400
Eltwise 53_459 2 1 52_450_bn 49_423_bn_split_1 53_459 -23330=4,3,10,10,80 0=1
Split 53_459_split 1 2 53_459 53_459_split_0 53_459_split_1 -23330=8,3,10,10,80,3,10,10,80
Convolution 54_463 1 1 53_459_split_0 54_463_bn_relu -23330=4,3,10,10,480 0=480 1=1 5=1 6=38400 9=1
ConvolutionDepthWise 55_472 1 1 54_463_bn_relu 55_472_bn_relu -23330=4,3,10,10,480 0=480 1=3 4=1 5=1 6=4320 7=480 9=1
Convolution 56_481 1 1 55_472_bn_relu 56_481_bn -23330=4,3,10,10,80 0=80 1=1 5=1 6=38400
Eltwise 57_490 2 1 56_481_bn 53_459_split_1 57_490 -23330=4,3,10,10,80 0=1
Split 57_490_split 1 4 57_490 57_490_split_0 57_490_split_1 57_490_split_2 57_490_split_3 -23330=16,3,10,10,80,3,10,10,80,3,10,10,80,3,10,10,80
Pooling 58_494 1 1 57_490_split_0 58_494 -23330=4,3,10,10,80 1=3 14=2 15=2 5=1
Pooling 60_501 1 1 57_490_split_1 60_501 -23330=4,3,10,10,80 1=5 14=4 15=4 5=1
Pooling 62_508 1 1 57_490_split_2 62_508 -23330=4,3,10,10,80 1=9 14=8 15=8 5=1
Concat 63_512 4 1 62_508 60_501 58_494 57_490_split_3 63_512 -23330=4,3,10,10,320
Convolution 64_517 1 1 63_512 64_517_bn_relu -23330=4,3,10,10,288 0=288 1=1 5=1 6=92160 9=1
Split 64_517_bn_relu_split 1 2 64_517_bn_relu 64_517_bn_relu_split_0 64_517_bn_relu_split_1 -23330=8,3,10,10,288,3,10,10,288
ConvolutionDepthWise 65_525 1 1 64_517_bn_relu_split_0 65_525_bn_relu -23330=4,3,10,10,288 0=288 1=3 4=1 5=1 6=2592 7=288 9=1
Convolution 66_534 1 1 65_525_bn_relu 66_534_bn_relu -23330=4,3,10,10,96 0=96 1=1 5=1 6=27648 9=1
Convolution 67_542 1 1 66_534_bn_relu 67_542_bn_relu -23330=4,3,10,10,384 0=384 1=1 5=1 6=36864 9=1
Convolution 68_550 1 1 67_542_bn_relu 68_550 -23330=4,3,10,10,255 0=255 1=1 5=1 6=97920
Interp 71_580 1 1 64_517_bn_relu_split_1 71_580 -23330=4,3,20,20,288 0=1 1=2.000000e+00 2=2.000000e+00
Concat 72_583 2 1 71_580 47_405_bn_relu_split_1 72_583 -23330=4,3,20,20,576
Convolution 73_586 1 1 72_583 73_586_bn_relu -23330=4,3,20,20,80 0=80 1=1 5=1 6=46080 9=1
Convolution 74_595 1 1 73_586_bn_relu 74_595_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=23040 9=1
ConvolutionDepthWise 75_603 1 1 74_595_bn_relu 75_603_bn_relu -23330=4,3,20,20,288 0=288 1=3 4=1 5=1 6=2592 7=288 9=1
Convolution 76_612 1 1 75_603_bn_relu 76_612_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=55296 9=1
Convolution 77_620 1 1 76_612_bn_relu 77_620_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=55296 9=1
Convolution 78_628 1 1 77_620_bn_relu 78_628 -23330=4,3,20,20,255 0=255 1=1 5=1 6=73440
Yolov3DetectionOutput detection_out 2 1 68_550 78_628 output -23330=4,2,6,1356,1 0=80 1=3 2=0.24 -23304=12,1.200000e+01,1.800000e+01,3.700000e+01,4.900000e+01,5.200000e+01,1.320000e+02,1.150000e+02,7.400000e+01,1.190000e+02,1.990000e+02,2.430000e+02,2.380000e+02 -23305=6,1077936128,1082130432,1084227584,0,1065353216,1073741824 -23306=2,3.520000e+01,1.680000e+01

@ -0,0 +1,82 @@
7767517
80 90
Input data 0 1 data
Convolution mobilenetv20_features_conv0_fwd 1 1 data mobilenetv20_features_relu60_relu6 0=16 1=3 3=2 4=1 5=1 6=432 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck0_conv0_fwd 1 1 mobilenetv20_features_relu60_relu6 mobilenetv20_features_linearbottleneck0_relu60_relu6 0=16 1=3 4=1 5=1 6=144 7=16 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck0_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck0_relu60_relu6 mobilenetv20_features_linearbottleneck0_batchnormcudnnoff1_fwd 0=8 1=1 5=1 6=128
Convolution mobilenetv20_features_linearbottleneck1_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck0_batchnormcudnnoff1_fwd mobilenetv20_features_linearbottleneck1_relu60_relu6 0=48 1=1 5=1 6=384 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck1_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck1_relu60_relu6 mobilenetv20_features_linearbottleneck1_relu61_relu6 0=48 1=3 3=2 4=1 5=1 6=432 7=48 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck1_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck1_relu61_relu6 mobilenetv20_features_linearbottleneck1_batchnormcudnnoff2_fwd 0=12 1=1 5=1 6=576
Split splitncnn_0 1 2 mobilenetv20_features_linearbottleneck1_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck1_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck1_batchnormcudnnoff2_fwd_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck2_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck1_batchnormcudnnoff2_fwd_splitncnn_1 mobilenetv20_features_linearbottleneck2_relu60_relu6 0=72 1=1 5=1 6=864 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck2_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck2_relu60_relu6 mobilenetv20_features_linearbottleneck2_relu61_relu6 0=72 1=3 4=1 5=1 6=648 7=72 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck2_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck2_relu61_relu6 mobilenetv20_features_linearbottleneck2_batchnormcudnnoff2_fwd 0=12 1=1 5=1 6=864
BinaryOp mobilenetv20_features_linearbottleneck2_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck2_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck1_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck2_elemwise_add0
Convolution mobilenetv20_features_linearbottleneck3_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck2_elemwise_add0 mobilenetv20_features_linearbottleneck3_relu60_relu6 0=72 1=1 5=1 6=864 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck3_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck3_relu60_relu6 mobilenetv20_features_linearbottleneck3_relu61_relu6 0=72 1=3 3=2 4=1 5=1 6=648 7=72 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck3_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck3_relu61_relu6 mobilenetv20_features_linearbottleneck3_batchnormcudnnoff2_fwd 0=16 1=1 5=1 6=1152
Split splitncnn_1 1 2 mobilenetv20_features_linearbottleneck3_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck3_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck3_batchnormcudnnoff2_fwd_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck4_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck3_batchnormcudnnoff2_fwd_splitncnn_1 mobilenetv20_features_linearbottleneck4_relu60_relu6 0=96 1=1 5=1 6=1536 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck4_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck4_relu60_relu6 mobilenetv20_features_linearbottleneck4_relu61_relu6 0=96 1=3 4=1 5=1 6=864 7=96 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck4_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck4_relu61_relu6 mobilenetv20_features_linearbottleneck4_batchnormcudnnoff2_fwd 0=16 1=1 5=1 6=1536
BinaryOp mobilenetv20_features_linearbottleneck4_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck4_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck3_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck4_elemwise_add0
Split splitncnn_2 1 2 mobilenetv20_features_linearbottleneck4_elemwise_add0 mobilenetv20_features_linearbottleneck4_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck4_elemwise_add0_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck5_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck4_elemwise_add0_splitncnn_1 mobilenetv20_features_linearbottleneck5_relu60_relu6 0=96 1=1 5=1 6=1536 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck5_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck5_relu60_relu6 mobilenetv20_features_linearbottleneck5_relu61_relu6 0=96 1=3 4=1 5=1 6=864 7=96 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck5_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck5_relu61_relu6 mobilenetv20_features_linearbottleneck5_batchnormcudnnoff2_fwd 0=16 1=1 5=1 6=1536
BinaryOp mobilenetv20_features_linearbottleneck5_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck5_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck4_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck5_elemwise_add0
Convolution mobilenetv20_features_linearbottleneck6_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck5_elemwise_add0 mobilenetv20_features_linearbottleneck6_relu60_relu6 0=96 1=1 5=1 6=1536 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck6_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck6_relu60_relu6 mobilenetv20_features_linearbottleneck6_relu61_relu6 0=96 1=3 3=2 4=1 5=1 6=864 7=96 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck6_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck6_relu61_relu6 mobilenetv20_features_linearbottleneck6_batchnormcudnnoff2_fwd 0=32 1=1 5=1 6=3072
Split splitncnn_3 1 2 mobilenetv20_features_linearbottleneck6_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck6_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck6_batchnormcudnnoff2_fwd_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck7_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck6_batchnormcudnnoff2_fwd_splitncnn_1 mobilenetv20_features_linearbottleneck7_relu60_relu6 0=192 1=1 5=1 6=6144 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck7_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck7_relu60_relu6 mobilenetv20_features_linearbottleneck7_relu61_relu6 0=192 1=3 4=1 5=1 6=1728 7=192 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck7_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck7_relu61_relu6 mobilenetv20_features_linearbottleneck7_batchnormcudnnoff2_fwd 0=32 1=1 5=1 6=6144
BinaryOp mobilenetv20_features_linearbottleneck7_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck7_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck6_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck7_elemwise_add0
Split splitncnn_4 1 2 mobilenetv20_features_linearbottleneck7_elemwise_add0 mobilenetv20_features_linearbottleneck7_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck7_elemwise_add0_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck8_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck7_elemwise_add0_splitncnn_1 mobilenetv20_features_linearbottleneck8_relu60_relu6 0=192 1=1 5=1 6=6144 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck8_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck8_relu60_relu6 mobilenetv20_features_linearbottleneck8_relu61_relu6 0=192 1=3 4=1 5=1 6=1728 7=192 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck8_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck8_relu61_relu6 mobilenetv20_features_linearbottleneck8_batchnormcudnnoff2_fwd 0=32 1=1 5=1 6=6144
BinaryOp mobilenetv20_features_linearbottleneck8_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck8_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck7_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck8_elemwise_add0
Split splitncnn_5 1 2 mobilenetv20_features_linearbottleneck8_elemwise_add0 mobilenetv20_features_linearbottleneck8_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck8_elemwise_add0_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck9_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck8_elemwise_add0_splitncnn_1 mobilenetv20_features_linearbottleneck9_relu60_relu6 0=192 1=1 5=1 6=6144 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck9_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck9_relu60_relu6 mobilenetv20_features_linearbottleneck9_relu61_relu6 0=192 1=3 4=1 5=1 6=1728 7=192 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck9_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck9_relu61_relu6 mobilenetv20_features_linearbottleneck9_batchnormcudnnoff2_fwd 0=32 1=1 5=1 6=6144
BinaryOp mobilenetv20_features_linearbottleneck9_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck9_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck8_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck9_elemwise_add0
Convolution mobilenetv20_features_linearbottleneck10_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck9_elemwise_add0 mobilenetv20_features_linearbottleneck10_relu60_relu6 0=192 1=1 5=1 6=6144 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck10_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck10_relu60_relu6 mobilenetv20_features_linearbottleneck10_relu61_relu6 0=192 1=3 4=1 5=1 6=1728 7=192 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck10_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck10_relu61_relu6 mobilenetv20_features_linearbottleneck10_batchnormcudnnoff2_fwd 0=48 1=1 5=1 6=9216
Split splitncnn_6 1 2 mobilenetv20_features_linearbottleneck10_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck10_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck10_batchnormcudnnoff2_fwd_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck11_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck10_batchnormcudnnoff2_fwd_splitncnn_1 mobilenetv20_features_linearbottleneck11_relu60_relu6 0=288 1=1 5=1 6=13824 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck11_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck11_relu60_relu6 mobilenetv20_features_linearbottleneck11_relu61_relu6 0=288 1=3 4=1 5=1 6=2592 7=288 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck11_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck11_relu61_relu6 mobilenetv20_features_linearbottleneck11_batchnormcudnnoff2_fwd 0=48 1=1 5=1 6=13824
BinaryOp mobilenetv20_features_linearbottleneck11_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck11_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck10_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck11_elemwise_add0
Split splitncnn_7 1 2 mobilenetv20_features_linearbottleneck11_elemwise_add0 mobilenetv20_features_linearbottleneck11_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck11_elemwise_add0_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck12_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck11_elemwise_add0_splitncnn_1 mobilenetv20_features_linearbottleneck12_relu60_relu6 0=288 1=1 5=1 6=13824 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck12_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck12_relu60_relu6 mobilenetv20_features_linearbottleneck12_relu61_relu6 0=288 1=3 4=1 5=1 6=2592 7=288 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck12_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck12_relu61_relu6 mobilenetv20_features_linearbottleneck12_batchnormcudnnoff2_fwd 0=48 1=1 5=1 6=13824
BinaryOp mobilenetv20_features_linearbottleneck12_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck12_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck11_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck12_elemwise_add0
Convolution mobilenetv20_features_linearbottleneck13_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck12_elemwise_add0 mobilenetv20_features_linearbottleneck13_relu60_relu6 0=288 1=1 5=1 6=13824 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck13_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck13_relu60_relu6 mobilenetv20_features_linearbottleneck13_relu61_relu6 0=288 1=3 3=2 4=1 5=1 6=2592 7=288 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck13_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck13_relu61_relu6 mobilenetv20_features_linearbottleneck13_batchnormcudnnoff2_fwd 0=80 1=1 5=1 6=23040
Split splitncnn_8 1 2 mobilenetv20_features_linearbottleneck13_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck13_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck13_batchnormcudnnoff2_fwd_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck14_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck13_batchnormcudnnoff2_fwd_splitncnn_1 mobilenetv20_features_linearbottleneck14_relu60_relu6 0=480 1=1 5=1 6=38400 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck14_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck14_relu60_relu6 mobilenetv20_features_linearbottleneck14_relu61_relu6 0=480 1=3 4=1 5=1 6=4320 7=480 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck14_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck14_relu61_relu6 mobilenetv20_features_linearbottleneck14_batchnormcudnnoff2_fwd 0=80 1=1 5=1 6=38400
BinaryOp mobilenetv20_features_linearbottleneck14_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck14_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck13_batchnormcudnnoff2_fwd_splitncnn_0 mobilenetv20_features_linearbottleneck14_elemwise_add0
Split splitncnn_9 1 2 mobilenetv20_features_linearbottleneck14_elemwise_add0 mobilenetv20_features_linearbottleneck14_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck14_elemwise_add0_splitncnn_1
Convolution mobilenetv20_features_linearbottleneck15_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck14_elemwise_add0_splitncnn_1 mobilenetv20_features_linearbottleneck15_relu60_relu6 0=480 1=1 5=1 6=38400 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck15_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck15_relu60_relu6 mobilenetv20_features_linearbottleneck15_relu61_relu6 0=480 1=3 4=1 5=1 6=4320 7=480 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck15_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck15_relu61_relu6 mobilenetv20_features_linearbottleneck15_batchnormcudnnoff2_fwd 0=80 1=1 5=1 6=38400
BinaryOp mobilenetv20_features_linearbottleneck15_elemwise_add0 2 1 mobilenetv20_features_linearbottleneck15_batchnormcudnnoff2_fwd mobilenetv20_features_linearbottleneck14_elemwise_add0_splitncnn_0 mobilenetv20_features_linearbottleneck15_elemwise_add0
Convolution mobilenetv20_features_linearbottleneck16_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck15_elemwise_add0 mobilenetv20_features_linearbottleneck16_relu60_relu6 0=480 1=1 5=1 6=38400 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise mobilenetv20_features_linearbottleneck16_conv1_fwd 1 1 mobilenetv20_features_linearbottleneck16_relu60_relu6 mobilenetv20_features_linearbottleneck16_relu61_relu6 0=480 1=3 4=1 5=1 6=4320 7=480 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution mobilenetv20_features_linearbottleneck16_conv2_fwd 1 1 mobilenetv20_features_linearbottleneck16_relu61_relu6 mobilenetv20_features_linearbottleneck16_batchnormcudnnoff2_fwd 0=160 1=1 5=1 6=76800
Convolution hybridsequential0_conv0_fwd 1 1 mobilenetv20_features_linearbottleneck16_batchnormcudnnoff2_fwd hybridsequential0_relu0_fwd 0=128 1=1 5=1 6=20480 9=1
DeconvolutionDepthWise hybridsequential0_conv1_fwd 1 1 hybridsequential0_relu0_fwd hybridsequential0_relu1_fwd 0=128 1=4 3=2 4=1 5=1 6=2048 7=128 9=1
Convolution hybridsequential0_conv2_fwd 1 1 hybridsequential0_relu1_fwd hybridsequential0_relu2_fwd 0=128 1=1 5=1 6=16384 9=1
DeconvolutionDepthWise hybridsequential0_conv3_fwd 1 1 hybridsequential0_relu2_fwd hybridsequential0_relu3_fwd 0=128 1=4 3=2 4=1 5=1 6=2048 7=128 9=1
Convolution hybridsequential0_conv4_fwd 1 1 hybridsequential0_relu3_fwd hybridsequential0_relu4_fwd 0=128 1=1 5=1 6=16384 9=1
DeconvolutionDepthWise hybridsequential0_conv5_fwd 1 1 hybridsequential0_relu4_fwd hybridsequential0_relu5_fwd 0=128 1=4 3=2 4=1 5=1 6=2048 7=128 9=1
Convolution hybridsequential0_conv6_fwd 1 1 hybridsequential0_relu5_fwd hybridsequential0_relu6_fwd 0=128 1=1 5=1 6=16384 9=1
Convolution hybridsequential0_conv7_fwd 1 1 hybridsequential0_relu6_fwd hybridsequential0_conv7_fwd 0=17 1=1 6=2176

@ -0,0 +1,209 @@
7767517
207 225
Input 0 0 1 0
Convolution 346 1 1 0 346 0=16 1=3 11=3 2=1 12=1 3=2 13=2 4=1 14=1 15=1 16=1 5=0 6=432
BatchNorm 347 1 1 346 347 0=16
ReLU 348 1 1 347 348
Convolution 349 1 1 348 349 0=16 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=256
BatchNorm 350 1 1 349 350 0=16
ReLU 351 1 1 350 351
ConvolutionDepthWise 352 1 1 351 352 0=16 1=3 11=3 2=1 12=1 3=2 13=2 4=1 14=1 15=1 16=1 5=0 6=144 7=16
BatchNorm 353 1 1 352 353 0=16
ReLU 354 1 1 353 354
Convolution 355 1 1 354 355 0=16 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=256
BatchNorm 356 1 1 355 356 0=16
Split splitncnn_0 1 2 356 356_splitncnn_0 356_splitncnn_1
Convolution 357 1 1 356_splitncnn_1 357 0=72 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=1152
BatchNorm 358 1 1 357 358 0=72
ReLU 359 1 1 358 359
ConvolutionDepthWise 360 1 1 359 360 0=72 1=3 11=3 2=1 12=1 3=2 13=2 4=1 14=1 15=1 16=1 5=0 6=648 7=72
BatchNorm 361 1 1 360 361 0=72
ReLU 362 1 1 361 362
Convolution 363 1 1 362 363 0=24 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=1728
BatchNorm 364 1 1 363 364 0=24
Split splitncnn_1 1 2 364 364_splitncnn_0 364_splitncnn_1
Convolution 365 1 1 364_splitncnn_1 365 0=88 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=2112
BatchNorm 366 1 1 365 366 0=88
ReLU 367 1 1 366 367
ConvolutionDepthWise 368 1 1 367 368 0=88 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=792 7=88
BatchNorm 369 1 1 368 369 0=88
ReLU 370 1 1 369 370
Convolution 371 1 1 370 371 0=24 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=2112
BatchNorm 372 1 1 371 372 0=24
BinaryOp 373 2 1 372 364_splitncnn_0 373 0=0
Split splitncnn_2 1 2 373 373_splitncnn_0 373_splitncnn_1
Convolution 374 1 1 373_splitncnn_1 374 0=96 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=2304
BatchNorm 375 1 1 374 375 0=96
ReLU 376 1 1 375 376
ConvolutionDepthWise 377 1 1 376 377 0=96 1=5 11=5 2=1 12=1 3=2 13=2 4=2 14=2 15=2 16=2 5=0 6=2400 7=96
BatchNorm 378 1 1 377 378 0=96
ReLU 379 1 1 378 379
Convolution 380 1 1 379 380 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=3840
BatchNorm 381 1 1 380 381 0=40
Split splitncnn_3 1 2 381 381_splitncnn_0 381_splitncnn_1
Pooling 382 1 1 381_splitncnn_1 382 0=1 4=1
Convolution 383 1 1 382 383 0=10 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=400
BatchNorm 384 1 1 383 384 0=10
ReLU 385 1 1 384 385
Convolution 386 1 1 385 386 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=400
BatchNorm 387 1 1 386 387 0=40
Sigmoid 388 1 1 387 388
BinaryOp 389 2 1 381_splitncnn_0 388 389 0=2
Split splitncnn_4 1 2 389 389_splitncnn_0 389_splitncnn_1
Convolution 390 1 1 389_splitncnn_1 390 0=240 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=9600
BatchNorm 391 1 1 390 391 0=240
ReLU 392 1 1 391 392
ConvolutionDepthWise 393 1 1 392 393 0=240 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=0 6=6000 7=240
BatchNorm 394 1 1 393 394 0=240
ReLU 395 1 1 394 395
Convolution 396 1 1 395 396 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=9600
BatchNorm 397 1 1 396 397 0=40
Split splitncnn_5 1 2 397 397_splitncnn_0 397_splitncnn_1
Pooling 398 1 1 397_splitncnn_1 398 0=1 4=1
Convolution 399 1 1 398 399 0=10 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=400
BatchNorm 400 1 1 399 400 0=10
ReLU 401 1 1 400 401
Convolution 402 1 1 401 402 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=400
BatchNorm 403 1 1 402 403 0=40
Sigmoid 404 1 1 403 404
BinaryOp 405 2 1 397_splitncnn_0 404 405 0=2
BinaryOp 406 2 1 405 389_splitncnn_0 406 0=0
Split splitncnn_6 1 2 406 406_splitncnn_0 406_splitncnn_1
Convolution 407 1 1 406_splitncnn_1 407 0=240 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=9600
BatchNorm 408 1 1 407 408 0=240
ReLU 409 1 1 408 409
ConvolutionDepthWise 410 1 1 409 410 0=240 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=0 6=6000 7=240
BatchNorm 411 1 1 410 411 0=240
ReLU 412 1 1 411 412
Convolution 413 1 1 412 413 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=9600
BatchNorm 414 1 1 413 414 0=40
Split splitncnn_7 1 2 414 414_splitncnn_0 414_splitncnn_1
Pooling 415 1 1 414_splitncnn_1 415 0=1 4=1
Convolution 416 1 1 415 416 0=10 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=400
BatchNorm 417 1 1 416 417 0=10
ReLU 418 1 1 417 418
Convolution 419 1 1 418 419 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=400
BatchNorm 420 1 1 419 420 0=40
Sigmoid 421 1 1 420 421
BinaryOp 422 2 1 414_splitncnn_0 421 422 0=2
BinaryOp 423 2 1 422 406_splitncnn_0 423 0=0
Split splitncnn_8 1 2 423 423_splitncnn_0 423_splitncnn_1
Convolution 424 1 1 423_splitncnn_1 424 0=120 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=4800
BatchNorm 425 1 1 424 425 0=120
ReLU 426 1 1 425 426
ConvolutionDepthWise 427 1 1 426 427 0=120 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=0 6=3000 7=120
BatchNorm 428 1 1 427 428 0=120
ReLU 429 1 1 428 429
Convolution 430 1 1 429 430 0=48 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=5760
BatchNorm 431 1 1 430 431 0=48
Split splitncnn_9 1 2 431 431_splitncnn_0 431_splitncnn_1
Pooling 432 1 1 431_splitncnn_1 432 0=1 4=1
Convolution 433 1 1 432 433 0=12 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=576
BatchNorm 434 1 1 433 434 0=12
ReLU 435 1 1 434 435
Convolution 436 1 1 435 436 0=48 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=576
BatchNorm 437 1 1 436 437 0=48
Sigmoid 438 1 1 437 438
BinaryOp 439 2 1 431_splitncnn_0 438 439 0=2
Convolution 440 1 1 423_splitncnn_0 440 0=48 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=1920
BatchNorm 441 1 1 440 441 0=48
BinaryOp 442 2 1 439 441 442 0=0
Split splitncnn_10 1 2 442 442_splitncnn_0 442_splitncnn_1
Convolution 443 1 1 442_splitncnn_1 443 0=144 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=6912
BatchNorm 444 1 1 443 444 0=144
ReLU 445 1 1 444 445
ConvolutionDepthWise 446 1 1 445 446 0=144 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=0 6=3600 7=144
BatchNorm 447 1 1 446 447 0=144
ReLU 448 1 1 447 448
Convolution 449 1 1 448 449 0=48 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=6912
BatchNorm 450 1 1 449 450 0=48
Split splitncnn_11 1 2 450 450_splitncnn_0 450_splitncnn_1
Pooling 451 1 1 450_splitncnn_1 451 0=1 4=1
Convolution 452 1 1 451 452 0=12 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=576
BatchNorm 453 1 1 452 453 0=12
ReLU 454 1 1 453 454
Convolution 455 1 1 454 455 0=48 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=576
BatchNorm 456 1 1 455 456 0=48
Sigmoid 457 1 1 456 457
BinaryOp 458 2 1 450_splitncnn_0 457 458 0=2
BinaryOp 459 2 1 458 442_splitncnn_0 459 0=0
Split splitncnn_12 1 2 459 459_splitncnn_0 459_splitncnn_1
Convolution 460 1 1 459_splitncnn_1 460 0=288 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=13824
BatchNorm 461 1 1 460 461 0=288
ReLU 462 1 1 461 462
ConvolutionDepthWise 463 1 1 462 463 0=288 1=5 11=5 2=1 12=1 3=2 13=2 4=2 14=2 15=2 16=2 5=0 6=7200 7=288
BatchNorm 464 1 1 463 464 0=288
ReLU 465 1 1 464 465
Convolution 466 1 1 465 466 0=96 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=27648
BatchNorm 467 1 1 466 467 0=96
Split splitncnn_13 1 2 467 467_splitncnn_0 467_splitncnn_1
Pooling 468 1 1 467_splitncnn_1 468 0=1 4=1
Convolution 469 1 1 468 469 0=24 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=2304
BatchNorm 470 1 1 469 470 0=24
ReLU 471 1 1 470 471
Convolution 472 1 1 471 472 0=96 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=2304
BatchNorm 473 1 1 472 473 0=96
Sigmoid 474 1 1 473 474
BinaryOp 475 2 1 467_splitncnn_0 474 475 0=2
Convolution 476 1 1 475 476 0=64 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=6144
BatchNorm 477 1 1 476 477 0=64
ReLU 478 1 1 477 478
Deconvolution 479 1 1 478 479 0=64 1=2 11=2 2=1 12=1 3=2 13=2 4=0 14=0 15=0 16=0 5=0 6=16384
Convolution 480 1 1 479 480 0=64 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=36864
BatchNorm 481 1 1 480 481 0=64
ReLU 482 1 1 481 482
Convolution 483 1 1 459_splitncnn_0 483 0=64 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=3072
BatchNorm 484 1 1 483 484 0=64
ReLU 485 1 1 484 485
BinaryOp 486 2 1 482 485 486 0=0
Deconvolution 487 1 1 486 487 0=64 1=2 11=2 2=1 12=1 3=2 13=2 4=0 14=0 15=0 16=0 5=0 6=16384
Convolution 488 1 1 487 488 0=64 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=36864
BatchNorm 489 1 1 488 489 0=64
ReLU 490 1 1 489 490
Convolution 491 1 1 373_splitncnn_0 491 0=64 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=1536
BatchNorm 492 1 1 491 492 0=64
ReLU 493 1 1 492 493
BinaryOp 494 2 1 490 493 494 0=0
Deconvolution 495 1 1 494 495 0=64 1=2 11=2 2=1 12=1 3=2 13=2 4=0 14=0 15=0 16=0 5=0 6=16384
Convolution 496 1 1 495 496 0=64 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=36864
BatchNorm 497 1 1 496 497 0=64
ReLU 498 1 1 497 498
Convolution 499 1 1 356_splitncnn_0 499 0=64 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=1024
BatchNorm 500 1 1 499 500 0=64
ReLU 501 1 1 500 501
BinaryOp 502 2 1 498 501 502 0=0
Split splitncnn_14 1 2 502 502_splitncnn_0 502_splitncnn_1
Convolution 503 1 1 502_splitncnn_1 503 0=32 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=18432
BatchNorm 504 1 1 503 504 0=32
ReLU 505 1 1 504 505
Convolution 506 1 1 502_splitncnn_0 506 0=16 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=9216
BatchNorm 507 1 1 506 507 0=16
ReLU 508 1 1 507 508
Split splitncnn_15 1 2 508 508_splitncnn_0 508_splitncnn_1
Convolution 509 1 1 508_splitncnn_1 509 0=16 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=2304
BatchNorm 510 1 1 509 510 0=16
ReLU 511 1 1 510 511
Convolution 512 1 1 508_splitncnn_0 512 0=16 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=2304
BatchNorm 513 1 1 512 513 0=16
ReLU 514 1 1 513 514
Convolution 515 1 1 514 515 0=16 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=2304
BatchNorm 516 1 1 515 516 0=16
ReLU 517 1 1 516 517
Concat 518 2 1 511 517 518 0=0
Concat 519 2 1 505 518 519 0=0
Split splitncnn_16 1 3 519 519_splitncnn_0 519_splitncnn_1 519_splitncnn_2
Convolution 520 1 1 519_splitncnn_2 520 0=64 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=36864
BatchNorm 521 1 1 520 521 0=64
ReLU 522 1 1 521 522
Convolution 523 1 1 522 523 0=1 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=64
Convolution 524 1 1 519_splitncnn_1 524 0=64 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=36864
BatchNorm 525 1 1 524 525 0=64
ReLU 526 1 1 525 526
Convolution 527 1 1 526 527 0=4 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=256
Sigmoid hm 1 1 523 hm
UnaryOp tlrb 1 1 527 tlrb 0=7
Convolution 530 1 1 519_splitncnn_0 530 0=64 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=36864
BatchNorm 531 1 1 530 531 0=64
ReLU 532 1 1 531 532
Convolution landmark 1 1 532 landmark 0=10 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=640
Pooling pool_hm 1 1 hm pool_hm 0=0 1=3 11=3 2=1 12=1 3=1 13=1 14=1 15=1 5=1

@ -0,0 +1,82 @@
7767517
80 91
Input input.1 0 1 input.1
Convolution Conv_0 1 1 input.1 339 0=32 1=3 3=2 4=1 5=1 6=864 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_5 1 1 339 344 0=32 1=3 4=1 5=1 6=288 7=32 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_10 1 1 344 346 0=16 1=1 5=1 6=512
Convolution Conv_12 1 1 346 351 0=96 1=1 5=1 6=1536 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_17 1 1 351 356 0=96 1=3 3=2 4=1 5=1 6=864 7=96 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_22 1 1 356 358 0=24 1=1 5=1 6=2304
Split splitncnn_0 1 2 358 358_splitncnn_0 358_splitncnn_1
Convolution Conv_24 1 1 358_splitncnn_1 363 0=144 1=1 5=1 6=3456 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_29 1 1 363 368 0=144 1=3 4=1 5=1 6=1296 7=144 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_34 1 1 368 370 0=24 1=1 5=1 6=3456
BinaryOp Add_36 2 1 358_splitncnn_0 370 371
Convolution Conv_37 1 1 371 376 0=144 1=1 5=1 6=3456 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_42 1 1 376 381 0=144 1=3 3=2 4=1 5=1 6=1296 7=144 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_47 1 1 381 383 0=32 1=1 5=1 6=4608
Split splitncnn_1 1 2 383 383_splitncnn_0 383_splitncnn_1
Convolution Conv_49 1 1 383_splitncnn_1 388 0=192 1=1 5=1 6=6144 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_54 1 1 388 393 0=192 1=3 4=1 5=1 6=1728 7=192 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_59 1 1 393 395 0=32 1=1 5=1 6=6144
BinaryOp Add_61 2 1 383_splitncnn_0 395 396
Split splitncnn_2 1 2 396 396_splitncnn_0 396_splitncnn_1
Convolution Conv_62 1 1 396_splitncnn_1 401 0=192 1=1 5=1 6=6144 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_67 1 1 401 406 0=192 1=3 4=1 5=1 6=1728 7=192 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_72 1 1 406 408 0=32 1=1 5=1 6=6144
BinaryOp Add_74 2 1 396_splitncnn_0 408 409
Convolution Conv_75 1 1 409 414 0=192 1=1 5=1 6=6144 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_80 1 1 414 419 0=192 1=3 2=2 4=2 5=1 6=1728 7=192 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_85 1 1 419 421 0=64 1=1 5=1 6=12288
Split splitncnn_3 1 2 421 421_splitncnn_0 421_splitncnn_1
Convolution Conv_87 1 1 421_splitncnn_1 426 0=384 1=1 5=1 6=24576 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_92 1 1 426 431 0=384 1=3 4=1 5=1 6=3456 7=384 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_97 1 1 431 433 0=64 1=1 5=1 6=24576
BinaryOp Add_99 2 1 421_splitncnn_0 433 434
Split splitncnn_4 1 2 434 434_splitncnn_0 434_splitncnn_1
Convolution Conv_100 1 1 434_splitncnn_1 439 0=384 1=1 5=1 6=24576 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_105 1 1 439 444 0=384 1=3 4=1 5=1 6=3456 7=384 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_110 1 1 444 446 0=64 1=1 5=1 6=24576
BinaryOp Add_112 2 1 434_splitncnn_0 446 447
Split splitncnn_5 1 2 447 447_splitncnn_0 447_splitncnn_1
Convolution Conv_113 1 1 447_splitncnn_1 452 0=384 1=1 5=1 6=24576 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_118 1 1 452 457 0=384 1=3 4=1 5=1 6=3456 7=384 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_123 1 1 457 459 0=64 1=1 5=1 6=24576
BinaryOp Add_125 2 1 447_splitncnn_0 459 460
Convolution Conv_126 1 1 460 465 0=384 1=1 5=1 6=24576 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_131 1 1 465 470 0=384 1=3 2=2 4=2 5=1 6=3456 7=384 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_136 1 1 470 472 0=96 1=1 5=1 6=36864
Split splitncnn_6 1 2 472 472_splitncnn_0 472_splitncnn_1
Convolution Conv_138 1 1 472_splitncnn_1 477 0=576 1=1 5=1 6=55296 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_143 1 1 477 482 0=576 1=3 4=1 5=1 6=5184 7=576 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_148 1 1 482 484 0=96 1=1 5=1 6=55296
BinaryOp Add_150 2 1 472_splitncnn_0 484 485
Split splitncnn_7 1 2 485 485_splitncnn_0 485_splitncnn_1
Convolution Conv_151 1 1 485_splitncnn_1 490 0=576 1=1 5=1 6=55296 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_156 1 1 490 495 0=576 1=3 4=1 5=1 6=5184 7=576 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_161 1 1 495 497 0=96 1=1 5=1 6=55296
BinaryOp Add_163 2 1 485_splitncnn_0 497 498
Convolution Conv_164 1 1 498 503 0=576 1=1 5=1 6=55296 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_169 1 1 503 508 0=576 1=3 2=4 4=4 5=1 6=5184 7=576 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_174 1 1 508 510 0=160 1=1 5=1 6=92160
Split splitncnn_8 1 2 510 510_splitncnn_0 510_splitncnn_1
Convolution Conv_176 1 1 510_splitncnn_1 515 0=960 1=1 5=1 6=153600 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_181 1 1 515 520 0=960 1=3 4=1 5=1 6=8640 7=960 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_186 1 1 520 522 0=160 1=1 5=1 6=153600
BinaryOp Add_188 2 1 510_splitncnn_0 522 523
Split splitncnn_9 1 2 523 523_splitncnn_0 523_splitncnn_1
Convolution Conv_189 1 1 523_splitncnn_1 528 0=960 1=1 5=1 6=153600 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_194 1 1 528 533 0=960 1=3 4=1 5=1 6=8640 7=960 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_199 1 1 533 535 0=160 1=1 5=1 6=153600
BinaryOp Add_201 2 1 523_splitncnn_0 535 536
Convolution Conv_202 1 1 536 541 0=960 1=1 5=1 6=153600 9=3 -23310=2,0.000000e+00,6.000000e+00
ConvolutionDepthWise Conv_207 1 1 541 546 0=960 1=3 2=4 4=4 5=1 6=8640 7=960 9=3 -23310=2,0.000000e+00,6.000000e+00
Convolution Conv_212 1 1 546 548 0=320 1=1 5=1 6=307200
Split splitncnn_10 1 2 548 548_splitncnn_0 548_splitncnn_1
Convolution Conv_214 1 1 548_splitncnn_1 551 0=512 1=3 4=1 5=1 6=1474560 9=1
Convolution Conv_217 1 1 551 554 0=512 1=3 4=1 5=1 6=2359296 9=1
Concat Concat_220 2 1 548_splitncnn_0 554 555
Convolution Conv_221 1 1 555 558 0=512 1=3 4=1 5=1 6=3833856 9=1
Convolution Conv_224 1 1 558 559 0=19 1=1 5=1 6=9728
Interp Resize_233 1 1 559 570 0=2 3=512 4=512
Interp Resize_242 1 1 570 581 0=2 3=512 4=512

@ -0,0 +1,82 @@
7767517
80 89
Input data 0 1 data
Convolution Conv_0 1 1 data 253 0=32 1=3 3=2 4=1 5=1 6=864 9=1
ConvolutionDepthWise Conv_2 1 1 253 256 0=32 1=3 4=1 5=1 6=288 7=32 9=1
Convolution Conv_4 1 1 256 259 0=64 1=1 5=1 6=2048 9=1
ConvolutionDepthWise Conv_6 1 1 259 262 0=64 1=3 3=2 4=1 5=1 6=576 7=64 9=1
Convolution Conv_8 1 1 262 265 0=128 1=1 5=1 6=8192 9=1
ConvolutionDepthWise Conv_10 1 1 265 268 0=128 1=3 4=1 5=1 6=1152 7=128 9=1
Convolution Conv_12 1 1 268 271 0=128 1=1 5=1 6=16384 9=1
ConvolutionDepthWise Conv_14 1 1 271 274 0=128 1=3 3=2 4=1 5=1 6=1152 7=128 9=1
Convolution Conv_16 1 1 274 277 0=256 1=1 5=1 6=32768 9=1
ConvolutionDepthWise Conv_18 1 1 277 280 0=256 1=3 4=1 5=1 6=2304 7=256 9=1
Convolution Conv_20 1 1 280 283 0=256 1=1 5=1 6=65536 9=1
ConvolutionDepthWise Conv_22 1 1 283 286 0=256 1=3 4=1 5=1 6=2304 7=256 9=1
Convolution Conv_24 1 1 286 289 0=512 1=1 5=1 6=131072 9=1
ConvolutionDepthWise Conv_26 1 1 289 292 0=512 1=3 2=2 4=2 5=1 6=4608 7=512 9=1
Convolution Conv_28 1 1 292 295 0=512 1=1 5=1 6=262144 9=1
ConvolutionDepthWise Conv_30 1 1 295 298 0=512 1=3 4=1 5=1 6=4608 7=512 9=1
Convolution Conv_32 1 1 298 301 0=512 1=1 5=1 6=262144 9=1
ConvolutionDepthWise Conv_34 1 1 301 304 0=512 1=3 4=1 5=1 6=4608 7=512 9=1
Convolution Conv_36 1 1 304 307 0=512 1=1 5=1 6=262144 9=1
ConvolutionDepthWise Conv_38 1 1 307 310 0=512 1=3 4=1 5=1 6=4608 7=512 9=1
Convolution Conv_40 1 1 310 313 0=512 1=1 5=1 6=262144 9=1
ConvolutionDepthWise Conv_42 1 1 313 316 0=512 1=3 4=1 5=1 6=4608 7=512 9=1
Convolution Conv_44 1 1 316 319 0=512 1=1 5=1 6=262144 9=1
Convolution Conv_46 1 1 319 321 0=128 1=1 5=1 6=65536 9=1
Split splitncnn_0 1 2 321 321_splitncnn_0 321_splitncnn_1
ConvolutionDepthWise Conv_48 1 1 321_splitncnn_1 322 0=128 1=3 4=1 6=1152 7=128
ELU Elu_49 1 1 322 323 0=1.000000e+00
Convolution Conv_50 1 1 323 324 0=128 1=1 6=16384
ELU Elu_51 1 1 324 325 0=1.000000e+00
ConvolutionDepthWise Conv_52 1 1 325 326 0=128 1=3 4=1 6=1152 7=128
ELU Elu_53 1 1 326 327 0=1.000000e+00
Convolution Conv_54 1 1 327 328 0=128 1=1 6=16384
ELU Elu_55 1 1 328 329 0=1.000000e+00
ConvolutionDepthWise Conv_56 1 1 329 330 0=128 1=3 4=1 6=1152 7=128
ELU Elu_57 1 1 330 331 0=1.000000e+00
Convolution Conv_58 1 1 331 332 0=128 1=1 6=16384
ELU Elu_59 1 1 332 333 0=1.000000e+00
BinaryOp Add_60 2 1 321_splitncnn_0 333 334
Convolution Conv_61 1 1 334 336 0=128 1=3 4=1 5=1 6=147456 9=1
Split splitncnn_1 1 2 336 336_splitncnn_0 336_splitncnn_1
Convolution Conv_63 1 1 336_splitncnn_1 338 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_65 1 1 338 340 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_67 1 1 340 342 0=128 1=3 4=1 5=1 6=147456 9=1
Split splitncnn_2 1 2 342 342_splitncnn_0 342_splitncnn_1
Convolution Conv_69 1 1 342_splitncnn_1 344 0=512 1=1 5=1 6=65536 9=1
Convolution Conv_71 1 1 344 stage_0_output_1_heatmaps 0=19 1=1 5=1 6=9728
Convolution Conv_72 1 1 342_splitncnn_0 347 0=512 1=1 5=1 6=65536 9=1
Convolution Conv_74 1 1 347 stage_0_output_0_pafs 0=38 1=1 5=1 6=19456
Concat Concat_75 3 1 336_splitncnn_0 stage_0_output_1_heatmaps stage_0_output_0_pafs 349
Convolution Conv_76 1 1 349 351 0=128 1=1 5=1 6=23680 9=1
Split splitncnn_3 1 2 351 351_splitncnn_0 351_splitncnn_1
Convolution Conv_78 1 1 351_splitncnn_1 354 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_80 1 1 354 357 0=128 1=3 2=2 4=2 5=1 6=147456 9=1
BinaryOp Add_82 2 1 351_splitncnn_0 357 358
Convolution Conv_83 1 1 358 360 0=128 1=1 5=1 6=16384 9=1
Split splitncnn_4 1 2 360 360_splitncnn_0 360_splitncnn_1
Convolution Conv_85 1 1 360_splitncnn_1 363 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_87 1 1 363 366 0=128 1=3 2=2 4=2 5=1 6=147456 9=1
BinaryOp Add_89 2 1 360_splitncnn_0 366 367
Convolution Conv_90 1 1 367 369 0=128 1=1 5=1 6=16384 9=1
Split splitncnn_5 1 2 369 369_splitncnn_0 369_splitncnn_1
Convolution Conv_92 1 1 369_splitncnn_1 372 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_94 1 1 372 375 0=128 1=3 2=2 4=2 5=1 6=147456 9=1
BinaryOp Add_96 2 1 369_splitncnn_0 375 376
Convolution Conv_97 1 1 376 378 0=128 1=1 5=1 6=16384 9=1
Split splitncnn_6 1 2 378 378_splitncnn_0 378_splitncnn_1
Convolution Conv_99 1 1 378_splitncnn_1 381 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_101 1 1 381 384 0=128 1=3 2=2 4=2 5=1 6=147456 9=1
BinaryOp Add_103 2 1 378_splitncnn_0 384 385
Convolution Conv_104 1 1 385 387 0=128 1=1 5=1 6=16384 9=1
Split splitncnn_7 1 2 387 387_splitncnn_0 387_splitncnn_1
Convolution Conv_106 1 1 387_splitncnn_1 390 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_108 1 1 390 393 0=128 1=3 2=2 4=2 5=1 6=147456 9=1
BinaryOp Add_110 2 1 387_splitncnn_0 393 394
Split splitncnn_8 1 2 394 394_splitncnn_0 394_splitncnn_1
Convolution Conv_111 1 1 394_splitncnn_1 396 0=128 1=1 5=1 6=16384 9=1
Convolution Conv_113 1 1 396 stage_1_output_1_heatmaps 0=19 1=1 5=1 6=2432
Convolution Conv_114 1 1 394_splitncnn_0 399 0=128 1=1 5=1 6=16384 9=1
Convolution Conv_116 1 1 399 stage_1_output_0_pafs 0=38 1=1 5=1 6=4864

@ -0,0 +1,83 @@
7767517
81 89
Input data 0 1 data -23330=4,3,112,112,3 0=112 1=112 2=3
Convolution conv1_conv2d 1 1 data conv1_batchnorm_conv1_batchnorm_scale -23330=4,3,56,56,8 0=8 1=3 3=2 4=1 5=1 6=216
PReLU conv1_relu 1 1 conv1_batchnorm_conv1_batchnorm_scale conv1_batchnorm_conv1_relu -23330=4,3,56,56,8 0=8
Split splitncnn_0 1 2 conv1_batchnorm_conv1_relu conv1_batchnorm_conv1_relu_splitncnn_0 conv1_batchnorm_conv1_relu_splitncnn_1 -23330=8,3,56,56,8,3,56,56,8
Convolution res2_block0_conv_sep_conv2d 1 1 conv1_batchnorm_conv1_relu_splitncnn_1 res2_block0_conv_sep_batchnorm_res2_block0_conv_sep_batchnorm_scale -23330=4,3,56,56,8 0=8 1=1 5=1 6=64
PReLU res2_block0_conv_sep_relu 1 1 res2_block0_conv_sep_batchnorm_res2_block0_conv_sep_batchnorm_scale res2_block0_conv_sep_batchnorm_res2_block0_conv_sep_relu -23330=4,3,56,56,8 0=8
ConvolutionDepthWise res2_block0_conv_dw_conv2d 1 1 res2_block0_conv_sep_batchnorm_res2_block0_conv_sep_relu res2_block0_conv_dw_batchnorm_res2_block0_conv_dw_batchnorm_scale -23330=4,3,56,56,8 0=8 1=3 4=1 5=1 6=72 7=8
PReLU res2_block0_conv_dw_relu 1 1 res2_block0_conv_dw_batchnorm_res2_block0_conv_dw_batchnorm_scale res2_block0_conv_dw_batchnorm_res2_block0_conv_dw_relu -23330=4,3,56,56,8 0=8
Convolution res2_block0_conv_proj_conv2d 1 1 res2_block0_conv_dw_batchnorm_res2_block0_conv_dw_relu res2_block0_conv_proj_batchnorm_res2_block0_conv_proj_batchnorm_scale -23330=4,3,56,56,8 0=8 1=1 5=1 6=64
Eltwise plus0 2 1 res2_block0_conv_proj_batchnorm_res2_block0_conv_proj_batchnorm_scale conv1_batchnorm_conv1_relu_splitncnn_0 plus0 -23330=4,3,56,56,8 0=1
Convolution dconv23_conv_sep_conv2d 1 1 plus0 dconv23_conv_sep_batchnorm_dconv23_conv_sep_batchnorm_scale -23330=4,3,56,56,16 0=16 1=1 5=1 6=128
PReLU dconv23_conv_sep_relu 1 1 dconv23_conv_sep_batchnorm_dconv23_conv_sep_batchnorm_scale dconv23_conv_sep_batchnorm_dconv23_conv_sep_relu -23330=4,3,56,56,16 0=16
ConvolutionDepthWise dconv23_conv_dw_conv2d 1 1 dconv23_conv_sep_batchnorm_dconv23_conv_sep_relu dconv23_conv_dw_batchnorm_dconv23_conv_dw_batchnorm_scale -23330=4,3,28,28,16 0=16 1=3 3=2 4=1 5=1 6=144 7=16
PReLU dconv23_conv_dw_relu 1 1 dconv23_conv_dw_batchnorm_dconv23_conv_dw_batchnorm_scale dconv23_conv_dw_batchnorm_dconv23_conv_dw_relu -23330=4,3,28,28,16 0=16
Convolution dconv23_conv_proj_conv2d 1 1 dconv23_conv_dw_batchnorm_dconv23_conv_dw_relu dconv23_conv_proj_batchnorm_dconv23_conv_proj_batchnorm_scale -23330=4,3,28,28,16 0=16 1=1 5=1 6=256
Split splitncnn_1 1 2 dconv23_conv_proj_batchnorm_dconv23_conv_proj_batchnorm_scale dconv23_conv_proj_batchnorm_dconv23_conv_proj_batchnorm_scale_splitncnn_0 dconv23_conv_proj_batchnorm_dconv23_conv_proj_batchnorm_scale_splitncnn_1 -23330=8,3,28,28,16,3,28,28,16
Convolution res3_block0_conv_sep_conv2d 1 1 dconv23_conv_proj_batchnorm_dconv23_conv_proj_batchnorm_scale_splitncnn_1 res3_block0_conv_sep_batchnorm_res3_block0_conv_sep_batchnorm_scale -23330=4,3,28,28,16 0=16 1=1 5=1 6=256
PReLU res3_block0_conv_sep_relu 1 1 res3_block0_conv_sep_batchnorm_res3_block0_conv_sep_batchnorm_scale res3_block0_conv_sep_batchnorm_res3_block0_conv_sep_relu -23330=4,3,28,28,16 0=16
ConvolutionDepthWise res3_block0_conv_dw_conv2d 1 1 res3_block0_conv_sep_batchnorm_res3_block0_conv_sep_relu res3_block0_conv_dw_batchnorm_res3_block0_conv_dw_batchnorm_scale -23330=4,3,28,28,16 0=16 1=3 4=1 5=1 6=144 7=16
PReLU res3_block0_conv_dw_relu 1 1 res3_block0_conv_dw_batchnorm_res3_block0_conv_dw_batchnorm_scale res3_block0_conv_dw_batchnorm_res3_block0_conv_dw_relu -23330=4,3,28,28,16 0=16
Convolution res3_block0_conv_proj_conv2d 1 1 res3_block0_conv_dw_batchnorm_res3_block0_conv_dw_relu res3_block0_conv_proj_batchnorm_res3_block0_conv_proj_batchnorm_scale -23330=4,3,28,28,16 0=16 1=1 5=1 6=256
Eltwise plus1 2 1 res3_block0_conv_proj_batchnorm_res3_block0_conv_proj_batchnorm_scale dconv23_conv_proj_batchnorm_dconv23_conv_proj_batchnorm_scale_splitncnn_0 plus1 -23330=4,3,28,28,16 0=1
Split splitncnn_2 1 2 plus1 plus1_splitncnn_0 plus1_splitncnn_1 -23330=8,3,28,28,16,3,28,28,16
Convolution res3_block1_conv_sep_conv2d 1 1 plus1_splitncnn_1 res3_block1_conv_sep_batchnorm_res3_block1_conv_sep_batchnorm_scale -23330=4,3,28,28,16 0=16 1=1 5=1 6=256
PReLU res3_block1_conv_sep_relu 1 1 res3_block1_conv_sep_batchnorm_res3_block1_conv_sep_batchnorm_scale res3_block1_conv_sep_batchnorm_res3_block1_conv_sep_relu -23330=4,3,28,28,16 0=16
ConvolutionDepthWise res3_block1_conv_dw_conv2d 1 1 res3_block1_conv_sep_batchnorm_res3_block1_conv_sep_relu res3_block1_conv_dw_batchnorm_res3_block1_conv_dw_batchnorm_scale -23330=4,3,28,28,16 0=16 1=3 4=1 5=1 6=144 7=16
PReLU res3_block1_conv_dw_relu 1 1 res3_block1_conv_dw_batchnorm_res3_block1_conv_dw_batchnorm_scale res3_block1_conv_dw_batchnorm_res3_block1_conv_dw_relu -23330=4,3,28,28,16 0=16
Convolution res3_block1_conv_proj_conv2d 1 1 res3_block1_conv_dw_batchnorm_res3_block1_conv_dw_relu res3_block1_conv_proj_batchnorm_res3_block1_conv_proj_batchnorm_scale -23330=4,3,28,28,16 0=16 1=1 5=1 6=256
Eltwise plus2 2 1 res3_block1_conv_proj_batchnorm_res3_block1_conv_proj_batchnorm_scale plus1_splitncnn_0 plus2 -23330=4,3,28,28,16 0=1
Convolution dconv34_conv_sep_conv2d 1 1 plus2 dconv34_conv_sep_batchnorm_dconv34_conv_sep_batchnorm_scale -23330=4,3,28,28,32 0=32 1=1 5=1 6=512
PReLU dconv34_conv_sep_relu 1 1 dconv34_conv_sep_batchnorm_dconv34_conv_sep_batchnorm_scale dconv34_conv_sep_batchnorm_dconv34_conv_sep_relu -23330=4,3,28,28,32 0=32
ConvolutionDepthWise dconv34_conv_dw_conv2d 1 1 dconv34_conv_sep_batchnorm_dconv34_conv_sep_relu dconv34_conv_dw_batchnorm_dconv34_conv_dw_batchnorm_scale -23330=4,3,14,14,32 0=32 1=3 3=2 4=1 5=1 6=288 7=32
PReLU dconv34_conv_dw_relu 1 1 dconv34_conv_dw_batchnorm_dconv34_conv_dw_batchnorm_scale dconv34_conv_dw_batchnorm_dconv34_conv_dw_relu -23330=4,3,14,14,32 0=32
Convolution dconv34_conv_proj_conv2d 1 1 dconv34_conv_dw_batchnorm_dconv34_conv_dw_relu dconv34_conv_proj_batchnorm_dconv34_conv_proj_batchnorm_scale -23330=4,3,14,14,32 0=32 1=1 5=1 6=1024
Split splitncnn_3 1 2 dconv34_conv_proj_batchnorm_dconv34_conv_proj_batchnorm_scale dconv34_conv_proj_batchnorm_dconv34_conv_proj_batchnorm_scale_splitncnn_0 dconv34_conv_proj_batchnorm_dconv34_conv_proj_batchnorm_scale_splitncnn_1 -23330=8,3,14,14,32,3,14,14,32
Convolution res4_block0_conv_sep_conv2d 1 1 dconv34_conv_proj_batchnorm_dconv34_conv_proj_batchnorm_scale_splitncnn_1 res4_block0_conv_sep_batchnorm_res4_block0_conv_sep_batchnorm_scale -23330=4,3,14,14,32 0=32 1=1 5=1 6=1024
PReLU res4_block0_conv_sep_relu 1 1 res4_block0_conv_sep_batchnorm_res4_block0_conv_sep_batchnorm_scale res4_block0_conv_sep_batchnorm_res4_block0_conv_sep_relu -23330=4,3,14,14,32 0=32
ConvolutionDepthWise res4_block0_conv_dw_conv2d 1 1 res4_block0_conv_sep_batchnorm_res4_block0_conv_sep_relu res4_block0_conv_dw_batchnorm_res4_block0_conv_dw_batchnorm_scale -23330=4,3,14,14,32 0=32 1=3 4=1 5=1 6=288 7=32
PReLU res4_block0_conv_dw_relu 1 1 res4_block0_conv_dw_batchnorm_res4_block0_conv_dw_batchnorm_scale res4_block0_conv_dw_batchnorm_res4_block0_conv_dw_relu -23330=4,3,14,14,32 0=32
Convolution res4_block0_conv_proj_conv2d 1 1 res4_block0_conv_dw_batchnorm_res4_block0_conv_dw_relu res4_block0_conv_proj_batchnorm_res4_block0_conv_proj_batchnorm_scale -23330=4,3,14,14,32 0=32 1=1 5=1 6=1024
Eltwise plus3 2 1 res4_block0_conv_proj_batchnorm_res4_block0_conv_proj_batchnorm_scale dconv34_conv_proj_batchnorm_dconv34_conv_proj_batchnorm_scale_splitncnn_0 plus3 -23330=4,3,14,14,32 0=1
Split splitncnn_4 1 2 plus3 plus3_splitncnn_0 plus3_splitncnn_1 -23330=8,3,14,14,32,3,14,14,32
Convolution res4_block1_conv_sep_conv2d 1 1 plus3_splitncnn_1 res4_block1_conv_sep_batchnorm_res4_block1_conv_sep_batchnorm_scale -23330=4,3,14,14,32 0=32 1=1 5=1 6=1024
PReLU res4_block1_conv_sep_relu 1 1 res4_block1_conv_sep_batchnorm_res4_block1_conv_sep_batchnorm_scale res4_block1_conv_sep_batchnorm_res4_block1_conv_sep_relu -23330=4,3,14,14,32 0=32
ConvolutionDepthWise res4_block1_conv_dw_conv2d 1 1 res4_block1_conv_sep_batchnorm_res4_block1_conv_sep_relu res4_block1_conv_dw_batchnorm_res4_block1_conv_dw_batchnorm_scale -23330=4,3,14,14,32 0=32 1=3 4=1 5=1 6=288 7=32
PReLU res4_block1_conv_dw_relu 1 1 res4_block1_conv_dw_batchnorm_res4_block1_conv_dw_batchnorm_scale res4_block1_conv_dw_batchnorm_res4_block1_conv_dw_relu -23330=4,3,14,14,32 0=32
Convolution res4_block1_conv_proj_conv2d 1 1 res4_block1_conv_dw_batchnorm_res4_block1_conv_dw_relu res4_block1_conv_proj_batchnorm_res4_block1_conv_proj_batchnorm_scale -23330=4,3,14,14,32 0=32 1=1 5=1 6=1024
Eltwise plus4 2 1 res4_block1_conv_proj_batchnorm_res4_block1_conv_proj_batchnorm_scale plus3_splitncnn_0 plus4 -23330=4,3,14,14,32 0=1
Split splitncnn_5 1 2 plus4 plus4_splitncnn_0 plus4_splitncnn_1 -23330=8,3,14,14,32,3,14,14,32
Convolution res4_block2_conv_sep_conv2d 1 1 plus4_splitncnn_1 res4_block2_conv_sep_batchnorm_res4_block2_conv_sep_batchnorm_scale -23330=4,3,14,14,32 0=32 1=1 5=1 6=1024
PReLU res4_block2_conv_sep_relu 1 1 res4_block2_conv_sep_batchnorm_res4_block2_conv_sep_batchnorm_scale res4_block2_conv_sep_batchnorm_res4_block2_conv_sep_relu -23330=4,3,14,14,32 0=32
ConvolutionDepthWise res4_block2_conv_dw_conv2d 1 1 res4_block2_conv_sep_batchnorm_res4_block2_conv_sep_relu res4_block2_conv_dw_batchnorm_res4_block2_conv_dw_batchnorm_scale -23330=4,3,14,14,32 0=32 1=3 4=1 5=1 6=288 7=32
PReLU res4_block2_conv_dw_relu 1 1 res4_block2_conv_dw_batchnorm_res4_block2_conv_dw_batchnorm_scale res4_block2_conv_dw_batchnorm_res4_block2_conv_dw_relu -23330=4,3,14,14,32 0=32
Convolution res4_block2_conv_proj_conv2d 1 1 res4_block2_conv_dw_batchnorm_res4_block2_conv_dw_relu res4_block2_conv_proj_batchnorm_res4_block2_conv_proj_batchnorm_scale -23330=4,3,14,14,32 0=32 1=1 5=1 6=1024
Eltwise plus5 2 1 res4_block2_conv_proj_batchnorm_res4_block2_conv_proj_batchnorm_scale plus4_splitncnn_0 plus5 -23330=4,3,14,14,32 0=1
Convolution dconv45_conv_sep_conv2d 1 1 plus5 dconv45_conv_sep_batchnorm_dconv45_conv_sep_batchnorm_scale -23330=4,3,14,14,64 0=64 1=1 5=1 6=2048
PReLU dconv45_conv_sep_relu 1 1 dconv45_conv_sep_batchnorm_dconv45_conv_sep_batchnorm_scale dconv45_conv_sep_batchnorm_dconv45_conv_sep_relu -23330=4,3,14,14,64 0=64
ConvolutionDepthWise dconv45_conv_dw_conv2d 1 1 dconv45_conv_sep_batchnorm_dconv45_conv_sep_relu dconv45_conv_dw_batchnorm_dconv45_conv_dw_batchnorm_scale -23330=4,3,7,7,64 0=64 1=3 3=2 4=1 5=1 6=576 7=64
PReLU dconv45_conv_dw_relu 1 1 dconv45_conv_dw_batchnorm_dconv45_conv_dw_batchnorm_scale dconv45_conv_dw_batchnorm_dconv45_conv_dw_relu -23330=4,3,7,7,64 0=64
Convolution dconv45_conv_proj_conv2d 1 1 dconv45_conv_dw_batchnorm_dconv45_conv_dw_relu dconv45_conv_proj_batchnorm_dconv45_conv_proj_batchnorm_scale -23330=4,3,7,7,64 0=64 1=1 5=1 6=4096
Split splitncnn_6 1 2 dconv45_conv_proj_batchnorm_dconv45_conv_proj_batchnorm_scale dconv45_conv_proj_batchnorm_dconv45_conv_proj_batchnorm_scale_splitncnn_0 dconv45_conv_proj_batchnorm_dconv45_conv_proj_batchnorm_scale_splitncnn_1 -23330=8,3,7,7,64,3,7,7,64
Convolution res5_block0_conv_sep_conv2d 1 1 dconv45_conv_proj_batchnorm_dconv45_conv_proj_batchnorm_scale_splitncnn_1 res5_block0_conv_sep_batchnorm_res5_block0_conv_sep_batchnorm_scale -23330=4,3,7,7,64 0=64 1=1 5=1 6=4096
PReLU res5_block0_conv_sep_relu 1 1 res5_block0_conv_sep_batchnorm_res5_block0_conv_sep_batchnorm_scale res5_block0_conv_sep_batchnorm_res5_block0_conv_sep_relu -23330=4,3,7,7,64 0=64
ConvolutionDepthWise res5_block0_conv_dw_conv2d 1 1 res5_block0_conv_sep_batchnorm_res5_block0_conv_sep_relu res5_block0_conv_dw_batchnorm_res5_block0_conv_dw_batchnorm_scale -23330=4,3,7,7,64 0=64 1=3 4=1 5=1 6=576 7=64
PReLU res5_block0_conv_dw_relu 1 1 res5_block0_conv_dw_batchnorm_res5_block0_conv_dw_batchnorm_scale res5_block0_conv_dw_batchnorm_res5_block0_conv_dw_relu -23330=4,3,7,7,64 0=64
Convolution res5_block0_conv_proj_conv2d 1 1 res5_block0_conv_dw_batchnorm_res5_block0_conv_dw_relu res5_block0_conv_proj_batchnorm_res5_block0_conv_proj_batchnorm_scale -23330=4,3,7,7,64 0=64 1=1 5=1 6=4096
Eltwise plus6 2 1 res5_block0_conv_proj_batchnorm_res5_block0_conv_proj_batchnorm_scale dconv45_conv_proj_batchnorm_dconv45_conv_proj_batchnorm_scale_splitncnn_0 plus6 -23330=4,3,7,7,64 0=1
Split splitncnn_7 1 2 plus6 plus6_splitncnn_0 plus6_splitncnn_1 -23330=8,3,7,7,64,3,7,7,64
Convolution res5_block1_conv_sep_conv2d 1 1 plus6_splitncnn_1 res5_block1_conv_sep_batchnorm_res5_block1_conv_sep_batchnorm_scale -23330=4,3,7,7,64 0=64 1=1 5=1 6=4096
PReLU res5_block1_conv_sep_relu 1 1 res5_block1_conv_sep_batchnorm_res5_block1_conv_sep_batchnorm_scale res5_block1_conv_sep_batchnorm_res5_block1_conv_sep_relu -23330=4,3,7,7,64 0=64
ConvolutionDepthWise res5_block1_conv_dw_conv2d 1 1 res5_block1_conv_sep_batchnorm_res5_block1_conv_sep_relu res5_block1_conv_dw_batchnorm_res5_block1_conv_dw_batchnorm_scale -23330=4,3,7,7,64 0=64 1=3 4=1 5=1 6=576 7=64
PReLU res5_block1_conv_dw_relu 1 1 res5_block1_conv_dw_batchnorm_res5_block1_conv_dw_batchnorm_scale res5_block1_conv_dw_batchnorm_res5_block1_conv_dw_relu -23330=4,3,7,7,64 0=64
Convolution res5_block1_conv_proj_conv2d 1 1 res5_block1_conv_dw_batchnorm_res5_block1_conv_dw_relu res5_block1_conv_proj_batchnorm_res5_block1_conv_proj_batchnorm_scale -23330=4,3,7,7,64 0=64 1=1 5=1 6=4096
Eltwise plus7 2 1 res5_block1_conv_proj_batchnorm_res5_block1_conv_proj_batchnorm_scale plus6_splitncnn_0 plus7 -23330=4,3,7,7,64 0=1
Convolution conv6_conv2d 1 1 plus7 conv6_batchnorm_conv6_batchnorm_scale -23330=4,3,1,1,64 0=64 1=7 5=1 6=200704
PReLU conv6_relu 1 1 conv6_batchnorm_conv6_batchnorm_scale conv6_batchnorm_conv6_relu -23330=4,3,1,1,64 0=64
Convolution fc1_conv2d 1 1 conv6_batchnorm_conv6_relu fc1_batchnorm_fc1_batchnorm_scale -23330=4,3,1,1,128 0=128 1=1 5=1 6=8192
PReLU fc1_relu 1 1 fc1_batchnorm_fc1_batchnorm_scale fc1_batchnorm_fc1_relu -23330=4,3,1,1,128 0=128
Convolution fc2_conv2d 1 1 fc1_batchnorm_fc1_relu fc2_batchnorm_fc2_batchnorm_scale -23330=4,3,1,1,256 0=256 1=1 5=1 6=32768
PReLU fc2_relu 1 1 fc2_batchnorm_fc2_batchnorm_scale fc2_batchnorm_fc2_relu -23330=4,3,1,1,256 0=256
InnerProduct conv6_3 1 1 fc2_batchnorm_fc2_relu bn6_3_bn6_3_scale -23330=4,1,212,1,1 0=212 1=1 2=54272

@ -0,0 +1,210 @@
7767517
208 224
Input input 0 1 input
Convolution Conv_6 1 1 input 250 0=16 1=3 11=3 2=1 12=1 3=2 13=2 4=1 14=1 15=1 16=1 5=0 6=432
BatchNorm BatchNormalization_7 1 1 250 251 0=16
HardSwish Div_15 1 1 251 259 0=1.666667e-01 1=5.000000e-01
Convolution Conv_16 1 1 259 260 0=16 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=256
BatchNorm BatchNormalization_17 1 1 260 261 0=16
ReLU Relu_18 1 1 261 262
ConvolutionDepthWise Conv_19 1 1 262 263 0=16 1=3 11=3 2=1 12=1 3=2 13=2 4=1 14=1 15=1 16=1 5=0 6=144 7=16
BatchNorm BatchNormalization_20 1 1 263 264 0=16
Split splitncnn_0 1 2 264 264_splitncnn_0 264_splitncnn_1
Pooling GlobalAveragePool_27 1 1 264_splitncnn_1 271 0=1 4=1
Reshape Reshape_31 1 1 271 275 0=16
InnerProduct MatMul_32 1 1 275 277 0=4 1=0 2=64
ReLU Relu_33 1 1 277 278
InnerProduct MatMul_34 1 1 278 280 0=16 1=0 2=64
HardSigmoid Div_41 1 1 280 287 0=1.666667e-01 1=5.000000e-01
Reshape Reshape_45 1 1 287 295 0=1 1=1 2=16
Noop Expand_47 1 1 295 297
BinaryOp Mul_48 2 1 264_splitncnn_0 297 298 0=2
ReLU Relu_49 1 1 298 299
Convolution Conv_50 1 1 299 300 0=16 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=256
BatchNorm BatchNormalization_51 1 1 300 301 0=16
Convolution Conv_52 1 1 301 302 0=72 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=1152
BatchNorm BatchNormalization_53 1 1 302 303 0=72
ReLU Relu_54 1 1 303 304
ConvolutionDepthWise Conv_55 1 1 304 305 0=72 1=3 11=3 2=1 12=1 3=2 13=2 4=1 14=1 15=1 16=1 5=0 6=648 7=72
BatchNorm BatchNormalization_56 1 1 305 306 0=72
ReLU Relu_57 1 1 306 307
Convolution Conv_58 1 1 307 308 0=24 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=1728
BatchNorm BatchNormalization_59 1 1 308 309 0=24
Split splitncnn_1 1 2 309 309_splitncnn_0 309_splitncnn_1
Convolution Conv_60 1 1 309_splitncnn_1 310 0=88 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=2112
BatchNorm BatchNormalization_61 1 1 310 311 0=88
ReLU Relu_62 1 1 311 312
ConvolutionDepthWise Conv_63 1 1 312 313 0=88 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=0 6=792 7=88
BatchNorm BatchNormalization_64 1 1 313 314 0=88
ReLU Relu_65 1 1 314 315
Convolution Conv_66 1 1 315 316 0=24 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=2112
BatchNorm BatchNormalization_67 1 1 316 317 0=24
BinaryOp Add_68 2 1 309_splitncnn_0 317 318 0=0
Convolution Conv_69 1 1 318 319 0=96 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=2304
BatchNorm BatchNormalization_70 1 1 319 320 0=96
HardSwish Div_78 1 1 320 328 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_79 1 1 328 329 0=96 1=5 11=5 2=1 12=1 3=2 13=2 4=2 14=2 15=2 16=2 5=0 6=2400 7=96
BatchNorm BatchNormalization_80 1 1 329 330 0=96
Split splitncnn_2 1 2 330 330_splitncnn_0 330_splitncnn_1
Pooling GlobalAveragePool_87 1 1 330_splitncnn_1 337 0=1 4=1
Reshape Reshape_91 1 1 337 341 0=96
InnerProduct MatMul_92 1 1 341 343 0=24 1=0 2=2304
ReLU Relu_93 1 1 343 344
InnerProduct MatMul_94 1 1 344 346 0=96 1=0 2=2304
HardSigmoid Div_101 1 1 346 353 0=1.666667e-01 1=5.000000e-01
Reshape Reshape_105 1 1 353 361 0=1 1=1 2=96
Noop Expand_107 1 1 361 363
BinaryOp Mul_108 2 1 330_splitncnn_0 363 364 0=2
HardSwish Div_116 1 1 364 372 0=1.666667e-01 1=5.000000e-01
Convolution Conv_117 1 1 372 373 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=3840
BatchNorm BatchNormalization_118 1 1 373 374 0=40
Split splitncnn_3 1 2 374 374_splitncnn_0 374_splitncnn_1
Convolution Conv_119 1 1 374_splitncnn_1 375 0=240 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=9600
BatchNorm BatchNormalization_120 1 1 375 376 0=240
HardSwish Div_128 1 1 376 384 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_129 1 1 384 385 0=240 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=0 6=6000 7=240
BatchNorm BatchNormalization_130 1 1 385 386 0=240
Split splitncnn_4 1 2 386 386_splitncnn_0 386_splitncnn_1
Pooling GlobalAveragePool_137 1 1 386_splitncnn_1 393 0=1 4=1
Reshape Reshape_141 1 1 393 397 0=240
InnerProduct MatMul_142 1 1 397 399 0=60 1=0 2=14400
ReLU Relu_143 1 1 399 400
InnerProduct MatMul_144 1 1 400 402 0=240 1=0 2=14400
HardSigmoid Div_151 1 1 402 409 0=1.666667e-01 1=5.000000e-01
Reshape Reshape_155 1 1 409 417 0=1 1=1 2=240
Noop Expand_157 1 1 417 419
BinaryOp Mul_158 2 1 386_splitncnn_0 419 420 0=2
HardSwish Div_166 1 1 420 428 0=1.666667e-01 1=5.000000e-01
Convolution Conv_167 1 1 428 429 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=9600
BatchNorm BatchNormalization_168 1 1 429 430 0=40
BinaryOp Add_169 2 1 374_splitncnn_0 430 431 0=0
Split splitncnn_5 1 2 431 431_splitncnn_0 431_splitncnn_1
Convolution Conv_170 1 1 431_splitncnn_1 432 0=240 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=9600
BatchNorm BatchNormalization_171 1 1 432 433 0=240
HardSwish Div_179 1 1 433 441 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_180 1 1 441 442 0=240 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=0 6=6000 7=240
BatchNorm BatchNormalization_181 1 1 442 443 0=240
Split splitncnn_6 1 2 443 443_splitncnn_0 443_splitncnn_1
Pooling GlobalAveragePool_188 1 1 443_splitncnn_1 450 0=1 4=1
Reshape Reshape_192 1 1 450 454 0=240
InnerProduct MatMul_193 1 1 454 456 0=60 1=0 2=14400
ReLU Relu_194 1 1 456 457
InnerProduct MatMul_195 1 1 457 459 0=240 1=0 2=14400
HardSigmoid Div_202 1 1 459 466 0=1.666667e-01 1=5.000000e-01
Reshape Reshape_206 1 1 466 474 0=1 1=1 2=240
Noop Expand_208 1 1 474 476
BinaryOp Mul_209 2 1 443_splitncnn_0 476 477 0=2
HardSwish Div_217 1 1 477 485 0=1.666667e-01 1=5.000000e-01
Convolution Conv_218 1 1 485 486 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=9600
BatchNorm BatchNormalization_219 1 1 486 487 0=40
BinaryOp Add_220 2 1 431_splitncnn_0 487 488 0=0
Convolution Conv_221 1 1 488 489 0=120 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=4800
BatchNorm BatchNormalization_222 1 1 489 490 0=120
HardSwish Div_230 1 1 490 498 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_231 1 1 498 499 0=120 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=0 6=3000 7=120
BatchNorm BatchNormalization_232 1 1 499 500 0=120
Split splitncnn_7 1 2 500 500_splitncnn_0 500_splitncnn_1
Pooling GlobalAveragePool_239 1 1 500_splitncnn_1 507 0=1 4=1
Reshape Reshape_243 1 1 507 511 0=120
InnerProduct MatMul_244 1 1 511 513 0=30 1=0 2=3600
ReLU Relu_245 1 1 513 514
InnerProduct MatMul_246 1 1 514 516 0=120 1=0 2=3600
HardSigmoid Div_253 1 1 516 523 0=1.666667e-01 1=5.000000e-01
Reshape Reshape_257 1 1 523 531 0=1 1=1 2=120
Noop Expand_259 1 1 531 533
BinaryOp Mul_260 2 1 500_splitncnn_0 533 534 0=2
HardSwish Div_268 1 1 534 542 0=1.666667e-01 1=5.000000e-01
Convolution Conv_269 1 1 542 543 0=48 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=5760
BatchNorm BatchNormalization_270 1 1 543 544 0=48
Split splitncnn_8 1 2 544 544_splitncnn_0 544_splitncnn_1
Convolution Conv_271 1 1 544_splitncnn_1 545 0=144 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=6912
BatchNorm BatchNormalization_272 1 1 545 546 0=144
HardSwish Div_280 1 1 546 554 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_281 1 1 554 555 0=144 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=0 6=3600 7=144
BatchNorm BatchNormalization_282 1 1 555 556 0=144
Split splitncnn_9 1 2 556 556_splitncnn_0 556_splitncnn_1
Pooling GlobalAveragePool_289 1 1 556_splitncnn_1 563 0=1 4=1
Reshape Reshape_293 1 1 563 567 0=144
InnerProduct MatMul_294 1 1 567 569 0=36 1=0 2=5184
ReLU Relu_295 1 1 569 570
InnerProduct MatMul_296 1 1 570 572 0=144 1=0 2=5184
HardSigmoid Div_303 1 1 572 579 0=1.666667e-01 1=5.000000e-01
Reshape Reshape_307 1 1 579 587 0=1 1=1 2=144
Noop Expand_309 1 1 587 589
BinaryOp Mul_310 2 1 556_splitncnn_0 589 590 0=2
HardSwish Div_318 1 1 590 598 0=1.666667e-01 1=5.000000e-01
Convolution Conv_319 1 1 598 599 0=48 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=6912
BatchNorm BatchNormalization_320 1 1 599 600 0=48
BinaryOp Add_321 2 1 544_splitncnn_0 600 601 0=0
Convolution Conv_322 1 1 601 602 0=288 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=13824
BatchNorm BatchNormalization_323 1 1 602 603 0=288
HardSwish Div_331 1 1 603 611 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_332 1 1 611 612 0=288 1=5 11=5 2=2 12=2 3=1 13=1 4=4 14=4 15=4 16=4 5=0 6=7200 7=288
BatchNorm BatchNormalization_333 1 1 612 613 0=288
Split splitncnn_10 1 2 613 613_splitncnn_0 613_splitncnn_1
Pooling GlobalAveragePool_340 1 1 613_splitncnn_1 620 0=1 4=1
Reshape Reshape_344 1 1 620 624 0=288
InnerProduct MatMul_345 1 1 624 626 0=72 1=0 2=20736
ReLU Relu_346 1 1 626 627
InnerProduct MatMul_347 1 1 627 629 0=288 1=0 2=20736
HardSigmoid Div_354 1 1 629 636 0=1.666667e-01 1=5.000000e-01
Reshape Reshape_358 1 1 636 644 0=1 1=1 2=288
Noop Expand_360 1 1 644 646
BinaryOp Mul_361 2 1 613_splitncnn_0 646 647 0=2
HardSwish Div_369 1 1 647 655 0=1.666667e-01 1=5.000000e-01
Convolution Conv_370 1 1 655 656 0=96 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=27648
BatchNorm BatchNormalization_371 1 1 656 657 0=96
Split splitncnn_11 1 2 657 657_splitncnn_0 657_splitncnn_1
Convolution Conv_372 1 1 657_splitncnn_1 658 0=576 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=55296
BatchNorm BatchNormalization_373 1 1 658 659 0=576
HardSwish Div_381 1 1 659 667 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_382 1 1 667 668 0=576 1=5 11=5 2=2 12=2 3=1 13=1 4=4 14=4 15=4 16=4 5=0 6=14400 7=576
BatchNorm BatchNormalization_383 1 1 668 669 0=576
Split splitncnn_12 1 2 669 669_splitncnn_0 669_splitncnn_1
Pooling GlobalAveragePool_390 1 1 669_splitncnn_1 676 0=1 4=1
Reshape Reshape_394 1 1 676 680 0=576
InnerProduct MatMul_395 1 1 680 682 0=144 1=0 2=82944
ReLU Relu_396 1 1 682 683
InnerProduct MatMul_397 1 1 683 685 0=576 1=0 2=82944
HardSigmoid Div_404 1 1 685 692 0=1.666667e-01 1=5.000000e-01
Reshape Reshape_408 1 1 692 700 0=1 1=1 2=576
Noop Expand_410 1 1 700 702
BinaryOp Mul_411 2 1 669_splitncnn_0 702 703 0=2
HardSwish Div_419 1 1 703 711 0=1.666667e-01 1=5.000000e-01
Convolution Conv_420 1 1 711 712 0=96 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=55296
BatchNorm BatchNormalization_421 1 1 712 713 0=96
BinaryOp Add_422 2 1 657_splitncnn_0 713 714 0=0
Split splitncnn_13 1 2 714 714_splitncnn_0 714_splitncnn_1
Convolution Conv_423 1 1 714_splitncnn_1 715 0=576 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=55296
BatchNorm BatchNormalization_424 1 1 715 716 0=576
HardSwish Div_432 1 1 716 724 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_433 1 1 724 725 0=576 1=5 11=5 2=2 12=2 3=1 13=1 4=4 14=4 15=4 16=4 5=0 6=14400 7=576
BatchNorm BatchNormalization_434 1 1 725 726 0=576
Split splitncnn_14 1 2 726 726_splitncnn_0 726_splitncnn_1
Pooling GlobalAveragePool_441 1 1 726_splitncnn_1 733 0=1 4=1
Reshape Reshape_445 1 1 733 737 0=576
InnerProduct MatMul_446 1 1 737 739 0=144 1=0 2=82944
ReLU Relu_447 1 1 739 740
InnerProduct MatMul_448 1 1 740 742 0=576 1=0 2=82944
HardSigmoid Div_455 1 1 742 749 0=1.666667e-01 1=5.000000e-01
Reshape Reshape_459 1 1 749 757 0=1 1=1 2=576
Noop Expand_461 1 1 757 759
BinaryOp Mul_462 2 1 726_splitncnn_0 759 760 0=2
HardSwish Div_470 1 1 760 768 0=1.666667e-01 1=5.000000e-01
Convolution Conv_471 1 1 768 769 0=96 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=55296
BatchNorm BatchNormalization_472 1 1 769 770 0=96
BinaryOp Add_473 2 1 714_splitncnn_0 770 771 0=0
Convolution Conv_474 1 1 771 772 0=576 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=55296
BatchNorm BatchNormalization_475 1 1 772 773 0=576
HardSwish Div_483 1 1 773 781 0=1.666667e-01 1=5.000000e-01
Split splitncnn_15 1 2 781 781_splitncnn_0 781_splitncnn_1
Convolution Conv_490 1 1 781_splitncnn_1 788 0=128 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=73728
BatchNorm BatchNormalization_491 1 1 788 789 0=128
ReLU Relu_492 1 1 789 790
Pooling MaxPool_493 1 1 781_splitncnn_0 791 0=0 1=18 11=18 2=9 12=9 3=0 13=0 14=0 15=0 5=1
Convolution Conv_494 1 1 791 792 0=128 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=0 6=73728
Sigmoid Sigmoid_495 1 1 792 793
Interp Resize_508 1 1 793 806 0=2 1=1.000000e+00 2=1.000000e+00 3=32 4=32
BinaryOp Mul_509 2 1 790 806 807 0=2
Convolution Conv_510 1 1 807 808 0=19 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=2432
Interp Resize_523 1 1 808 output 0=2 1=1.000000e+00 2=1.000000e+00 3=512 4=512

@ -0,0 +1,155 @@
7767517
153 178
Input input.1 0 1 input.1 -23330=4,3,320,320,3 0=320 1=320 2=3
Convolution Conv_0 1 1 input.1 424 -23330=4,3,160,160,24 0=24 1=3 3=2 4=1 5=1 6=648 9=2 -23310=1,1.000000e-01
Pooling MaxPool_3 1 1 424 425 -23330=4,3,80,80,24 1=3 2=2 3=1 5=1
Split splitncnn_0 1 2 425 425_splitncnn_0 425_splitncnn_1 -23330=8,3,80,80,24,3,80,80,24
ConvolutionDepthWise Conv_4 1 1 425_splitncnn_1 427 -23330=4,3,40,40,24 0=24 1=3 3=2 4=1 5=1 6=216 7=24
Convolution Conv_6 1 1 427 430 -23330=4,3,40,40,58 0=58 1=1 5=1 6=1392 9=2 -23310=1,1.000000e-01
Convolution Conv_9 1 1 425_splitncnn_0 433 -23330=4,3,80,80,58 0=58 1=1 5=1 6=1392 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_12 1 1 433 435 -23330=4,3,40,40,58 0=58 1=3 3=2 4=1 5=1 6=522 7=58
Convolution Conv_14 1 1 435 438 -23330=4,3,40,40,58 0=58 1=1 5=1 6=3364 9=2 -23310=1,1.000000e-01
Concat Concat_17 2 1 430 438 439 -23330=4,3,40,40,116
ShuffleChannel Reshape_22 1 1 439 444 -23330=4,3,40,40,116 0=2
Slice Split_23 1 2 444 445 446 -23330=8,3,40,40,58,3,40,40,58 -23300=2,58,-233
Convolution Conv_24 1 1 446 449 -23330=4,3,40,40,58 0=58 1=1 5=1 6=3364 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_27 1 1 449 451 -23330=4,3,40,40,58 0=58 1=3 4=1 5=1 6=522 7=58
Convolution Conv_29 1 1 451 454 -23330=4,3,40,40,58 0=58 1=1 5=1 6=3364 9=2 -23310=1,1.000000e-01
Concat Concat_32 2 1 445 454 455 -23330=4,3,40,40,116
ShuffleChannel Reshape_37 1 1 455 460 -23330=4,3,40,40,116 0=2
Slice Split_38 1 2 460 461 462 -23330=8,3,40,40,58,3,40,40,58 -23300=2,58,-233
Convolution Conv_39 1 1 462 465 -23330=4,3,40,40,58 0=58 1=1 5=1 6=3364 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_42 1 1 465 467 -23330=4,3,40,40,58 0=58 1=3 4=1 5=1 6=522 7=58
Convolution Conv_44 1 1 467 470 -23330=4,3,40,40,58 0=58 1=1 5=1 6=3364 9=2 -23310=1,1.000000e-01
Concat Concat_47 2 1 461 470 471 -23330=4,3,40,40,116
ShuffleChannel Reshape_52 1 1 471 476 -23330=4,3,40,40,116 0=2
Slice Split_53 1 2 476 477 478 -23330=8,3,40,40,58,3,40,40,58 -23300=2,58,-233
Convolution Conv_54 1 1 478 481 -23330=4,3,40,40,58 0=58 1=1 5=1 6=3364 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_57 1 1 481 483 -23330=4,3,40,40,58 0=58 1=3 4=1 5=1 6=522 7=58
Convolution Conv_59 1 1 483 486 -23330=4,3,40,40,58 0=58 1=1 5=1 6=3364 9=2 -23310=1,1.000000e-01
Concat Concat_62 2 1 477 486 487 -23330=4,3,40,40,116
ShuffleChannel Reshape_67 1 1 487 492 -23330=4,3,40,40,116 0=2
Split splitncnn_1 1 3 492 492_splitncnn_0 492_splitncnn_1 492_splitncnn_2 -23330=12,3,40,40,116,3,40,40,116,3,40,40,116
ConvolutionDepthWise Conv_68 1 1 492_splitncnn_2 494 -23330=4,3,20,20,116 0=116 1=3 3=2 4=1 5=1 6=1044 7=116
Convolution Conv_70 1 1 494 497 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
Convolution Conv_73 1 1 492_splitncnn_1 500 -23330=4,3,40,40,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_76 1 1 500 502 -23330=4,3,20,20,116 0=116 1=3 3=2 4=1 5=1 6=1044 7=116
Convolution Conv_78 1 1 502 505 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
Concat Concat_81 2 1 497 505 506 -23330=4,3,20,20,232
ShuffleChannel Reshape_86 1 1 506 511 -23330=4,3,20,20,232 0=2
Slice Split_87 1 2 511 512 513 -23330=8,3,20,20,116,3,20,20,116 -23300=2,116,-233
Convolution Conv_88 1 1 513 516 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_91 1 1 516 518 -23330=4,3,20,20,116 0=116 1=3 4=1 5=1 6=1044 7=116
Convolution Conv_93 1 1 518 521 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
Concat Concat_96 2 1 512 521 522 -23330=4,3,20,20,232
ShuffleChannel Reshape_101 1 1 522 527 -23330=4,3,20,20,232 0=2
Slice Split_102 1 2 527 528 529 -23330=8,3,20,20,116,3,20,20,116 -23300=2,116,-233
Convolution Conv_103 1 1 529 532 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_106 1 1 532 534 -23330=4,3,20,20,116 0=116 1=3 4=1 5=1 6=1044 7=116
Convolution Conv_108 1 1 534 537 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
Concat Concat_111 2 1 528 537 538 -23330=4,3,20,20,232
ShuffleChannel Reshape_116 1 1 538 543 -23330=4,3,20,20,232 0=2
Slice Split_117 1 2 543 544 545 -23330=8,3,20,20,116,3,20,20,116 -23300=2,116,-233
Convolution Conv_118 1 1 545 548 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_121 1 1 548 550 -23330=4,3,20,20,116 0=116 1=3 4=1 5=1 6=1044 7=116
Convolution Conv_123 1 1 550 553 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
Concat Concat_126 2 1 544 553 554 -23330=4,3,20,20,232
ShuffleChannel Reshape_131 1 1 554 559 -23330=4,3,20,20,232 0=2
Slice Split_132 1 2 559 560 561 -23330=8,3,20,20,116,3,20,20,116 -23300=2,116,-233
Convolution Conv_133 1 1 561 564 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_136 1 1 564 566 -23330=4,3,20,20,116 0=116 1=3 4=1 5=1 6=1044 7=116
Convolution Conv_138 1 1 566 569 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
Concat Concat_141 2 1 560 569 570 -23330=4,3,20,20,232
ShuffleChannel Reshape_146 1 1 570 575 -23330=4,3,20,20,232 0=2
Slice Split_147 1 2 575 576 577 -23330=8,3,20,20,116,3,20,20,116 -23300=2,116,-233
Convolution Conv_148 1 1 577 580 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_151 1 1 580 582 -23330=4,3,20,20,116 0=116 1=3 4=1 5=1 6=1044 7=116
Convolution Conv_153 1 1 582 585 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
Concat Concat_156 2 1 576 585 586 -23330=4,3,20,20,232
ShuffleChannel Reshape_161 1 1 586 591 -23330=4,3,20,20,232 0=2
Slice Split_162 1 2 591 592 593 -23330=8,3,20,20,116,3,20,20,116 -23300=2,116,-233
Convolution Conv_163 1 1 593 596 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_166 1 1 596 598 -23330=4,3,20,20,116 0=116 1=3 4=1 5=1 6=1044 7=116
Convolution Conv_168 1 1 598 601 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
Concat Concat_171 2 1 592 601 602 -23330=4,3,20,20,232
ShuffleChannel Reshape_176 1 1 602 607 -23330=4,3,20,20,232 0=2
Slice Split_177 1 2 607 608 609 -23330=8,3,20,20,116,3,20,20,116 -23300=2,116,-233
Convolution Conv_178 1 1 609 612 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_181 1 1 612 614 -23330=4,3,20,20,116 0=116 1=3 4=1 5=1 6=1044 7=116
Convolution Conv_183 1 1 614 617 -23330=4,3,20,20,116 0=116 1=1 5=1 6=13456 9=2 -23310=1,1.000000e-01
Concat Concat_186 2 1 608 617 618 -23330=4,3,20,20,232
ShuffleChannel Reshape_191 1 1 618 623 -23330=4,3,20,20,232 0=2
Split splitncnn_2 1 3 623 623_splitncnn_0 623_splitncnn_1 623_splitncnn_2 -23330=12,3,20,20,232,3,20,20,232,3,20,20,232
ConvolutionDepthWise Conv_192 1 1 623_splitncnn_2 625 -23330=4,3,10,10,232 0=232 1=3 3=2 4=1 5=1 6=2088 7=232
Convolution Conv_194 1 1 625 628 -23330=4,3,10,10,232 0=232 1=1 5=1 6=53824 9=2 -23310=1,1.000000e-01
Convolution Conv_197 1 1 623_splitncnn_1 631 -23330=4,3,20,20,232 0=232 1=1 5=1 6=53824 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_200 1 1 631 633 -23330=4,3,10,10,232 0=232 1=3 3=2 4=1 5=1 6=2088 7=232
Convolution Conv_202 1 1 633 636 -23330=4,3,10,10,232 0=232 1=1 5=1 6=53824 9=2 -23310=1,1.000000e-01
Concat Concat_205 2 1 628 636 637 -23330=4,3,10,10,464
ShuffleChannel Reshape_210 1 1 637 642 -23330=4,3,10,10,464 0=2
Slice Split_211 1 2 642 643 644 -23330=8,3,10,10,232,3,10,10,232 -23300=2,232,-233
Convolution Conv_212 1 1 644 647 -23330=4,3,10,10,232 0=232 1=1 5=1 6=53824 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_215 1 1 647 649 -23330=4,3,10,10,232 0=232 1=3 4=1 5=1 6=2088 7=232
Convolution Conv_217 1 1 649 652 -23330=4,3,10,10,232 0=232 1=1 5=1 6=53824 9=2 -23310=1,1.000000e-01
Concat Concat_220 2 1 643 652 653 -23330=4,3,10,10,464
ShuffleChannel Reshape_225 1 1 653 658 -23330=4,3,10,10,464 0=2
Slice Split_226 1 2 658 659 660 -23330=8,3,10,10,232,3,10,10,232 -23300=2,232,-233
Convolution Conv_227 1 1 660 663 -23330=4,3,10,10,232 0=232 1=1 5=1 6=53824 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_230 1 1 663 665 -23330=4,3,10,10,232 0=232 1=3 4=1 5=1 6=2088 7=232
Convolution Conv_232 1 1 665 668 -23330=4,3,10,10,232 0=232 1=1 5=1 6=53824 9=2 -23310=1,1.000000e-01
Concat Concat_235 2 1 659 668 669 -23330=4,3,10,10,464
ShuffleChannel Reshape_240 1 1 669 674 -23330=4,3,10,10,464 0=2
Slice Split_241 1 2 674 675 676 -23330=8,3,10,10,232,3,10,10,232 -23300=2,232,-233
Convolution Conv_242 1 1 676 679 -23330=4,3,10,10,232 0=232 1=1 5=1 6=53824 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_245 1 1 679 681 -23330=4,3,10,10,232 0=232 1=3 4=1 5=1 6=2088 7=232
Convolution Conv_247 1 1 681 684 -23330=4,3,10,10,232 0=232 1=1 5=1 6=53824 9=2 -23310=1,1.000000e-01
Concat Concat_250 2 1 675 684 685 -23330=4,3,10,10,464
ShuffleChannel Reshape_255 1 1 685 690 -23330=4,3,10,10,464 0=2
Convolution Conv_256 1 1 492_splitncnn_0 691 -23330=4,3,40,40,96 0=96 1=1 5=1 6=11136
Convolution Conv_257 1 1 623_splitncnn_0 692 -23330=4,3,20,20,96 0=96 1=1 5=1 6=22272
Convolution Conv_258 1 1 690 693 -23330=4,3,10,10,96 0=96 1=1 5=1 6=44544
Split splitncnn_3 1 2 693 693_splitncnn_0 693_splitncnn_1 -23330=8,3,10,10,96,3,10,10,96
Interp Resize_277 1 1 693_splitncnn_1 712 -23330=4,3,20,20,96 0=2 3=20 4=20
BinaryOp Add_278 2 1 692 712 713 -23330=4,3,20,20,96
Split splitncnn_4 1 2 713 713_splitncnn_0 713_splitncnn_1 -23330=8,3,20,20,96,3,20,20,96
Interp Resize_297 1 1 713_splitncnn_1 732 -23330=4,3,40,40,96 0=2 3=40 4=40
BinaryOp Add_298 2 1 691 732 733 -23330=4,3,40,40,96
Split splitncnn_5 1 2 733 733_splitncnn_0 733_splitncnn_1 -23330=8,3,40,40,96,3,40,40,96
Interp Resize_317 1 1 733_splitncnn_1 752 -23330=4,3,20,20,96 0=2 3=20 4=20
BinaryOp Add_318 2 1 713_splitncnn_0 752 753 -23330=4,3,20,20,96
Split splitncnn_6 1 2 753 753_splitncnn_0 753_splitncnn_1 -23330=8,3,20,20,96,3,20,20,96
Interp Resize_337 1 1 753_splitncnn_1 772 -23330=4,3,10,10,96 0=2 3=10 4=10
BinaryOp Add_338 2 1 693_splitncnn_0 772 773 -23330=4,3,10,10,96
ConvolutionDepthWise Conv_339 1 1 733_splitncnn_0 776 -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution Conv_342 1 1 776 779 -23330=4,3,40,40,96 0=96 1=1 5=1 6=9216 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_345 1 1 779 782 -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution Conv_348 1 1 782 785 -23330=4,3,40,40,96 0=96 1=1 5=1 6=9216 9=2 -23310=1,1.000000e-01
Convolution Conv_351 1 1 785 786 -23330=4,3,40,40,112 0=112 1=1 5=1 6=10752
Slice Split_352 1 2 786 787 788 -23330=8,3,40,40,80,3,40,40,32 -23300=2,80,-233
Sigmoid Sigmoid_353 1 1 787 789 -23330=4,3,40,40,80
Reshape Reshape_355 1 1 789 791 -23330=4,2,1600,80,1 0=-1 1=80
Permute Transpose_356 1 1 791 792 -23330=4,2,80,1600,1 0=1
Reshape Reshape_358 1 1 788 794 -23330=4,2,1600,32,1 0=-1 1=32
Permute Transpose_359 1 1 794 795 -23330=4,2,32,1600,1 0=1
ConvolutionDepthWise Conv_360 1 1 753_splitncnn_0 798 -23330=4,3,20,20,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution Conv_363 1 1 798 801 -23330=4,3,20,20,96 0=96 1=1 5=1 6=9216 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_366 1 1 801 804 -23330=4,3,20,20,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution Conv_369 1 1 804 807 -23330=4,3,20,20,96 0=96 1=1 5=1 6=9216 9=2 -23310=1,1.000000e-01
Convolution Conv_372 1 1 807 808 -23330=4,3,20,20,112 0=112 1=1 5=1 6=10752
Slice Split_373 1 2 808 809 810 -23330=8,3,20,20,80,3,20,20,32 -23300=2,80,-233
Sigmoid Sigmoid_374 1 1 809 811 -23330=4,3,20,20,80
Reshape Reshape_376 1 1 811 813 -23330=4,2,400,80,1 0=-1 1=80
Permute Transpose_377 1 1 813 814 -23330=4,2,80,400,1 0=1
Reshape Reshape_379 1 1 810 816 -23330=4,2,400,32,1 0=-1 1=32
Permute Transpose_380 1 1 816 817 -23330=4,2,32,400,1 0=1
ConvolutionDepthWise Conv_381 1 1 773 820 -23330=4,3,10,10,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution Conv_384 1 1 820 823 -23330=4,3,10,10,96 0=96 1=1 5=1 6=9216 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise Conv_387 1 1 823 826 -23330=4,3,10,10,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution Conv_390 1 1 826 829 -23330=4,3,10,10,96 0=96 1=1 5=1 6=9216 9=2 -23310=1,1.000000e-01
Convolution Conv_393 1 1 829 830 -23330=4,3,10,10,112 0=112 1=1 5=1 6=10752
Slice Split_394 1 2 830 831 832 -23330=8,3,10,10,80,3,10,10,32 -23300=2,80,-233
Sigmoid Sigmoid_395 1 1 831 833 -23330=4,3,10,10,80
Reshape Reshape_397 1 1 833 835 -23330=4,2,100,80,1 0=-1 1=80
Permute Transpose_398 1 1 835 836 -23330=4,2,80,100,1 0=1
Reshape Reshape_400 1 1 832 838 -23330=4,2,100,32,1 0=-1 1=32
Permute Transpose_401 1 1 838 839 -23330=4,2,32,100,1 0=1

@ -0,0 +1,111 @@
7767517
109 125
Input input 0 1 input
Convolution 339 1 1 input 341 0=24 1=3 3=2 4=1 5=1 6=648 9=1
Pooling 342 1 1 341 342 1=3 2=2 12=1 3=1 5=1
Split splitncnn_0 1 2 342 342_splitncnn_0 342_splitncnn_1
ConvolutionDepthWise 343 1 1 342_splitncnn_1 343 0=24 1=3 3=2 4=1 5=1 6=216 7=24
Convolution 345 1 1 343 347 0=24 1=1 5=1 6=576 9=1
Convolution 348 1 1 342_splitncnn_0 350 0=24 1=1 5=1 6=576 9=1
ConvolutionDepthWise 351 1 1 350 351 0=24 1=3 3=2 4=1 5=1 6=216 7=24
Convolution 353 1 1 351 355 0=24 1=1 5=1 6=576 9=1
Concat 356 2 1 347 355 356
ShuffleChannel 361 1 1 356 361 0=2
Slice 362 1 2 361 362 363 -23300=2,24,-233
Convolution 364 1 1 363 366 0=24 1=1 5=1 6=576 9=1
ConvolutionDepthWise 367 1 1 366 367 0=24 1=3 4=1 5=1 6=216 7=24
Convolution 369 1 1 367 371 0=24 1=1 5=1 6=576 9=1
Concat 372 2 1 362 371 372
ShuffleChannel 377 1 1 372 377 0=2
Slice 378 1 2 377 378 379 -23300=2,24,-233
Convolution 380 1 1 379 382 0=24 1=1 5=1 6=576 9=1
ConvolutionDepthWise 383 1 1 382 383 0=24 1=3 4=1 5=1 6=216 7=24
Convolution 385 1 1 383 387 0=24 1=1 5=1 6=576 9=1
Concat 388 2 1 378 387 388
ShuffleChannel 393 1 1 388 393 0=2
Slice 394 1 2 393 394 395 -23300=2,24,-233
Convolution 396 1 1 395 398 0=24 1=1 5=1 6=576 9=1
ConvolutionDepthWise 399 1 1 398 399 0=24 1=3 4=1 5=1 6=216 7=24
Convolution 401 1 1 399 403 0=24 1=1 5=1 6=576 9=1
Concat 404 2 1 394 403 404
ShuffleChannel 409 1 1 404 409 0=2
Split splitncnn_1 1 2 409 409_splitncnn_0 409_splitncnn_1
ConvolutionDepthWise 410 1 1 409_splitncnn_1 410 0=48 1=3 3=2 4=1 5=1 6=432 7=48
Convolution 412 1 1 410 414 0=48 1=1 5=1 6=2304 9=1
Convolution 415 1 1 409_splitncnn_0 417 0=48 1=1 5=1 6=2304 9=1
ConvolutionDepthWise 418 1 1 417 418 0=48 1=3 3=2 4=1 5=1 6=432 7=48
Convolution 420 1 1 418 422 0=48 1=1 5=1 6=2304 9=1
Concat 423 2 1 414 422 423
ShuffleChannel 428 1 1 423 428 0=2
Slice 429 1 2 428 429 430 -23300=2,48,-233
Convolution 431 1 1 430 433 0=48 1=1 5=1 6=2304 9=1
ConvolutionDepthWise 434 1 1 433 434 0=48 1=3 4=1 5=1 6=432 7=48
Convolution 436 1 1 434 438 0=48 1=1 5=1 6=2304 9=1
Concat 439 2 1 429 438 439
ShuffleChannel 444 1 1 439 444 0=2
Slice 445 1 2 444 445 446 -23300=2,48,-233
Convolution 447 1 1 446 449 0=48 1=1 5=1 6=2304 9=1
ConvolutionDepthWise 450 1 1 449 450 0=48 1=3 4=1 5=1 6=432 7=48
Convolution 452 1 1 450 454 0=48 1=1 5=1 6=2304 9=1
Concat 455 2 1 445 454 455
ShuffleChannel 460 1 1 455 460 0=2
Slice 461 1 2 460 461 462 -23300=2,48,-233
Convolution 463 1 1 462 465 0=48 1=1 5=1 6=2304 9=1
ConvolutionDepthWise 466 1 1 465 466 0=48 1=3 4=1 5=1 6=432 7=48
Convolution 468 1 1 466 470 0=48 1=1 5=1 6=2304 9=1
Concat 471 2 1 461 470 471
ShuffleChannel 476 1 1 471 476 0=2
Slice 477 1 2 476 477 478 -23300=2,48,-233
Convolution 479 1 1 478 481 0=48 1=1 5=1 6=2304 9=1
ConvolutionDepthWise 482 1 1 481 482 0=48 1=3 4=1 5=1 6=432 7=48
Convolution 484 1 1 482 486 0=48 1=1 5=1 6=2304 9=1
Concat 487 2 1 477 486 487
ShuffleChannel 492 1 1 487 492 0=2
Slice 493 1 2 492 493 494 -23300=2,48,-233
Convolution 495 1 1 494 497 0=48 1=1 5=1 6=2304 9=1
ConvolutionDepthWise 498 1 1 497 498 0=48 1=3 4=1 5=1 6=432 7=48
Convolution 500 1 1 498 502 0=48 1=1 5=1 6=2304 9=1
Concat 503 2 1 493 502 503
ShuffleChannel 508 1 1 503 508 0=2
Slice 509 1 2 508 509 510 -23300=2,48,-233
Convolution 511 1 1 510 513 0=48 1=1 5=1 6=2304 9=1
ConvolutionDepthWise 514 1 1 513 514 0=48 1=3 4=1 5=1 6=432 7=48
Convolution 516 1 1 514 518 0=48 1=1 5=1 6=2304 9=1
Concat 519 2 1 509 518 519
ShuffleChannel 524 1 1 519 524 0=2
Slice 525 1 2 524 525 526 -23300=2,48,-233
Convolution 527 1 1 526 529 0=48 1=1 5=1 6=2304 9=1
ConvolutionDepthWise 530 1 1 529 530 0=48 1=3 4=1 5=1 6=432 7=48
Convolution 532 1 1 530 534 0=48 1=1 5=1 6=2304 9=1
Concat 535 2 1 525 534 535
ShuffleChannel 540 1 1 535 540 0=2
Split splitncnn_2 1 2 540 540_splitncnn_0 540_splitncnn_1
ConvolutionDepthWise 541 1 1 540_splitncnn_1 541 0=96 1=3 3=2 4=1 5=1 6=864 7=96
Convolution 543 1 1 541 545 0=96 1=1 5=1 6=9216 9=1
Convolution 546 1 1 540_splitncnn_0 548 0=96 1=1 5=1 6=9216 9=1
ConvolutionDepthWise 549 1 1 548 549 0=96 1=3 3=2 4=1 5=1 6=864 7=96
Convolution 551 1 1 549 553 0=96 1=1 5=1 6=9216 9=1
Concat 554 2 1 545 553 554
ShuffleChannel 559 1 1 554 559 0=2
Slice 560 1 2 559 560 561 -23300=2,96,-233
Convolution 562 1 1 561 564 0=96 1=1 5=1 6=9216 9=1
ConvolutionDepthWise 565 1 1 564 565 0=96 1=3 4=1 5=1 6=864 7=96
Convolution 567 1 1 565 569 0=96 1=1 5=1 6=9216 9=1
Concat 570 2 1 560 569 570
ShuffleChannel 575 1 1 570 575 0=2
Slice 576 1 2 575 576 577 -23300=2,96,-233
Convolution 578 1 1 577 580 0=96 1=1 5=1 6=9216 9=1
ConvolutionDepthWise 581 1 1 580 581 0=96 1=3 4=1 5=1 6=864 7=96
Convolution 583 1 1 581 585 0=96 1=1 5=1 6=9216 9=1
Concat 586 2 1 576 585 586
ShuffleChannel 591 1 1 586 591 0=2
Slice 592 1 2 591 592 593 -23300=2,96,-233
Convolution 594 1 1 593 596 0=96 1=1 5=1 6=9216 9=1
ConvolutionDepthWise 597 1 1 596 597 0=96 1=3 4=1 5=1 6=864 7=96
Convolution 599 1 1 597 601 0=96 1=1 5=1 6=9216 9=1
Concat 602 2 1 592 601 602
ShuffleChannel 607 1 1 602 607 0=2
Convolution 608 1 1 607 610 0=256 1=1 5=1 6=49152 9=1
Reduction 611 1 1 610 611 0=3 1=0 -23303=2,2,3
InnerProduct 612 1 1 611 612 0=2 1=1 2=512
Softmax out 1 1 612 out

@ -0,0 +1,43 @@
7767517
41 42
Input input 0 1 input
Convolution 202 1 1 input 204 0=8 1=3 4=1 5=1 6=216 9=1
ConvolutionDepthWise 205 1 1 204 207 0=8 1=3 3=2 4=1 5=1 6=72 7=8 9=1
Convolution 208 1 1 207 208 0=16 1=1 5=1 6=128
ConvolutionDepthWise 210 1 1 208 212 0=16 1=3 4=1 5=1 6=144 7=16 9=1
Convolution 213 1 1 212 213 0=16 1=1 5=1 6=256
ConvolutionDepthWise 215 1 1 213 217 0=16 1=3 13=2 4=1 5=1 6=144 7=16 9=1
Convolution 218 1 1 217 218 0=32 1=1 5=1 6=512
ConvolutionDepthWise 220 1 1 218 222 0=32 1=3 4=1 5=1 6=288 7=32 9=1
Convolution 223 1 1 222 223 0=32 1=1 5=1 6=1024
ConvolutionDepthWise 225 1 1 223 227 0=32 1=3 4=1 5=1 6=288 7=32 9=1
Convolution 228 1 1 227 228 0=32 1=1 5=1 6=1024
ConvolutionDepthWise 230 1 1 228 232 0=32 1=3 13=2 4=1 5=1 6=288 7=32 9=1
Convolution 233 1 1 232 233 0=64 1=1 5=1 6=2048
ConvolutionDepthWise 235 1 1 233 237 0=64 1=3 4=1 5=1 6=576 7=64 9=1
Convolution 238 1 1 237 238 0=64 1=1 5=1 6=4096
ConvolutionDepthWise 240 1 1 238 242 0=64 1=3 4=1 5=1 6=576 7=64 9=1
Convolution 243 1 1 242 243 0=64 1=1 5=1 6=4096
ConvolutionDepthWise 245 1 1 243 247 0=64 1=3 4=1 5=1 6=576 7=64 9=1
Convolution 248 1 1 247 248 0=64 1=1 5=1 6=4096
ConvolutionDepthWise 250 1 1 248 252 0=64 1=3 3=2 4=1 5=1 6=576 7=64 9=1
Convolution 253 1 1 252 253 0=128 1=1 5=1 6=8192
ConvolutionDepthWise 255 1 1 253 257 0=128 1=3 4=1 5=1 6=1152 7=128 9=1
Convolution 258 1 1 257 258 0=128 1=1 5=1 6=16384
ConvolutionDepthWise 260 1 1 258 262 0=128 1=2 5=1 6=512 7=128 9=1
Convolution 263 1 1 262 263 0=256 1=1 5=1 6=32768
Reshape 265 1 1 263 265 0=-1 1=256 2=-233
Permute 266 1 1 265 266 0=1
Split splitncnn_0 1 2 266 266_splitncnn_0 266_splitncnn_1
LSTM 300 1 1 266_splitncnn_1 300 0=48 1=49152 2=0
Squeeze 303 1 1 300 303 -23303=1,1
LSTM 326 1 1 303 326 0=48 1=9216 2=0
Squeeze 329 1 1 326 329 -23303=1,1
LSTM 386 1 1 266_splitncnn_0 386 0=48 1=98304 2=2
Reshape 391 1 1 386 391 0=96 1=-1
LSTM 437 1 1 391 437 0=48 1=36864 2=2
Reshape 442 1 1 437 442 0=96 1=-1
Concat 443 2 1 329 442 443 0=1
Reshape 457 1 1 443 457 0=144
InnerProduct 458 1 1 457 458 0=5532 1=1 2=796608
Reshape out 1 1 458 out 0=-1 1=1

@ -0,0 +1,144 @@
7767517
142 163
Input input0 0 1 input0
Convolution 346 1 1 input0 346 0=16 1=3 3=2 4=1 5=1 6=432
HardSwish 353 1 1 346 353 0=1.666667e-01
Split splitncnn_0 1 2 353 353_splitncnn_0 353_splitncnn_1
ConvolutionDepthWise 354 1 1 353_splitncnn_1 356 0=16 1=3 4=1 5=1 6=144 7=16 9=1
Convolution 357 1 1 356 357 0=16 1=1 5=1 6=256
BinaryOp 359 2 1 353_splitncnn_0 357 359
Convolution 360 1 1 359 362 0=64 1=1 5=1 6=1024 9=1
ConvolutionDepthWise 363 1 1 362 365 0=64 1=3 3=2 4=1 5=1 6=576 7=64 9=1
Convolution 366 1 1 365 366 0=24 1=1 5=1 6=1536
Split splitncnn_1 1 2 366 366_splitncnn_0 366_splitncnn_1
Convolution 368 1 1 366_splitncnn_1 370 0=72 1=1 5=1 6=1728 9=1
ConvolutionDepthWise 371 1 1 370 373 0=72 1=3 4=1 5=1 6=648 7=72 9=1
Convolution 374 1 1 373 374 0=24 1=1 5=1 6=1728
BinaryOp 376 2 1 366_splitncnn_0 374 376
Split splitncnn_2 1 2 376 376_splitncnn_0 376_splitncnn_1
Convolution 377 1 1 376_splitncnn_1 379 0=72 1=1 5=1 6=1728 9=1
ConvolutionDepthWise 380 1 1 379 380 0=72 1=5 3=2 4=2 5=1 6=1800 7=72
Split splitncnn_3 1 2 380 380_splitncnn_0 380_splitncnn_1
Pooling 388 1 1 380_splitncnn_1 392 0=1 4=1
InnerProduct 393 1 1 392 394 0=24 1=1 2=1728 9=1
InnerProduct 395 1 1 394 395 0=72 1=1 2=1728
HardSigmoid 400 1 1 395 400 0=1.666667e-01
BinaryOp 409 2 1 380_splitncnn_0 400 409 0=2
ReLU 410 1 1 409 410
Convolution 411 1 1 410 411 0=32 1=1 5=1 6=2304
Split splitncnn_4 1 2 411 411_splitncnn_0 411_splitncnn_1
Convolution 413 1 1 411_splitncnn_1 415 0=96 1=1 5=1 6=3072 9=1
ConvolutionDepthWise 416 1 1 415 416 0=96 1=5 4=2 5=1 6=2400 7=96
Split splitncnn_5 1 2 416 416_splitncnn_0 416_splitncnn_1
Pooling 424 1 1 416_splitncnn_1 428 0=1 4=1
InnerProduct 429 1 1 428 430 0=24 1=1 2=2304 9=1
InnerProduct 431 1 1 430 431 0=96 1=1 2=2304
HardSigmoid 436 1 1 431 436 0=1.666667e-01
BinaryOp 445 2 1 416_splitncnn_0 436 445 0=2
ReLU 446 1 1 445 446
Convolution 447 1 1 446 447 0=32 1=1 5=1 6=3072
BinaryOp 449 2 1 411_splitncnn_0 447 449
Split splitncnn_6 1 2 449 449_splitncnn_0 449_splitncnn_1
Convolution 450 1 1 449_splitncnn_1 452 0=96 1=1 5=1 6=3072 9=1
ConvolutionDepthWise 453 1 1 452 453 0=96 1=5 4=2 5=1 6=2400 7=96
Split splitncnn_7 1 2 453 453_splitncnn_0 453_splitncnn_1
Pooling 461 1 1 453_splitncnn_1 465 0=1 4=1
InnerProduct 466 1 1 465 467 0=24 1=1 2=2304 9=1
InnerProduct 468 1 1 467 468 0=96 1=1 2=2304
HardSigmoid 473 1 1 468 473 0=1.666667e-01
BinaryOp 482 2 1 453_splitncnn_0 473 482 0=2
ReLU 483 1 1 482 483
Convolution 484 1 1 483 484 0=32 1=1 5=1 6=3072
BinaryOp 486 2 1 449_splitncnn_0 484 486
Split splitncnn_8 1 2 486 486_splitncnn_0 486_splitncnn_1
Convolution 487 1 1 486_splitncnn_1 487 0=192 1=1 5=1 6=6144
HardSwish 494 1 1 487 494 0=1.666667e-01
ConvolutionDepthWise 495 1 1 494 495 0=192 1=3 3=2 4=1 5=1 6=1728 7=192
HardSwish 502 1 1 495 502 0=1.666667e-01
Convolution 503 1 1 502 503 0=64 1=1 5=1 6=12288
Split splitncnn_9 1 2 503 503_splitncnn_0 503_splitncnn_1
Convolution 505 1 1 503_splitncnn_1 505 0=160 1=1 5=1 6=10240
HardSwish 512 1 1 505 512 0=1.666667e-01
ConvolutionDepthWise 513 1 1 512 513 0=160 1=3 4=1 5=1 6=1440 7=160
HardSwish 520 1 1 513 520 0=1.666667e-01
Convolution 521 1 1 520 521 0=64 1=1 5=1 6=10240
BinaryOp 523 2 1 503_splitncnn_0 521 523
Split splitncnn_10 1 2 523 523_splitncnn_0 523_splitncnn_1
Convolution 524 1 1 523_splitncnn_1 524 0=144 1=1 5=1 6=9216
HardSwish 531 1 1 524 531 0=1.666667e-01
ConvolutionDepthWise 532 1 1 531 532 0=144 1=3 4=1 5=1 6=1296 7=144
HardSwish 539 1 1 532 539 0=1.666667e-01
Convolution 540 1 1 539 540 0=64 1=1 5=1 6=9216
BinaryOp 542 2 1 523_splitncnn_0 540 542
Split splitncnn_11 1 2 542 542_splitncnn_0 542_splitncnn_1
Convolution 543 1 1 542_splitncnn_1 543 0=144 1=1 5=1 6=9216
HardSwish 550 1 1 543 550 0=1.666667e-01
ConvolutionDepthWise 551 1 1 550 551 0=144 1=3 4=1 5=1 6=1296 7=144
HardSwish 558 1 1 551 558 0=1.666667e-01
Convolution 559 1 1 558 559 0=64 1=1 5=1 6=9216
BinaryOp 561 2 1 542_splitncnn_0 559 561
Convolution 562 1 1 561 562 0=384 1=1 5=1 6=24576
HardSwish 569 1 1 562 569 0=1.666667e-01
ConvolutionDepthWise 570 1 1 569 570 0=384 1=3 4=1 5=1 6=3456 7=384
Split splitncnn_12 1 2 570 570_splitncnn_0 570_splitncnn_1
Pooling 578 1 1 570_splitncnn_1 582 0=1 4=1
InnerProduct 583 1 1 582 584 0=96 1=1 2=36864 9=1
InnerProduct 585 1 1 584 585 0=384 1=1 2=36864
HardSigmoid 590 1 1 585 590 0=1.666667e-01
BinaryOp 599 2 1 570_splitncnn_0 590 599 0=2
HardSwish 605 1 1 599 605 0=1.666667e-01
Convolution 606 1 1 605 606 0=88 1=1 5=1 6=33792
Split splitncnn_13 1 2 606 606_splitncnn_0 606_splitncnn_1
Convolution 608 1 1 606_splitncnn_1 608 0=528 1=1 5=1 6=46464
HardSwish 615 1 1 608 615 0=1.666667e-01
ConvolutionDepthWise 616 1 1 615 616 0=528 1=3 4=1 5=1 6=4752 7=528
Split splitncnn_14 1 2 616 616_splitncnn_0 616_splitncnn_1
Pooling 624 1 1 616_splitncnn_1 628 0=1 4=1
InnerProduct 629 1 1 628 630 0=136 1=1 2=71808 9=1
InnerProduct 631 1 1 630 631 0=528 1=1 2=71808
HardSigmoid 636 1 1 631 636 0=1.666667e-01
BinaryOp 645 2 1 616_splitncnn_0 636 645 0=2
HardSwish 651 1 1 645 651 0=1.666667e-01
Convolution 652 1 1 651 652 0=88 1=1 5=1 6=46464
BinaryOp 654 2 1 606_splitncnn_0 652 654
Split splitncnn_15 1 2 654 654_splitncnn_0 654_splitncnn_1
Convolution 655 1 1 654_splitncnn_1 655 0=528 1=1 5=1 6=46464
HardSwish 662 1 1 655 662 0=1.666667e-01
ConvolutionDepthWise 663 1 1 662 663 0=528 1=5 3=2 4=2 5=1 6=13200 7=528
Split splitncnn_16 1 2 663 663_splitncnn_0 663_splitncnn_1
Pooling 671 1 1 663_splitncnn_1 675 0=1 4=1
InnerProduct 676 1 1 675 677 0=136 1=1 2=71808 9=1
InnerProduct 678 1 1 677 678 0=528 1=1 2=71808
HardSigmoid 683 1 1 678 683 0=1.666667e-01
BinaryOp 692 2 1 663_splitncnn_0 683 692 0=2
HardSwish 698 1 1 692 698 0=1.666667e-01
Convolution 699 1 1 698 699 0=120 1=1 5=1 6=63360
Convolution 701 1 1 699 703 0=24 1=1 5=1 6=2880 9=1
Split splitncnn_17 1 2 703 703_splitncnn_0 703_splitncnn_1
Convolution 704 1 1 654_splitncnn_0 706 0=24 1=1 5=1 6=2112 9=1
Interp 723 1 1 703_splitncnn_1 723 0=1 1=2.000000e+00 2=2.000000e+00
BinaryOp 724 2 1 723 706 724
Convolution 725 1 1 724 727 0=24 1=3 4=1 5=1 6=5184 9=1
Split splitncnn_18 1 2 727 727_splitncnn_0 727_splitncnn_1
Convolution 728 1 1 486_splitncnn_0 730 0=24 1=1 5=1 6=768 9=1
Interp 747 1 1 727_splitncnn_1 747 0=1 1=2.000000e+00 2=2.000000e+00
BinaryOp 748 2 1 747 730 748
Convolution 749 1 1 748 751 0=24 1=3 4=1 5=1 6=5184 9=1
Split splitncnn_19 1 2 751 751_splitncnn_0 751_splitncnn_1
Convolution 752 1 1 376_splitncnn_0 754 0=24 1=1 5=1 6=576 9=1
Interp 771 1 1 751_splitncnn_1 771 0=1 1=2.000000e+00 2=2.000000e+00
BinaryOp 772 2 1 771 754 772
Convolution 773 1 1 772 775 0=24 1=3 4=1 5=1 6=5184 9=1
Interp 792 1 1 751_splitncnn_0 792 0=1 1=2.000000e+00 2=2.000000e+00
Interp 803 1 1 727_splitncnn_0 803 0=1 1=4.000000e+00 2=4.000000e+00
Interp 814 1 1 703_splitncnn_0 814 0=1 1=8.000000e+00 2=8.000000e+00
Concat 815 4 1 775 792 803 814 815
Convolution 816 1 1 815 818 0=96 1=3 4=1 5=1 6=82944 9=1
Split splitncnn_20 1 2 818 818_splitncnn_0 818_splitncnn_1
Convolution 819 1 1 818_splitncnn_1 821 0=24 1=3 4=1 5=1 6=20736 9=1
Deconvolution 822 1 1 821 824 0=24 1=2 3=2 5=1 6=2304 9=1
Deconvolution 825 1 1 824 826 0=1 1=2 3=2 5=1 6=96 9=4
Convolution 827 1 1 818_splitncnn_0 829 0=24 1=3 4=1 5=1 6=20736 9=1
Deconvolution 830 1 1 829 832 0=24 1=2 3=2 5=1 6=2304 9=1
Deconvolution 833 1 1 832 834 0=1 1=2 3=2 5=1 6=96 9=4
Concat out1 2 1 826 834 out1

File diff suppressed because it is too large Load Diff

@ -0,0 +1,92 @@
7767517
90 105
Input data 0 1 data -23330=4,3,320,320,3 0=320 1=320 2=3
Convolution 0_22 1 1 data 0_22_bn_relu -23330=4,3,160,160,16 0=16 1=3 3=2 4=1 5=1 6=432 9=1
ConvolutionDepthWise 1_31 1 1 0_22_bn_relu 1_31_bn_relu -23330=4,3,160,160,16 0=16 1=3 4=1 5=1 6=144 7=16 9=1
Convolution 2_40 1 1 1_31_bn_relu 2_40_bn -23330=4,3,160,160,8 0=8 1=1 5=1 6=128
Convolution 3_49 1 1 2_40_bn 3_49_bn_relu -23330=4,3,160,160,48 0=48 1=1 5=1 6=384 9=1
ConvolutionDepthWise 4_58 1 1 3_49_bn_relu 4_58_bn_relu -23330=4,3,80,80,48 0=48 1=3 3=2 4=1 5=1 6=432 7=48 9=1
Convolution 5_67 1 1 4_58_bn_relu 5_67_bn -23330=4,3,80,80,12 0=12 1=1 5=1 6=576
Split 5_67_bn_split 1 2 5_67_bn 5_67_bn_split_0 5_67_bn_split_1 -23330=8,3,80,80,12,3,80,80,12
Convolution 6_76 1 1 5_67_bn_split_0 6_76_bn_relu -23330=4,3,80,80,72 0=72 1=1 5=1 6=864 9=1
ConvolutionDepthWise 7_85 1 1 6_76_bn_relu 7_85_bn_relu -23330=4,3,80,80,72 0=72 1=3 4=1 5=1 6=648 7=72 9=1
Convolution 8_94 1 1 7_85_bn_relu 8_94_bn -23330=4,3,80,80,12 0=12 1=1 5=1 6=864
Eltwise 9_103 2 1 8_94_bn 5_67_bn_split_1 9_103 -23330=4,3,80,80,12 0=1
Convolution 10_107 1 1 9_103 10_107_bn_relu -23330=4,3,80,80,72 0=72 1=1 5=1 6=864 9=1
ConvolutionDepthWise 11_116 1 1 10_107_bn_relu 11_116_bn_relu -23330=4,3,40,40,72 0=72 1=3 3=2 4=1 5=1 6=648 7=72 9=1
Convolution 12_125 1 1 11_116_bn_relu 12_125_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1152
Split 12_125_bn_split 1 2 12_125_bn 12_125_bn_split_0 12_125_bn_split_1 -23330=8,3,40,40,16,3,40,40,16
Convolution 13_134 1 1 12_125_bn_split_0 13_134_bn_relu -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 14_143 1 1 13_134_bn_relu 14_143_bn_relu -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=1
Convolution 15_152 1 1 14_143_bn_relu 15_152_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1536
Eltwise 16_161 2 1 15_152_bn 12_125_bn_split_1 16_161 -23330=4,3,40,40,16 0=1
Split 16_161_split 1 2 16_161 16_161_split_0 16_161_split_1 -23330=8,3,40,40,16,3,40,40,16
Convolution 17_165 1 1 16_161_split_0 17_165_bn_relu -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 18_174 1 1 17_165_bn_relu 18_174_bn_relu -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=1
Convolution 19_183 1 1 18_174_bn_relu 19_183_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1536
Eltwise 20_192 2 1 19_183_bn 16_161_split_1 20_192 -23330=4,3,40,40,16 0=1
Convolution 21_196 1 1 20_192 21_196_bn_relu -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 22_205 1 1 21_196_bn_relu 22_205_bn_relu -23330=4,3,20,20,96 0=96 1=3 3=2 4=1 5=1 6=864 7=96 9=1
Convolution 23_214 1 1 22_205_bn_relu 23_214_bn -23330=4,3,20,20,32 0=32 1=1 5=1 6=3072
Split 23_214_bn_split 1 2 23_214_bn 23_214_bn_split_0 23_214_bn_split_1 -23330=8,3,20,20,32,3,20,20,32
Convolution 24_223 1 1 23_214_bn_split_0 24_223_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=6144 9=1
ConvolutionDepthWise 25_232 1 1 24_223_bn_relu 25_232_bn_relu -23330=4,3,20,20,192 0=192 1=3 4=1 5=1 6=1728 7=192 9=1
Convolution 26_241 1 1 25_232_bn_relu 26_241_bn -23330=4,3,20,20,32 0=32 1=1 5=1 6=6144
Eltwise 27_250 2 1 26_241_bn 23_214_bn_split_1 27_250 -23330=4,3,20,20,32 0=1
Split 27_250_split 1 2 27_250 27_250_split_0 27_250_split_1 -23330=8,3,20,20,32,3,20,20,32
Convolution 28_254 1 1 27_250_split_0 28_254_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=6144 9=1
ConvolutionDepthWise 29_263 1 1 28_254_bn_relu 29_263_bn_relu -23330=4,3,20,20,192 0=192 1=3 4=1 5=1 6=1728 7=192 9=1
Convolution 30_272 1 1 29_263_bn_relu 30_272_bn -23330=4,3,20,20,32 0=32 1=1 5=1 6=6144
Eltwise 31_281 2 1 30_272_bn 27_250_split_1 31_281 -23330=4,3,20,20,32 0=1
Split 31_281_split 1 2 31_281 31_281_split_0 31_281_split_1 -23330=8,3,20,20,32,3,20,20,32
Convolution 32_285 1 1 31_281_split_0 32_285_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=6144 9=1
ConvolutionDepthWise 33_294 1 1 32_285_bn_relu 33_294_bn_relu -23330=4,3,20,20,192 0=192 1=3 4=1 5=1 6=1728 7=192 9=1
Convolution 34_303 1 1 33_294_bn_relu 34_303_bn -23330=4,3,20,20,32 0=32 1=1 5=1 6=6144
Eltwise 35_312 2 1 34_303_bn 31_281_split_1 35_312 -23330=4,3,20,20,32 0=1
Convolution 36_316 1 1 35_312 36_316_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=6144 9=1
ConvolutionDepthWise 37_325 1 1 36_316_bn_relu 37_325_bn_relu -23330=4,3,20,20,192 0=192 1=3 4=1 5=1 6=1728 7=192 9=1
Convolution 38_334 1 1 37_325_bn_relu 38_334_bn -23330=4,3,20,20,48 0=48 1=1 5=1 6=9216
Split 38_334_bn_split 1 2 38_334_bn 38_334_bn_split_0 38_334_bn_split_1 -23330=8,3,20,20,48,3,20,20,48
Convolution 39_343 1 1 38_334_bn_split_0 39_343_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=13824 9=1
ConvolutionDepthWise 40_352 1 1 39_343_bn_relu 40_352_bn_relu -23330=4,3,20,20,288 0=288 1=3 4=1 5=1 6=2592 7=288 9=1
Convolution 41_361 1 1 40_352_bn_relu 41_361_bn -23330=4,3,20,20,48 0=48 1=1 5=1 6=13824
Eltwise 42_370 2 1 41_361_bn 38_334_bn_split_1 42_370 -23330=4,3,20,20,48 0=1
Split 42_370_split 1 2 42_370 42_370_split_0 42_370_split_1 -23330=8,3,20,20,48,3,20,20,48
Convolution 43_374 1 1 42_370_split_0 43_374_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=13824 9=1
ConvolutionDepthWise 44_383 1 1 43_374_bn_relu 44_383_bn_relu -23330=4,3,20,20,288 0=288 1=3 4=1 5=1 6=2592 7=288 9=1
Convolution 45_392 1 1 44_383_bn_relu 45_392_bn -23330=4,3,20,20,48 0=48 1=1 5=1 6=13824
Eltwise 46_401 2 1 45_392_bn 42_370_split_1 46_401 -23330=4,3,20,20,48 0=1
Convolution 47_405 1 1 46_401 47_405_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=13824 9=1
Split 47_405_bn_relu_split 1 2 47_405_bn_relu 47_405_bn_relu_split_0 47_405_bn_relu_split_1 -23330=8,3,20,20,288,3,20,20,288
ConvolutionDepthWise 48_414 1 1 47_405_bn_relu_split_0 48_414_bn_relu -23330=4,3,10,10,288 0=288 1=3 3=2 4=1 5=1 6=2592 7=288 9=1
Convolution 49_423 1 1 48_414_bn_relu 49_423_bn -23330=4,3,10,10,80 0=80 1=1 5=1 6=23040
Split 49_423_bn_split 1 2 49_423_bn 49_423_bn_split_0 49_423_bn_split_1 -23330=8,3,10,10,80,3,10,10,80
Convolution 50_432 1 1 49_423_bn_split_0 50_432_bn_relu -23330=4,3,10,10,480 0=480 1=1 5=1 6=38400 9=1
ConvolutionDepthWise 51_441 1 1 50_432_bn_relu 51_441_bn_relu -23330=4,3,10,10,480 0=480 1=3 4=1 5=1 6=4320 7=480 9=1
Convolution 52_450 1 1 51_441_bn_relu 52_450_bn -23330=4,3,10,10,80 0=80 1=1 5=1 6=38400
Eltwise 53_459 2 1 52_450_bn 49_423_bn_split_1 53_459 -23330=4,3,10,10,80 0=1
Split 53_459_split 1 2 53_459 53_459_split_0 53_459_split_1 -23330=8,3,10,10,80,3,10,10,80
Convolution 54_463 1 1 53_459_split_0 54_463_bn_relu -23330=4,3,10,10,480 0=480 1=1 5=1 6=38400 9=1
ConvolutionDepthWise 55_472 1 1 54_463_bn_relu 55_472_bn_relu -23330=4,3,10,10,480 0=480 1=3 4=1 5=1 6=4320 7=480 9=1
Convolution 56_481 1 1 55_472_bn_relu 56_481_bn -23330=4,3,10,10,80 0=80 1=1 5=1 6=38400
Eltwise 57_490 2 1 56_481_bn 53_459_split_1 57_490 -23330=4,3,10,10,80 0=1
Split 57_490_split 1 4 57_490 57_490_split_0 57_490_split_1 57_490_split_2 57_490_split_3 -23330=16,3,10,10,80,3,10,10,80,3,10,10,80,3,10,10,80
Pooling 58_494 1 1 57_490_split_0 58_494 -23330=4,3,10,10,80 1=3 14=2 15=2 5=1
Pooling 60_501 1 1 57_490_split_1 60_501 -23330=4,3,10,10,80 1=5 14=4 15=4 5=1
Pooling 62_508 1 1 57_490_split_2 62_508 -23330=4,3,10,10,80 1=9 14=8 15=8 5=1
Concat 63_512 4 1 62_508 60_501 58_494 57_490_split_3 63_512 -23330=4,3,10,10,320
Convolution 64_517 1 1 63_512 64_517_bn_relu -23330=4,3,10,10,288 0=288 1=1 5=1 6=92160 9=1
Split 64_517_bn_relu_split 1 2 64_517_bn_relu 64_517_bn_relu_split_0 64_517_bn_relu_split_1 -23330=8,3,10,10,288,3,10,10,288
ConvolutionDepthWise 65_525 1 1 64_517_bn_relu_split_0 65_525_bn_relu -23330=4,3,10,10,288 0=288 1=3 4=1 5=1 6=2592 7=288 9=1
Convolution 66_534 1 1 65_525_bn_relu 66_534_bn_relu -23330=4,3,10,10,96 0=96 1=1 5=1 6=27648 9=1
Convolution 67_542 1 1 66_534_bn_relu 67_542_bn_relu -23330=4,3,10,10,384 0=384 1=1 5=1 6=36864 9=1
Convolution 68_550 1 1 67_542_bn_relu 68_550 -23330=4,3,10,10,18 0=18 1=1 5=1 6=6912
Interp 71_580 1 1 64_517_bn_relu_split_1 71_580 -23330=4,3,20,20,288 0=1 1=2.000000e+00 2=2.000000e+00
Concat 72_583 2 1 71_580 47_405_bn_relu_split_1 72_583 -23330=4,3,20,20,576
Convolution 73_586 1 1 72_583 73_586_bn_relu -23330=4,3,20,20,80 0=80 1=1 5=1 6=46080 9=1
Convolution 74_595 1 1 73_586_bn_relu 74_595_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=23040 9=1
ConvolutionDepthWise 75_603 1 1 74_595_bn_relu 75_603_bn_relu -23330=4,3,20,20,288 0=288 1=3 4=1 5=1 6=2592 7=288 9=1
Convolution 76_612 1 1 75_603_bn_relu 76_612_bn_relu -23330=4,3,20,20,192 0=192 1=1 5=1 6=55296 9=1
Convolution 77_620 1 1 76_612_bn_relu 77_620_bn_relu -23330=4,3,20,20,288 0=288 1=1 5=1 6=55296 9=1
Convolution 78_628 1 1 77_620_bn_relu 78_628 -23330=4,3,20,20,18 0=18 1=1 5=1 6=5184
Yolov3DetectionOutput detection_out 2 1 68_550 78_628 output -23330=4,2,6,101,1 0=1 1=3 2=0.65 -23304=12,9.000000e+00,2.100000e+01,2.500000e+01,5.800000e+01,4.100000e+01,1.360000e+02,8.500000e+01,1.030000e+02,8.600000e+01,2.200000e+02,1.870000e+02,2.540000e+02 -23305=6,1077936128,1082130432,1084227584,0,1065353216,1073741824 -23306=2,3.200000e+01,1.600000e+01

@ -0,0 +1,196 @@
7767517
194 227
Input input.1 0 1 input.1
MemoryData 528 0 1 528 0=1
Convolution Conv_0 1 1 input.1 357 0=64 1=7 3=2 4=3 5=1 6=9408 9=1
Pooling MaxPool_3 1 1 357 358 1=3 2=2 3=1 5=1
Split splitncnn_0 1 2 358 358_splitncnn_0 358_splitncnn_1
Convolution Conv_4 1 1 358_splitncnn_1 361 0=64 1=1 5=1 6=4096 9=1
Convolution Conv_7 1 1 361 364 0=64 1=3 4=1 5=1 6=36864 9=1
Convolution Conv_10 1 1 364 366 0=256 1=1 5=1 6=16384
Convolution Conv_12 1 1 358_splitncnn_0 368 0=256 1=1 5=1 6=16384
BinaryOp Add_14 2 1 366 368 369
ReLU Relu_15 1 1 369 370
Split splitncnn_1 1 2 370 370_splitncnn_0 370_splitncnn_1
Convolution Conv_16 1 1 370_splitncnn_1 373 0=64 1=1 5=1 6=16384 9=1
Convolution Conv_19 1 1 373 376 0=64 1=3 4=1 5=1 6=36864 9=1
Convolution Conv_22 1 1 376 378 0=256 1=1 5=1 6=16384
BinaryOp Add_24 2 1 378 370_splitncnn_0 379
ReLU Relu_25 1 1 379 380
Split splitncnn_2 1 2 380 380_splitncnn_0 380_splitncnn_1
Convolution Conv_26 1 1 380_splitncnn_1 383 0=64 1=1 5=1 6=16384 9=1
Convolution Conv_29 1 1 383 386 0=64 1=3 4=1 5=1 6=36864 9=1
Convolution Conv_32 1 1 386 388 0=256 1=1 5=1 6=16384
BinaryOp Add_34 2 1 388 380_splitncnn_0 389
ReLU Relu_35 1 1 389 390
Split splitncnn_3 1 2 390 390_splitncnn_0 390_splitncnn_1
Convolution Conv_36 1 1 390_splitncnn_1 393 0=128 1=1 5=1 6=32768 9=1
Convolution Conv_39 1 1 393 396 0=128 1=3 3=2 4=1 5=1 6=147456 9=1
Convolution Conv_42 1 1 396 398 0=512 1=1 5=1 6=65536
Convolution Conv_44 1 1 390_splitncnn_0 400 0=512 1=1 3=2 5=1 6=131072
BinaryOp Add_46 2 1 398 400 401
ReLU Relu_47 1 1 401 402
Split splitncnn_4 1 2 402 402_splitncnn_0 402_splitncnn_1
Convolution Conv_48 1 1 402_splitncnn_1 405 0=128 1=1 5=1 6=65536 9=1
Convolution Conv_51 1 1 405 408 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_54 1 1 408 410 0=512 1=1 5=1 6=65536
BinaryOp Add_56 2 1 410 402_splitncnn_0 411
ReLU Relu_57 1 1 411 412
Split splitncnn_5 1 2 412 412_splitncnn_0 412_splitncnn_1
Convolution Conv_58 1 1 412_splitncnn_1 415 0=128 1=1 5=1 6=65536 9=1
Convolution Conv_61 1 1 415 418 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_64 1 1 418 420 0=512 1=1 5=1 6=65536
BinaryOp Add_66 2 1 420 412_splitncnn_0 421
ReLU Relu_67 1 1 421 422
Split splitncnn_6 1 2 422 422_splitncnn_0 422_splitncnn_1
Convolution Conv_68 1 1 422_splitncnn_1 425 0=128 1=1 5=1 6=65536 9=1
Convolution Conv_71 1 1 425 428 0=128 1=3 4=1 5=1 6=147456 9=1
Convolution Conv_74 1 1 428 430 0=512 1=1 5=1 6=65536
BinaryOp Add_76 2 1 430 422_splitncnn_0 431
ReLU Relu_77 1 1 431 432
Split splitncnn_7 1 3 432 432_splitncnn_0 432_splitncnn_1 432_splitncnn_2
Convolution Conv_78 1 1 432_splitncnn_2 435 0=256 1=1 5=1 6=131072 9=1
Convolution Conv_81 1 1 435 438 0=256 1=3 3=2 4=1 5=1 6=589824 9=1
Convolution Conv_84 1 1 438 440 0=1024 1=1 5=1 6=262144
Convolution Conv_86 1 1 432_splitncnn_1 442 0=1024 1=1 3=2 5=1 6=524288
BinaryOp Add_88 2 1 440 442 443
ReLU Relu_89 1 1 443 444
Split splitncnn_8 1 2 444 444_splitncnn_0 444_splitncnn_1
Convolution Conv_90 1 1 444_splitncnn_1 447 0=256 1=1 5=1 6=262144 9=1
Convolution Conv_93 1 1 447 450 0=256 1=3 4=1 5=1 6=589824 9=1
Convolution Conv_96 1 1 450 452 0=1024 1=1 5=1 6=262144
BinaryOp Add_98 2 1 452 444_splitncnn_0 453
ReLU Relu_99 1 1 453 454
Split splitncnn_9 1 2 454 454_splitncnn_0 454_splitncnn_1
Convolution Conv_100 1 1 454_splitncnn_1 457 0=256 1=1 5=1 6=262144 9=1
Convolution Conv_103 1 1 457 460 0=256 1=3 4=1 5=1 6=589824 9=1
Convolution Conv_106 1 1 460 462 0=1024 1=1 5=1 6=262144
BinaryOp Add_108 2 1 462 454_splitncnn_0 463
ReLU Relu_109 1 1 463 464
Split splitncnn_10 1 2 464 464_splitncnn_0 464_splitncnn_1
Convolution Conv_110 1 1 464_splitncnn_1 467 0=256 1=1 5=1 6=262144 9=1
Convolution Conv_113 1 1 467 470 0=256 1=3 4=1 5=1 6=589824 9=1
Convolution Conv_116 1 1 470 472 0=1024 1=1 5=1 6=262144
BinaryOp Add_118 2 1 472 464_splitncnn_0 473
ReLU Relu_119 1 1 473 474
Split splitncnn_11 1 2 474 474_splitncnn_0 474_splitncnn_1
Convolution Conv_120 1 1 474_splitncnn_1 477 0=256 1=1 5=1 6=262144 9=1
Convolution Conv_123 1 1 477 480 0=256 1=3 4=1 5=1 6=589824 9=1
Convolution Conv_126 1 1 480 482 0=1024 1=1 5=1 6=262144
BinaryOp Add_128 2 1 482 474_splitncnn_0 483
ReLU Relu_129 1 1 483 484
Split splitncnn_12 1 2 484 484_splitncnn_0 484_splitncnn_1
Convolution Conv_130 1 1 484_splitncnn_1 487 0=256 1=1 5=1 6=262144 9=1
Convolution Conv_133 1 1 487 490 0=256 1=3 4=1 5=1 6=589824 9=1
Convolution Conv_136 1 1 490 492 0=1024 1=1 5=1 6=262144
BinaryOp Add_138 2 1 492 484_splitncnn_0 493
ReLU Relu_139 1 1 493 494
Split splitncnn_13 1 3 494 494_splitncnn_0 494_splitncnn_1 494_splitncnn_2
Convolution Conv_140 1 1 494_splitncnn_2 497 0=512 1=1 5=1 6=524288 9=1
Convolution Conv_143 1 1 497 500 0=512 1=3 3=2 4=1 5=1 6=2359296 9=1
Convolution Conv_146 1 1 500 502 0=2048 1=1 5=1 6=1048576
Convolution Conv_148 1 1 494_splitncnn_1 504 0=2048 1=1 3=2 5=1 6=2097152
BinaryOp Add_150 2 1 502 504 505
ReLU Relu_151 1 1 505 506
Split splitncnn_14 1 2 506 506_splitncnn_0 506_splitncnn_1
Convolution Conv_152 1 1 506_splitncnn_1 509 0=512 1=1 5=1 6=1048576 9=1
Convolution Conv_155 1 1 509 512 0=512 1=3 4=1 5=1 6=2359296 9=1
Convolution Conv_158 1 1 512 514 0=2048 1=1 5=1 6=1048576
BinaryOp Add_160 2 1 514 506_splitncnn_0 515
ReLU Relu_161 1 1 515 516
Split splitncnn_15 1 2 516 516_splitncnn_0 516_splitncnn_1
Convolution Conv_162 1 1 516_splitncnn_1 519 0=512 1=1 5=1 6=1048576 9=1
Convolution Conv_165 1 1 519 522 0=512 1=3 4=1 5=1 6=2359296 9=1
Convolution Conv_168 1 1 522 524 0=2048 1=1 5=1 6=1048576
BinaryOp Add_170 2 1 524 516_splitncnn_0 525
ReLU Relu_171 1 1 525 526
Convolution Conv_172 1 1 526 527 0=256 1=1 5=1 6=524288
BinaryOp Add_174 2 1 528 527 529
Split splitncnn_16 1 2 529 529_splitncnn_0 529_splitncnn_1
Interp Resize_193 1 1 529_splitncnn_1 548 0=2 3=35 4=35
Convolution Conv_194 1 1 494_splitncnn_0 549 0=256 1=1 5=1 6=262144
BinaryOp Add_195 2 1 548 549 550
Split splitncnn_17 1 2 550 550_splitncnn_0 550_splitncnn_1
Interp Resize_214 1 1 550_splitncnn_1 569 0=2 3=69 4=69
Convolution Conv_215 1 1 432_splitncnn_0 570 0=256 1=1 5=1 6=131072
BinaryOp Add_216 2 1 569 570 571
Convolution Conv_217 1 1 529_splitncnn_0 573 0=256 1=3 4=1 5=1 6=589824 9=1
Split splitncnn_18 1 2 573 573_splitncnn_0 573_splitncnn_1
Convolution Conv_219 1 1 550_splitncnn_0 575 0=256 1=3 4=1 5=1 6=589824 9=1
Convolution Conv_221 1 1 571 577 0=256 1=3 4=1 5=1 6=589824 9=1
Split splitncnn_19 1 2 577 577_splitncnn_0 577_splitncnn_1
Convolution Conv_223 1 1 573_splitncnn_1 578 0=256 1=3 3=2 4=1 5=1 6=589824
Split splitncnn_20 1 2 578 578_splitncnn_0 578_splitncnn_1
Convolution Conv_224 1 1 578_splitncnn_1 579 0=256 1=3 3=2 4=1 5=1 6=589824
Convolution Conv_225 1 1 577_splitncnn_1 581 0=256 1=3 4=1 5=1 6=589824 9=1
Convolution Conv_227 1 1 581 583 0=256 1=3 4=1 5=1 6=589824 9=1
Convolution Conv_229 1 1 583 585 0=256 1=3 4=1 5=1 6=589824 9=1
Interp Resize_259 1 1 585 614 0=2 3=138 4=138
ReLU Relu_260 1 1 614 615
Convolution Conv_261 1 1 615 617 0=256 1=3 4=1 5=1 6=589824 9=1
Convolution Conv_263 1 1 617 619 0=32 1=1 5=1 6=8192 9=1
Permute Transpose_265 1 1 619 620 0=3
Convolution Conv_266 1 1 577_splitncnn_0 622 0=256 1=3 4=1 5=1 6=589824 9=1
Split splitncnn_21 1 3 622 622_splitncnn_0 622_splitncnn_1 622_splitncnn_2
Convolution Conv_268 1 1 622_splitncnn_2 623 0=12 1=3 4=1 5=1 6=27648
Permute Transpose_269 1 1 623 624 0=3
Reshape Reshape_275 1 1 624 634 0=4 1=-1
Convolution Conv_276 1 1 622_splitncnn_1 635 0=243 1=3 4=1 5=1 6=559872
Permute Transpose_277 1 1 635 636 0=3
Reshape Reshape_283 1 1 636 646 0=81 1=-1
Convolution Conv_284 1 1 622_splitncnn_0 647 0=96 1=3 4=1 5=1 6=221184
Permute Transpose_285 1 1 647 648 0=3
Reshape Reshape_291 1 1 648 658 0=32 1=-1
UnaryOp Tanh_292 1 1 658 659 0=16
Convolution Conv_293 1 1 575 661 0=256 1=3 4=1 5=1 6=589824 9=1
Split splitncnn_22 1 3 661 661_splitncnn_0 661_splitncnn_1 661_splitncnn_2
Convolution Conv_295 1 1 661_splitncnn_2 662 0=12 1=3 4=1 5=1 6=27648
Permute Transpose_296 1 1 662 663 0=3
Reshape Reshape_302 1 1 663 673 0=4 1=-1
Convolution Conv_303 1 1 661_splitncnn_1 674 0=243 1=3 4=1 5=1 6=559872
Permute Transpose_304 1 1 674 675 0=3
Reshape Reshape_310 1 1 675 685 0=81 1=-1
Convolution Conv_311 1 1 661_splitncnn_0 686 0=96 1=3 4=1 5=1 6=221184
Permute Transpose_312 1 1 686 687 0=3
Reshape Reshape_318 1 1 687 697 0=32 1=-1
UnaryOp Tanh_319 1 1 697 698 0=16
Convolution Conv_320 1 1 573_splitncnn_0 700 0=256 1=3 4=1 5=1 6=589824 9=1
Split splitncnn_23 1 3 700 700_splitncnn_0 700_splitncnn_1 700_splitncnn_2
Convolution Conv_322 1 1 700_splitncnn_2 701 0=12 1=3 4=1 5=1 6=27648
Permute Transpose_323 1 1 701 702 0=3
Reshape Reshape_329 1 1 702 712 0=4 1=-1
Convolution Conv_330 1 1 700_splitncnn_1 713 0=243 1=3 4=1 5=1 6=559872
Permute Transpose_331 1 1 713 714 0=3
Reshape Reshape_337 1 1 714 724 0=81 1=-1
Convolution Conv_338 1 1 700_splitncnn_0 725 0=96 1=3 4=1 5=1 6=221184
Permute Transpose_339 1 1 725 726 0=3
Reshape Reshape_345 1 1 726 736 0=32 1=-1
UnaryOp Tanh_346 1 1 736 737 0=16
Convolution Conv_347 1 1 578_splitncnn_0 739 0=256 1=3 4=1 5=1 6=589824 9=1
Split splitncnn_24 1 3 739 739_splitncnn_0 739_splitncnn_1 739_splitncnn_2
Convolution Conv_349 1 1 739_splitncnn_2 740 0=12 1=3 4=1 5=1 6=27648
Permute Transpose_350 1 1 740 741 0=3
Reshape Reshape_356 1 1 741 751 0=4 1=-1
Convolution Conv_357 1 1 739_splitncnn_1 752 0=243 1=3 4=1 5=1 6=559872
Permute Transpose_358 1 1 752 753 0=3
Reshape Reshape_364 1 1 753 763 0=81 1=-1
Convolution Conv_365 1 1 739_splitncnn_0 764 0=96 1=3 4=1 5=1 6=221184
Permute Transpose_366 1 1 764 765 0=3
Reshape Reshape_372 1 1 765 775 0=32 1=-1
UnaryOp Tanh_373 1 1 775 776 0=16
Convolution Conv_374 1 1 579 778 0=256 1=3 4=1 5=1 6=589824 9=1
Split splitncnn_25 1 3 778 778_splitncnn_0 778_splitncnn_1 778_splitncnn_2
Convolution Conv_376 1 1 778_splitncnn_2 779 0=12 1=3 4=1 5=1 6=27648
Permute Transpose_377 1 1 779 780 0=3
Reshape Reshape_383 1 1 780 790 0=4 1=-1
Convolution Conv_384 1 1 778_splitncnn_1 791 0=243 1=3 4=1 5=1 6=559872
Permute Transpose_385 1 1 791 792 0=3
Reshape Reshape_391 1 1 792 802 0=81 1=-1
Convolution Conv_392 1 1 778_splitncnn_0 803 0=96 1=3 4=1 5=1 6=221184
Permute Transpose_393 1 1 803 804 0=3
Reshape Reshape_399 1 1 804 814 0=32 1=-1
UnaryOp Tanh_400 1 1 814 815 0=16
Concat Concat_401 5 1 634 673 712 751 790 816 0=0
Concat Concat_402 5 1 646 685 724 763 802 817 0=0
Concat Concat_403 5 1 659 698 737 776 815 818 0=0
Softmax Softmax_405 1 1 817 820 0=1 1=1

@ -0,0 +1,129 @@
7767517
127 147
Input data 0 1 data -23330=4,3,320,320,3 0=320 1=320 2=3
Convolution 0_22 1 1 data 0_22_bn_leaky -23330=4,3,160,160,8 0=8 1=3 3=2 4=1 5=1 6=216 9=2 -23310=1,1.000000e-01
Convolution 1_31 1 1 0_22_bn_leaky 1_31_bn_leaky -23330=4,3,160,160,8 0=8 1=1 5=1 6=64 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 2_39 1 1 1_31_bn_leaky 2_39_bn_leaky -23330=4,3,160,160,8 0=8 1=3 4=1 5=1 6=72 7=8 9=2 -23310=1,1.000000e-01
Convolution 3_48 1 1 2_39_bn_leaky 3_48_bn -23330=4,3,160,160,4 0=4 1=1 5=1 6=32
Split 3_48_bn_split 1 2 3_48_bn 3_48_bn_split_0 3_48_bn_split_1 -23330=8,3,160,160,4,3,160,160,4
Convolution 4_57 1 1 3_48_bn_split_0 4_57_bn_leaky -23330=4,3,160,160,8 0=8 1=1 5=1 6=32 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 5_65 1 1 4_57_bn_leaky 5_65_bn_leaky -23330=4,3,160,160,8 0=8 1=3 4=1 5=1 6=72 7=8 9=2 -23310=1,1.000000e-01
Convolution 6_74 1 1 5_65_bn_leaky 6_74_bn -23330=4,3,160,160,4 0=4 1=1 5=1 6=32
Eltwise 8_86 2 1 6_74_bn 3_48_bn_split_1 8_86 -23330=4,3,160,160,4 0=1
Convolution 9_90 1 1 8_86 9_90_bn_leaky -23330=4,3,160,160,24 0=24 1=1 5=1 6=96 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 10_98 1 1 9_90_bn_leaky 10_98_bn_leaky -23330=4,3,80,80,24 0=24 1=3 3=2 4=1 5=1 6=216 7=24 9=2 -23310=1,1.000000e-01
Convolution 11_107 1 1 10_98_bn_leaky 11_107_bn -23330=4,3,80,80,8 0=8 1=1 5=1 6=192
Split 11_107_bn_split 1 2 11_107_bn 11_107_bn_split_0 11_107_bn_split_1 -23330=8,3,80,80,8,3,80,80,8
Convolution 12_116 1 1 11_107_bn_split_0 12_116_bn_leaky -23330=4,3,80,80,32 0=32 1=1 5=1 6=256 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 13_124 1 1 12_116_bn_leaky 13_124_bn_leaky -23330=4,3,80,80,32 0=32 1=3 4=1 5=1 6=288 7=32 9=2 -23310=1,1.000000e-01
Convolution 14_133 1 1 13_124_bn_leaky 14_133_bn -23330=4,3,80,80,8 0=8 1=1 5=1 6=256
Eltwise 16_145 2 1 14_133_bn 11_107_bn_split_1 16_145 -23330=4,3,80,80,8 0=1
Split 16_145_split 1 2 16_145 16_145_split_0 16_145_split_1 -23330=8,3,80,80,8,3,80,80,8
Convolution 17_149 1 1 16_145_split_0 17_149_bn_leaky -23330=4,3,80,80,32 0=32 1=1 5=1 6=256 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 18_157 1 1 17_149_bn_leaky 18_157_bn_leaky -23330=4,3,80,80,32 0=32 1=3 4=1 5=1 6=288 7=32 9=2 -23310=1,1.000000e-01
Convolution 19_166 1 1 18_157_bn_leaky 19_166_bn -23330=4,3,80,80,8 0=8 1=1 5=1 6=256
Eltwise 21_179 2 1 19_166_bn 16_145_split_1 21_179 -23330=4,3,80,80,8 0=1
Convolution 22_183 1 1 21_179 22_183_bn_leaky -23330=4,3,80,80,32 0=32 1=1 5=1 6=256 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 23_191 1 1 22_183_bn_leaky 23_191_bn_leaky -23330=4,3,40,40,32 0=32 1=3 3=2 4=1 5=1 6=288 7=32 9=2 -23310=1,1.000000e-01
Convolution 24_200 1 1 23_191_bn_leaky 24_200_bn -23330=4,3,40,40,8 0=8 1=1 5=1 6=256
Split 24_200_bn_split 1 2 24_200_bn 24_200_bn_split_0 24_200_bn_split_1 -23330=8,3,40,40,8,3,40,40,8
Convolution 25_209 1 1 24_200_bn_split_0 25_209_bn_leaky -23330=4,3,40,40,48 0=48 1=1 5=1 6=384 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 26_217 1 1 25_209_bn_leaky 26_217_bn_leaky -23330=4,3,40,40,48 0=48 1=3 4=1 5=1 6=432 7=48 9=2 -23310=1,1.000000e-01
Convolution 27_226 1 1 26_217_bn_leaky 27_226_bn -23330=4,3,40,40,8 0=8 1=1 5=1 6=384
Eltwise 29_238 2 1 27_226_bn 24_200_bn_split_1 29_238 -23330=4,3,40,40,8 0=1
Split 29_238_split 1 2 29_238 29_238_split_0 29_238_split_1 -23330=8,3,40,40,8,3,40,40,8
Convolution 30_242 1 1 29_238_split_0 30_242_bn_leaky -23330=4,3,40,40,48 0=48 1=1 5=1 6=384 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 31_250 1 1 30_242_bn_leaky 31_250_bn_leaky -23330=4,3,40,40,48 0=48 1=3 4=1 5=1 6=432 7=48 9=2 -23310=1,1.000000e-01
Convolution 32_259 1 1 31_250_bn_leaky 32_259_bn -23330=4,3,40,40,8 0=8 1=1 5=1 6=384
Eltwise 34_273 2 1 32_259_bn 29_238_split_1 34_273 -23330=4,3,40,40,8 0=1
Convolution 35_277 1 1 34_273 35_277_bn_leaky -23330=4,3,40,40,48 0=48 1=1 5=1 6=384 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 36_285 1 1 35_277_bn_leaky 36_285_bn_leaky -23330=4,3,40,40,48 0=48 1=3 4=1 5=1 6=432 7=48 9=2 -23310=1,1.000000e-01
Convolution 37_294 1 1 36_285_bn_leaky 37_294_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=768
Split 37_294_bn_split 1 2 37_294_bn 37_294_bn_split_0 37_294_bn_split_1 -23330=8,3,40,40,16,3,40,40,16
Convolution 38_303 1 1 37_294_bn_split_0 38_303_bn_leaky -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 39_311 1 1 38_303_bn_leaky 39_311_bn_leaky -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution 40_320 1 1 39_311_bn_leaky 40_320_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1536
Eltwise 42_332 2 1 40_320_bn 37_294_bn_split_1 42_332 -23330=4,3,40,40,16 0=1
Split 42_332_split 1 2 42_332 42_332_split_0 42_332_split_1 -23330=8,3,40,40,16,3,40,40,16
Convolution 43_336 1 1 42_332_split_0 43_336_bn_leaky -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 44_344 1 1 43_336_bn_leaky 44_344_bn_leaky -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution 45_353 1 1 44_344_bn_leaky 45_353_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1536
Eltwise 47_365 2 1 45_353_bn 42_332_split_1 47_365 -23330=4,3,40,40,16 0=1
Split 47_365_split 1 2 47_365 47_365_split_0 47_365_split_1 -23330=8,3,40,40,16,3,40,40,16
Convolution 48_369 1 1 47_365_split_0 48_369_bn_leaky -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 49_377 1 1 48_369_bn_leaky 49_377_bn_leaky -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution 50_386 1 1 49_377_bn_leaky 50_386_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1536
Eltwise 52_399 2 1 50_386_bn 47_365_split_1 52_399 -23330=4,3,40,40,16 0=1
Split 52_399_split 1 2 52_399 52_399_split_0 52_399_split_1 -23330=8,3,40,40,16,3,40,40,16
Convolution 53_403 1 1 52_399_split_0 53_403_bn_leaky -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 54_411 1 1 53_403_bn_leaky 54_411_bn_leaky -23330=4,3,40,40,96 0=96 1=3 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution 55_420 1 1 54_411_bn_leaky 55_420_bn -23330=4,3,40,40,16 0=16 1=1 5=1 6=1536
Eltwise 57_433 2 1 55_420_bn 52_399_split_1 57_433 -23330=4,3,40,40,16 0=1
Convolution 58_437 1 1 57_433 58_437_bn_leaky -23330=4,3,40,40,96 0=96 1=1 5=1 6=1536 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 59_445 1 1 58_437_bn_leaky 59_445_bn_leaky -23330=4,3,20,20,96 0=96 1=3 3=2 4=1 5=1 6=864 7=96 9=2 -23310=1,1.000000e-01
Convolution 60_454 1 1 59_445_bn_leaky 60_454_bn -23330=4,3,20,20,24 0=24 1=1 5=1 6=2304
Split 60_454_bn_split 1 2 60_454_bn 60_454_bn_split_0 60_454_bn_split_1 -23330=8,3,20,20,24,3,20,20,24
Convolution 61_463 1 1 60_454_bn_split_0 61_463_bn_leaky -23330=4,3,20,20,136 0=136 1=1 5=1 6=3264 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 62_471 1 1 61_463_bn_leaky 62_471_bn_leaky -23330=4,3,20,20,136 0=136 1=3 4=1 5=1 6=1224 7=136 9=2 -23310=1,1.000000e-01
Convolution 63_480 1 1 62_471_bn_leaky 63_480_bn -23330=4,3,20,20,24 0=24 1=1 5=1 6=3264
Eltwise 65_492 2 1 63_480_bn 60_454_bn_split_1 65_492 -23330=4,3,20,20,24 0=1
Split 65_492_split 1 2 65_492 65_492_split_0 65_492_split_1 -23330=8,3,20,20,24,3,20,20,24
Convolution 66_496 1 1 65_492_split_0 66_496_bn_leaky -23330=4,3,20,20,136 0=136 1=1 5=1 6=3264 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 67_504 1 1 66_496_bn_leaky 67_504_bn_leaky -23330=4,3,20,20,136 0=136 1=3 4=1 5=1 6=1224 7=136 9=2 -23310=1,1.000000e-01
Convolution 68_513 1 1 67_504_bn_leaky 68_513_bn -23330=4,3,20,20,24 0=24 1=1 5=1 6=3264
Eltwise 70_526 2 1 68_513_bn 65_492_split_1 70_526 -23330=4,3,20,20,24 0=1
Split 70_526_split 1 2 70_526 70_526_split_0 70_526_split_1 -23330=8,3,20,20,24,3,20,20,24
Convolution 71_530 1 1 70_526_split_0 71_530_bn_leaky -23330=4,3,20,20,136 0=136 1=1 5=1 6=3264 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 72_538 1 1 71_530_bn_leaky 72_538_bn_leaky -23330=4,3,20,20,136 0=136 1=3 4=1 5=1 6=1224 7=136 9=2 -23310=1,1.000000e-01
Convolution 73_547 1 1 72_538_bn_leaky 73_547_bn -23330=4,3,20,20,24 0=24 1=1 5=1 6=3264
Eltwise 75_559 2 1 73_547_bn 70_526_split_1 75_559 -23330=4,3,20,20,24 0=1
Split 75_559_split 1 2 75_559 75_559_split_0 75_559_split_1 -23330=8,3,20,20,24,3,20,20,24
Convolution 76_563 1 1 75_559_split_0 76_563_bn_leaky -23330=4,3,20,20,136 0=136 1=1 5=1 6=3264 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 77_571 1 1 76_563_bn_leaky 77_571_bn_leaky -23330=4,3,20,20,136 0=136 1=3 4=1 5=1 6=1224 7=136 9=2 -23310=1,1.000000e-01
Convolution 78_580 1 1 77_571_bn_leaky 78_580_bn -23330=4,3,20,20,24 0=24 1=1 5=1 6=3264
Eltwise 80_593 2 1 78_580_bn 75_559_split_1 80_593 -23330=4,3,20,20,24 0=1
Convolution 81_597 1 1 80_593 81_597_bn_leaky -23330=4,3,20,20,136 0=136 1=1 5=1 6=3264 9=2 -23310=1,1.000000e-01
Split 81_597_bn_leaky_split 1 2 81_597_bn_leaky 81_597_bn_leaky_split_0 81_597_bn_leaky_split_1 -23330=8,3,20,20,136,3,20,20,136
ConvolutionDepthWise 82_605 1 1 81_597_bn_leaky_split_0 82_605_bn_leaky -23330=4,3,10,10,136 0=136 1=3 3=2 4=1 5=1 6=1224 7=136 9=2 -23310=1,1.000000e-01
Convolution 83_615 1 1 82_605_bn_leaky 83_615_bn -23330=4,3,10,10,48 0=48 1=1 5=1 6=6528
Split 83_615_bn_split 1 2 83_615_bn 83_615_bn_split_0 83_615_bn_split_1 -23330=8,3,10,10,48,3,10,10,48
Convolution 84_624 1 1 83_615_bn_split_0 84_624_bn_leaky -23330=4,3,10,10,224 0=224 1=1 5=1 6=10752 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 85_632 1 1 84_624_bn_leaky 85_632_bn_leaky -23330=4,3,10,10,224 0=224 1=3 4=1 5=1 6=2016 7=224 9=2 -23310=1,1.000000e-01
Convolution 86_641 1 1 85_632_bn_leaky 86_641_bn -23330=4,3,10,10,48 0=48 1=1 5=1 6=10752
Eltwise 88_653 2 1 86_641_bn 83_615_bn_split_1 88_653 -23330=4,3,10,10,48 0=1
Split 88_653_split 1 2 88_653 88_653_split_0 88_653_split_1 -23330=8,3,10,10,48,3,10,10,48
Convolution 89_657 1 1 88_653_split_0 89_657_bn_leaky -23330=4,3,10,10,224 0=224 1=1 5=1 6=10752 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 90_665 1 1 89_657_bn_leaky 90_665_bn_leaky -23330=4,3,10,10,224 0=224 1=3 4=1 5=1 6=2016 7=224 9=2 -23310=1,1.000000e-01
Convolution 91_674 1 1 90_665_bn_leaky 91_674_bn -23330=4,3,10,10,48 0=48 1=1 5=1 6=10752
Eltwise 93_686 2 1 91_674_bn 88_653_split_1 93_686 -23330=4,3,10,10,48 0=1
Split 93_686_split 1 2 93_686 93_686_split_0 93_686_split_1 -23330=8,3,10,10,48,3,10,10,48
Convolution 94_690 1 1 93_686_split_0 94_690_bn_leaky -23330=4,3,10,10,224 0=224 1=1 5=1 6=10752 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 95_698 1 1 94_690_bn_leaky 95_698_bn_leaky -23330=4,3,10,10,224 0=224 1=3 4=1 5=1 6=2016 7=224 9=2 -23310=1,1.000000e-01
Convolution 96_707 1 1 95_698_bn_leaky 96_707_bn -23330=4,3,10,10,48 0=48 1=1 5=1 6=10752
Eltwise 98_719 2 1 96_707_bn 93_686_split_1 98_719 -23330=4,3,10,10,48 0=1
Split 98_719_split 1 2 98_719 98_719_split_0 98_719_split_1 -23330=8,3,10,10,48,3,10,10,48
Convolution 99_723 1 1 98_719_split_0 99_723_bn_leaky -23330=4,3,10,10,224 0=224 1=1 5=1 6=10752 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 100_731 1 1 99_723_bn_leaky 100_731_bn_leaky -23330=4,3,10,10,224 0=224 1=3 4=1 5=1 6=2016 7=224 9=2 -23310=1,1.000000e-01
Convolution 101_740 1 1 100_731_bn_leaky 101_740_bn -23330=4,3,10,10,48 0=48 1=1 5=1 6=10752
Eltwise 103_752 2 1 101_740_bn 98_719_split_1 103_752 -23330=4,3,10,10,48 0=1
Split 103_752_split 1 2 103_752 103_752_split_0 103_752_split_1 -23330=8,3,10,10,48,3,10,10,48
Convolution 104_756 1 1 103_752_split_0 104_756_bn_leaky -23330=4,3,10,10,224 0=224 1=1 5=1 6=10752 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 105_764 1 1 104_756_bn_leaky 105_764_bn_leaky -23330=4,3,10,10,224 0=224 1=3 4=1 5=1 6=2016 7=224 9=2 -23310=1,1.000000e-01
Convolution 106_773 1 1 105_764_bn_leaky 106_773_bn -23330=4,3,10,10,48 0=48 1=1 5=1 6=10752
Eltwise 108_784 2 1 106_773_bn 103_752_split_1 108_784 -23330=4,3,10,10,48 0=1
Convolution 109_788 1 1 108_784 109_788_bn_leaky -23330=4,3,10,10,96 0=96 1=1 5=1 6=4608 9=2 -23310=1,1.000000e-01
Split 109_788_bn_leaky_split 1 2 109_788_bn_leaky 109_788_bn_leaky_split_0 109_788_bn_leaky_split_1 -23330=8,3,10,10,96,3,10,10,96
ConvolutionDepthWise 110_796 1 1 109_788_bn_leaky_split_0 110_796_bn_leaky -23330=4,3,10,10,96 0=96 1=5 4=2 5=1 6=2400 7=96 9=2 -23310=1,1.000000e-01
Convolution 111_805 1 1 110_796_bn_leaky 111_805_bn -23330=4,3,10,10,128 0=128 1=1 5=1 6=12288
ConvolutionDepthWise 112_813 1 1 111_805_bn 112_813_bn_leaky -23330=4,3,10,10,128 0=128 1=5 4=2 5=1 6=3200 7=128 9=2 -23310=1,1.000000e-01
Convolution 113_822 1 1 112_813_bn_leaky 113_822_bn -23330=4,3,10,10,128 0=128 1=1 5=1 6=16384
Convolution 114_830 1 1 113_822_bn 114_830 -23330=4,3,10,10,255 0=255 1=1 5=1 6=32640
Interp 117_858 1 1 109_788_bn_leaky_split_1 117_858 -23330=4,3,20,20,96 0=1 1=2.000000e+00 2=2.000000e+00
Concat 118_861 2 1 117_858 81_597_bn_leaky_split_1 118_861 -23330=4,3,20,20,232
Convolution 119_864 1 1 118_861 119_864_bn_leaky -23330=4,3,20,20,96 0=96 1=1 5=1 6=22272 9=2 -23310=1,1.000000e-01
ConvolutionDepthWise 120_872 1 1 119_864_bn_leaky 120_872_bn_leaky -23330=4,3,20,20,96 0=96 1=5 4=2 5=1 6=2400 7=96 9=2 -23310=1,1.000000e-01
Convolution 121_881 1 1 120_872_bn_leaky 121_881_bn -23330=4,3,20,20,96 0=96 1=1 5=1 6=9216
ConvolutionDepthWise 122_889 1 1 121_881_bn 122_889_bn_leaky -23330=4,3,20,20,96 0=96 1=5 4=2 5=1 6=2400 7=96 9=2 -23310=1,1.000000e-01
Convolution 123_898 1 1 122_889_bn_leaky 123_898_bn -23330=4,3,20,20,96 0=96 1=1 5=1 6=9216
Convolution 124_906 1 1 123_898_bn 124_906 -23330=4,3,20,20,255 0=255 1=1 5=1 6=24480
Yolov3DetectionOutput detection_out 2 1 114_830 124_906 output -23330=4,2,6,262,1 0=80 1=3 2=2.500000e-01 -23304=12,1.200000e+01,1.800000e+01,3.700000e+01,4.900000e+01,5.200000e+01,1.320000e+02,1.150000e+02,7.300000e+01,1.190000e+02,1.990000e+02,2.420000e+02,2.380000e+02 -23305=6,1077936128,1082130432,1084227584,0,1065353216,1073741824 -23306=2,3.200000e+01,1.600000e+01

@ -0,0 +1,267 @@
7767517
265 285
Input data 0 1 data 0=320 1=320 2=3
Convolution 0_22 1 1 data 0_22 0=16 1=3 2=1 3=2 4=1 5=0 6=432
BatchNorm 0_22_bn 1 1 0_22 0_22_bn 0=16 1=.00001
ReLU 0_22_bn_leaky 1 1 0_22_bn 0_22_bn_leaky 0=0.1
Convolution 1_31 1 1 0_22_bn_leaky 1_31 0=16 1=1 2=1 3=1 4=0 5=0 6=256
BatchNorm 1_31_bn 1 1 1_31 1_31_bn 0=16 1=.00001
ReLU 1_31_bn_leaky 1 1 1_31_bn 1_31_bn_leaky 0=0.1
ConvolutionDepthWise 2_39 1 1 1_31_bn_leaky 2_39 0=16 1=3 2=1 3=1 4=1 5=0 6=144 7=16
BatchNorm 2_39_bn 1 1 2_39 2_39_bn 0=16 1=.00001
ReLU 2_39_bn_leaky 1 1 2_39_bn 2_39_bn_leaky 0=0.1
Convolution 3_48 1 1 2_39_bn_leaky 3_48 0=8 1=1 2=1 3=1 4=0 5=0 6=128
BatchNorm 3_48_bn 1 1 3_48 3_48_bn 0=8 1=.00001
Split 3_48_bn_split 1 2 3_48_bn 3_48_bn_split_0 3_48_bn_split_1
Convolution 4_57 1 1 3_48_bn_split_0 4_57 0=16 1=1 2=1 3=1 4=0 5=0 6=128
BatchNorm 4_57_bn 1 1 4_57 4_57_bn 0=16 1=.00001
ReLU 4_57_bn_leaky 1 1 4_57_bn 4_57_bn_leaky 0=0.1
ConvolutionDepthWise 5_65 1 1 4_57_bn_leaky 5_65 0=16 1=3 2=1 3=1 4=1 5=0 6=144 7=16
BatchNorm 5_65_bn 1 1 5_65 5_65_bn 0=16 1=.00001
ReLU 5_65_bn_leaky 1 1 5_65_bn 5_65_bn_leaky 0=0.1
Convolution 6_74 1 1 5_65_bn_leaky 6_74 0=8 1=1 2=1 3=1 4=0 5=0 6=128
BatchNorm 6_74_bn 1 1 6_74 6_74_bn 0=8 1=.00001
Eltwise 8_86 2 1 6_74_bn 3_48_bn_split_1 8_86 0=1
Convolution 9_90 1 1 8_86 9_90 0=48 1=1 2=1 3=1 4=0 5=0 6=384
BatchNorm 9_90_bn 1 1 9_90 9_90_bn 0=48 1=.00001
ReLU 9_90_bn_leaky 1 1 9_90_bn 9_90_bn_leaky 0=0.1
ConvolutionDepthWise 10_98 1 1 9_90_bn_leaky 10_98 0=48 1=3 2=1 3=2 4=1 5=0 6=432 7=48
BatchNorm 10_98_bn 1 1 10_98 10_98_bn 0=48 1=.00001
ReLU 10_98_bn_leaky 1 1 10_98_bn 10_98_bn_leaky 0=0.1
Convolution 11_107 1 1 10_98_bn_leaky 11_107 0=16 1=1 2=1 3=1 4=0 5=0 6=768
BatchNorm 11_107_bn 1 1 11_107 11_107_bn 0=16 1=.00001
Split 11_107_bn_split 1 2 11_107_bn 11_107_bn_split_0 11_107_bn_split_1
Convolution 12_116 1 1 11_107_bn_split_0 12_116 0=64 1=1 2=1 3=1 4=0 5=0 6=1024
BatchNorm 12_116_bn 1 1 12_116 12_116_bn 0=64 1=.00001
ReLU 12_116_bn_leaky 1 1 12_116_bn 12_116_bn_leaky 0=0.1
ConvolutionDepthWise 13_124 1 1 12_116_bn_leaky 13_124 0=64 1=3 2=1 3=1 4=1 5=0 6=576 7=64
BatchNorm 13_124_bn 1 1 13_124 13_124_bn 0=64 1=.00001
ReLU 13_124_bn_leaky 1 1 13_124_bn 13_124_bn_leaky 0=0.1
Convolution 14_133 1 1 13_124_bn_leaky 14_133 0=16 1=1 2=1 3=1 4=0 5=0 6=1024
BatchNorm 14_133_bn 1 1 14_133 14_133_bn 0=16 1=.00001
Eltwise 16_145 2 1 14_133_bn 11_107_bn_split_1 16_145 0=1
Split 16_145_split 1 2 16_145 16_145_split_0 16_145_split_1
Convolution 17_149 1 1 16_145_split_0 17_149 0=64 1=1 2=1 3=1 4=0 5=0 6=1024
BatchNorm 17_149_bn 1 1 17_149 17_149_bn 0=64 1=.00001
ReLU 17_149_bn_leaky 1 1 17_149_bn 17_149_bn_leaky 0=0.1
ConvolutionDepthWise 18_157 1 1 17_149_bn_leaky 18_157 0=64 1=3 2=1 3=1 4=1 5=0 6=576 7=64
BatchNorm 18_157_bn 1 1 18_157 18_157_bn 0=64 1=.00001
ReLU 18_157_bn_leaky 1 1 18_157_bn 18_157_bn_leaky 0=0.1
Convolution 19_166 1 1 18_157_bn_leaky 19_166 0=16 1=1 2=1 3=1 4=0 5=0 6=1024
BatchNorm 19_166_bn 1 1 19_166 19_166_bn 0=16 1=.00001
Eltwise 21_179 2 1 19_166_bn 16_145_split_1 21_179 0=1
Convolution 22_183 1 1 21_179 22_183 0=64 1=1 2=1 3=1 4=0 5=0 6=1024
BatchNorm 22_183_bn 1 1 22_183 22_183_bn 0=64 1=.00001
ReLU 22_183_bn_leaky 1 1 22_183_bn 22_183_bn_leaky 0=0.1
ConvolutionDepthWise 23_191 1 1 22_183_bn_leaky 23_191 0=64 1=3 2=1 3=2 4=1 5=0 6=576 7=64
BatchNorm 23_191_bn 1 1 23_191 23_191_bn 0=64 1=.00001
ReLU 23_191_bn_leaky 1 1 23_191_bn 23_191_bn_leaky 0=0.1
Convolution 24_200 1 1 23_191_bn_leaky 24_200 0=16 1=1 2=1 3=1 4=0 5=0 6=1024
BatchNorm 24_200_bn 1 1 24_200 24_200_bn 0=16 1=.00001
Split 24_200_bn_split 1 2 24_200_bn 24_200_bn_split_0 24_200_bn_split_1
Convolution 25_209 1 1 24_200_bn_split_0 25_209 0=96 1=1 2=1 3=1 4=0 5=0 6=1536
BatchNorm 25_209_bn 1 1 25_209 25_209_bn 0=96 1=.00001
ReLU 25_209_bn_leaky 1 1 25_209_bn 25_209_bn_leaky 0=0.1
ConvolutionDepthWise 26_217 1 1 25_209_bn_leaky 26_217 0=96 1=3 2=1 3=1 4=1 5=0 6=864 7=96
BatchNorm 26_217_bn 1 1 26_217 26_217_bn 0=96 1=.00001
ReLU 26_217_bn_leaky 1 1 26_217_bn 26_217_bn_leaky 0=0.1
Convolution 27_226 1 1 26_217_bn_leaky 27_226 0=16 1=1 2=1 3=1 4=0 5=0 6=1536
BatchNorm 27_226_bn 1 1 27_226 27_226_bn 0=16 1=.00001
Eltwise 29_238 2 1 27_226_bn 24_200_bn_split_1 29_238 0=1
Split 29_238_split 1 2 29_238 29_238_split_0 29_238_split_1
Convolution 30_242 1 1 29_238_split_0 30_242 0=96 1=1 2=1 3=1 4=0 5=0 6=1536
BatchNorm 30_242_bn 1 1 30_242 30_242_bn 0=96 1=.00001
ReLU 30_242_bn_leaky 1 1 30_242_bn 30_242_bn_leaky 0=0.1
ConvolutionDepthWise 31_250 1 1 30_242_bn_leaky 31_250 0=96 1=3 2=1 3=1 4=1 5=0 6=864 7=96
BatchNorm 31_250_bn 1 1 31_250 31_250_bn 0=96 1=.00001
ReLU 31_250_bn_leaky 1 1 31_250_bn 31_250_bn_leaky 0=0.1
Convolution 32_259 1 1 31_250_bn_leaky 32_259 0=16 1=1 2=1 3=1 4=0 5=0 6=1536
BatchNorm 32_259_bn 1 1 32_259 32_259_bn 0=16 1=.00001
Eltwise 34_273 2 1 32_259_bn 29_238_split_1 34_273 0=1
Convolution 35_277 1 1 34_273 35_277 0=96 1=1 2=1 3=1 4=0 5=0 6=1536
BatchNorm 35_277_bn 1 1 35_277 35_277_bn 0=96 1=.00001
ReLU 35_277_bn_leaky 1 1 35_277_bn 35_277_bn_leaky 0=0.1
ConvolutionDepthWise 36_285 1 1 35_277_bn_leaky 36_285 0=96 1=3 2=1 3=1 4=1 5=0 6=864 7=96
BatchNorm 36_285_bn 1 1 36_285 36_285_bn 0=96 1=.00001
ReLU 36_285_bn_leaky 1 1 36_285_bn 36_285_bn_leaky 0=0.1
Convolution 37_294 1 1 36_285_bn_leaky 37_294 0=32 1=1 2=1 3=1 4=0 5=0 6=3072
BatchNorm 37_294_bn 1 1 37_294 37_294_bn 0=32 1=.00001
Split 37_294_bn_split 1 2 37_294_bn 37_294_bn_split_0 37_294_bn_split_1
Convolution 38_303 1 1 37_294_bn_split_0 38_303 0=192 1=1 2=1 3=1 4=0 5=0 6=6144
BatchNorm 38_303_bn 1 1 38_303 38_303_bn 0=192 1=.00001
ReLU 38_303_bn_leaky 1 1 38_303_bn 38_303_bn_leaky 0=0.1
ConvolutionDepthWise 39_311 1 1 38_303_bn_leaky 39_311 0=192 1=3 2=1 3=1 4=1 5=0 6=1728 7=192
BatchNorm 39_311_bn 1 1 39_311 39_311_bn 0=192 1=.00001
ReLU 39_311_bn_leaky 1 1 39_311_bn 39_311_bn_leaky 0=0.1
Convolution 40_320 1 1 39_311_bn_leaky 40_320 0=32 1=1 2=1 3=1 4=0 5=0 6=6144
BatchNorm 40_320_bn 1 1 40_320 40_320_bn 0=32 1=.00001
Eltwise 42_332 2 1 40_320_bn 37_294_bn_split_1 42_332 0=1
Split 42_332_split 1 2 42_332 42_332_split_0 42_332_split_1
Convolution 43_336 1 1 42_332_split_0 43_336 0=192 1=1 2=1 3=1 4=0 5=0 6=6144
BatchNorm 43_336_bn 1 1 43_336 43_336_bn 0=192 1=.00001
ReLU 43_336_bn_leaky 1 1 43_336_bn 43_336_bn_leaky 0=0.1
ConvolutionDepthWise 44_344 1 1 43_336_bn_leaky 44_344 0=192 1=3 2=1 3=1 4=1 5=0 6=1728 7=192
BatchNorm 44_344_bn 1 1 44_344 44_344_bn 0=192 1=.00001
ReLU 44_344_bn_leaky 1 1 44_344_bn 44_344_bn_leaky 0=0.1
Convolution 45_353 1 1 44_344_bn_leaky 45_353 0=32 1=1 2=1 3=1 4=0 5=0 6=6144
BatchNorm 45_353_bn 1 1 45_353 45_353_bn 0=32 1=.00001
Eltwise 47_365 2 1 45_353_bn 42_332_split_1 47_365 0=1
Split 47_365_split 1 2 47_365 47_365_split_0 47_365_split_1
Convolution 48_369 1 1 47_365_split_0 48_369 0=192 1=1 2=1 3=1 4=0 5=0 6=6144
BatchNorm 48_369_bn 1 1 48_369 48_369_bn 0=192 1=.00001
ReLU 48_369_bn_leaky 1 1 48_369_bn 48_369_bn_leaky 0=0.1
ConvolutionDepthWise 49_377 1 1 48_369_bn_leaky 49_377 0=192 1=3 2=1 3=1 4=1 5=0 6=1728 7=192
BatchNorm 49_377_bn 1 1 49_377 49_377_bn 0=192 1=.00001
ReLU 49_377_bn_leaky 1 1 49_377_bn 49_377_bn_leaky 0=0.1
Convolution 50_386 1 1 49_377_bn_leaky 50_386 0=32 1=1 2=1 3=1 4=0 5=0 6=6144
BatchNorm 50_386_bn 1 1 50_386 50_386_bn 0=32 1=.00001
Eltwise 52_399 2 1 50_386_bn 47_365_split_1 52_399 0=1
Split 52_399_split 1 2 52_399 52_399_split_0 52_399_split_1
Convolution 53_403 1 1 52_399_split_0 53_403 0=192 1=1 2=1 3=1 4=0 5=0 6=6144
BatchNorm 53_403_bn 1 1 53_403 53_403_bn 0=192 1=.00001
ReLU 53_403_bn_leaky 1 1 53_403_bn 53_403_bn_leaky 0=0.1
ConvolutionDepthWise 54_411 1 1 53_403_bn_leaky 54_411 0=192 1=3 2=1 3=1 4=1 5=0 6=1728 7=192
BatchNorm 54_411_bn 1 1 54_411 54_411_bn 0=192 1=.00001
ReLU 54_411_bn_leaky 1 1 54_411_bn 54_411_bn_leaky 0=0.1
Convolution 55_420 1 1 54_411_bn_leaky 55_420 0=32 1=1 2=1 3=1 4=0 5=0 6=6144
BatchNorm 55_420_bn 1 1 55_420 55_420_bn 0=32 1=.00001
Eltwise 57_433 2 1 55_420_bn 52_399_split_1 57_433 0=1
Convolution 58_437 1 1 57_433 58_437 0=192 1=1 2=1 3=1 4=0 5=0 6=6144
BatchNorm 58_437_bn 1 1 58_437 58_437_bn 0=192 1=.00001
ReLU 58_437_bn_leaky 1 1 58_437_bn 58_437_bn_leaky 0=0.1
ConvolutionDepthWise 59_445 1 1 58_437_bn_leaky 59_445 0=192 1=3 2=1 3=2 4=1 5=0 6=1728 7=192
BatchNorm 59_445_bn 1 1 59_445 59_445_bn 0=192 1=.00001
ReLU 59_445_bn_leaky 1 1 59_445_bn 59_445_bn_leaky 0=0.1
Convolution 60_454 1 1 59_445_bn_leaky 60_454 0=48 1=1 2=1 3=1 4=0 5=0 6=9216
BatchNorm 60_454_bn 1 1 60_454 60_454_bn 0=48 1=.00001
Split 60_454_bn_split 1 2 60_454_bn 60_454_bn_split_0 60_454_bn_split_1
Convolution 61_463 1 1 60_454_bn_split_0 61_463 0=272 1=1 2=1 3=1 4=0 5=0 6=13056
BatchNorm 61_463_bn 1 1 61_463 61_463_bn 0=272 1=.00001
ReLU 61_463_bn_leaky 1 1 61_463_bn 61_463_bn_leaky 0=0.1
ConvolutionDepthWise 62_471 1 1 61_463_bn_leaky 62_471 0=272 1=3 2=1 3=1 4=1 5=0 6=2448 7=272
BatchNorm 62_471_bn 1 1 62_471 62_471_bn 0=272 1=.00001
ReLU 62_471_bn_leaky 1 1 62_471_bn 62_471_bn_leaky 0=0.1
Convolution 63_480 1 1 62_471_bn_leaky 63_480 0=48 1=1 2=1 3=1 4=0 5=0 6=13056
BatchNorm 63_480_bn 1 1 63_480 63_480_bn 0=48 1=.00001
Eltwise 65_492 2 1 63_480_bn 60_454_bn_split_1 65_492 0=1
Split 65_492_split 1 2 65_492 65_492_split_0 65_492_split_1
Convolution 66_496 1 1 65_492_split_0 66_496 0=272 1=1 2=1 3=1 4=0 5=0 6=13056
BatchNorm 66_496_bn 1 1 66_496 66_496_bn 0=272 1=.00001
ReLU 66_496_bn_leaky 1 1 66_496_bn 66_496_bn_leaky 0=0.1
ConvolutionDepthWise 67_504 1 1 66_496_bn_leaky 67_504 0=272 1=3 2=1 3=1 4=1 5=0 6=2448 7=272
BatchNorm 67_504_bn 1 1 67_504 67_504_bn 0=272 1=.00001
ReLU 67_504_bn_leaky 1 1 67_504_bn 67_504_bn_leaky 0=0.1
Convolution 68_513 1 1 67_504_bn_leaky 68_513 0=48 1=1 2=1 3=1 4=0 5=0 6=13056
BatchNorm 68_513_bn 1 1 68_513 68_513_bn 0=48 1=.00001
Eltwise 70_526 2 1 68_513_bn 65_492_split_1 70_526 0=1
Split 70_526_split 1 2 70_526 70_526_split_0 70_526_split_1
Convolution 71_530 1 1 70_526_split_0 71_530 0=272 1=1 2=1 3=1 4=0 5=0 6=13056
BatchNorm 71_530_bn 1 1 71_530 71_530_bn 0=272 1=.00001
ReLU 71_530_bn_leaky 1 1 71_530_bn 71_530_bn_leaky 0=0.1
ConvolutionDepthWise 72_538 1 1 71_530_bn_leaky 72_538 0=272 1=3 2=1 3=1 4=1 5=0 6=2448 7=272
BatchNorm 72_538_bn 1 1 72_538 72_538_bn 0=272 1=.00001
ReLU 72_538_bn_leaky 1 1 72_538_bn 72_538_bn_leaky 0=0.1
Convolution 73_547 1 1 72_538_bn_leaky 73_547 0=48 1=1 2=1 3=1 4=0 5=0 6=13056
BatchNorm 73_547_bn 1 1 73_547 73_547_bn 0=48 1=.00001
Eltwise 75_559 2 1 73_547_bn 70_526_split_1 75_559 0=1
Split 75_559_split 1 2 75_559 75_559_split_0 75_559_split_1
Convolution 76_563 1 1 75_559_split_0 76_563 0=272 1=1 2=1 3=1 4=0 5=0 6=13056
BatchNorm 76_563_bn 1 1 76_563 76_563_bn 0=272 1=.00001
ReLU 76_563_bn_leaky 1 1 76_563_bn 76_563_bn_leaky 0=0.1
ConvolutionDepthWise 77_571 1 1 76_563_bn_leaky 77_571 0=272 1=3 2=1 3=1 4=1 5=0 6=2448 7=272
BatchNorm 77_571_bn 1 1 77_571 77_571_bn 0=272 1=.00001
ReLU 77_571_bn_leaky 1 1 77_571_bn 77_571_bn_leaky 0=0.1
Convolution 78_580 1 1 77_571_bn_leaky 78_580 0=48 1=1 2=1 3=1 4=0 5=0 6=13056
BatchNorm 78_580_bn 1 1 78_580 78_580_bn 0=48 1=.00001
Eltwise 80_593 2 1 78_580_bn 75_559_split_1 80_593 0=1
Convolution 81_597 1 1 80_593 81_597 0=272 1=1 2=1 3=1 4=0 5=0 6=13056
BatchNorm 81_597_bn 1 1 81_597 81_597_bn 0=272 1=.00001
ReLU 81_597_bn_leaky 1 1 81_597_bn 81_597_bn_leaky 0=0.1
Split 81_597_bn_leaky_split 1 2 81_597_bn_leaky 81_597_bn_leaky_split_0 81_597_bn_leaky_split_1
ConvolutionDepthWise 82_605 1 1 81_597_bn_leaky_split_0 82_605 0=272 1=3 2=1 3=2 4=1 5=0 6=2448 7=272
BatchNorm 82_605_bn 1 1 82_605 82_605_bn 0=272 1=.00001
ReLU 82_605_bn_leaky 1 1 82_605_bn 82_605_bn_leaky 0=0.1
Convolution 83_615 1 1 82_605_bn_leaky 83_615 0=96 1=1 2=1 3=1 4=0 5=0 6=26112
BatchNorm 83_615_bn 1 1 83_615 83_615_bn 0=96 1=.00001
Split 83_615_bn_split 1 2 83_615_bn 83_615_bn_split_0 83_615_bn_split_1
Convolution 84_624 1 1 83_615_bn_split_0 84_624 0=448 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 84_624_bn 1 1 84_624 84_624_bn 0=448 1=.00001
ReLU 84_624_bn_leaky 1 1 84_624_bn 84_624_bn_leaky 0=0.1
ConvolutionDepthWise 85_632 1 1 84_624_bn_leaky 85_632 0=448 1=3 2=1 3=1 4=1 5=0 6=4032 7=448
BatchNorm 85_632_bn 1 1 85_632 85_632_bn 0=448 1=.00001
ReLU 85_632_bn_leaky 1 1 85_632_bn 85_632_bn_leaky 0=0.1
Convolution 86_641 1 1 85_632_bn_leaky 86_641 0=96 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 86_641_bn 1 1 86_641 86_641_bn 0=96 1=.00001
Eltwise 88_653 2 1 86_641_bn 83_615_bn_split_1 88_653 0=1
Split 88_653_split 1 2 88_653 88_653_split_0 88_653_split_1
Convolution 89_657 1 1 88_653_split_0 89_657 0=448 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 89_657_bn 1 1 89_657 89_657_bn 0=448 1=.00001
ReLU 89_657_bn_leaky 1 1 89_657_bn 89_657_bn_leaky 0=0.1
ConvolutionDepthWise 90_665 1 1 89_657_bn_leaky 90_665 0=448 1=3 2=1 3=1 4=1 5=0 6=4032 7=448
BatchNorm 90_665_bn 1 1 90_665 90_665_bn 0=448 1=.00001
ReLU 90_665_bn_leaky 1 1 90_665_bn 90_665_bn_leaky 0=0.1
Convolution 91_674 1 1 90_665_bn_leaky 91_674 0=96 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 91_674_bn 1 1 91_674 91_674_bn 0=96 1=.00001
Eltwise 93_686 2 1 91_674_bn 88_653_split_1 93_686 0=1
Split 93_686_split 1 2 93_686 93_686_split_0 93_686_split_1
Convolution 94_690 1 1 93_686_split_0 94_690 0=448 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 94_690_bn 1 1 94_690 94_690_bn 0=448 1=.00001
ReLU 94_690_bn_leaky 1 1 94_690_bn 94_690_bn_leaky 0=0.1
ConvolutionDepthWise 95_698 1 1 94_690_bn_leaky 95_698 0=448 1=3 2=1 3=1 4=1 5=0 6=4032 7=448
BatchNorm 95_698_bn 1 1 95_698 95_698_bn 0=448 1=.00001
ReLU 95_698_bn_leaky 1 1 95_698_bn 95_698_bn_leaky 0=0.1
Convolution 96_707 1 1 95_698_bn_leaky 96_707 0=96 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 96_707_bn 1 1 96_707 96_707_bn 0=96 1=.00001
Eltwise 98_719 2 1 96_707_bn 93_686_split_1 98_719 0=1
Split 98_719_split 1 2 98_719 98_719_split_0 98_719_split_1
Convolution 99_723 1 1 98_719_split_0 99_723 0=448 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 99_723_bn 1 1 99_723 99_723_bn 0=448 1=.00001
ReLU 99_723_bn_leaky 1 1 99_723_bn 99_723_bn_leaky 0=0.1
ConvolutionDepthWise 100_731 1 1 99_723_bn_leaky 100_731 0=448 1=3 2=1 3=1 4=1 5=0 6=4032 7=448
BatchNorm 100_731_bn 1 1 100_731 100_731_bn 0=448 1=.00001
ReLU 100_731_bn_leaky 1 1 100_731_bn 100_731_bn_leaky 0=0.1
Convolution 101_740 1 1 100_731_bn_leaky 101_740 0=96 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 101_740_bn 1 1 101_740 101_740_bn 0=96 1=.00001
Eltwise 103_752 2 1 101_740_bn 98_719_split_1 103_752 0=1
Split 103_752_split 1 2 103_752 103_752_split_0 103_752_split_1
Convolution 104_756 1 1 103_752_split_0 104_756 0=448 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 104_756_bn 1 1 104_756 104_756_bn 0=448 1=.00001
ReLU 104_756_bn_leaky 1 1 104_756_bn 104_756_bn_leaky 0=0.1
ConvolutionDepthWise 105_764 1 1 104_756_bn_leaky 105_764 0=448 1=3 2=1 3=1 4=1 5=0 6=4032 7=448
BatchNorm 105_764_bn 1 1 105_764 105_764_bn 0=448 1=.00001
ReLU 105_764_bn_leaky 1 1 105_764_bn 105_764_bn_leaky 0=0.1
Convolution 106_773 1 1 105_764_bn_leaky 106_773 0=96 1=1 2=1 3=1 4=0 5=0 6=43008
BatchNorm 106_773_bn 1 1 106_773 106_773_bn 0=96 1=.00001
Eltwise 108_784 2 1 106_773_bn 103_752_split_1 108_784 0=1
Convolution 109_788 1 1 108_784 109_788 0=96 1=1 2=1 3=1 4=0 5=0 6=9216
BatchNorm 109_788_bn 1 1 109_788 109_788_bn 0=96 1=.00001
ReLU 109_788_bn_leaky 1 1 109_788_bn 109_788_bn_leaky 0=0.1
Split 109_788_bn_leaky_split 1 2 109_788_bn_leaky 109_788_bn_leaky_split_0 109_788_bn_leaky_split_1
ConvolutionDepthWise 110_798 1 1 109_788_bn_leaky_split_0 110_798 0=96 1=5 2=1 3=1 4=2 5=0 6=2400 7=96
BatchNorm 110_798_bn 1 1 110_798 110_798_bn 0=96 1=.00001
ReLU 110_798_bn_leaky 1 1 110_798_bn 110_798_bn_leaky 0=0.1
Convolution 111_807 1 1 110_798_bn_leaky 111_807 0=128 1=1 2=1 3=1 4=0 5=0 6=12288
BatchNorm 111_807_bn 1 1 111_807 111_807_bn 0=128 1=.00001
ConvolutionDepthWise 112_815 1 1 111_807_bn 112_815 0=128 1=5 2=1 3=1 4=2 5=0 6=3200 7=128
BatchNorm 112_815_bn 1 1 112_815 112_815_bn 0=128 1=.00001
ReLU 112_815_bn_leaky 1 1 112_815_bn 112_815_bn_leaky 0=0.1
Convolution 113_824 1 1 112_815_bn_leaky 113_824 0=128 1=1 2=1 3=1 4=0 5=0 6=16384
BatchNorm 113_824_bn 1 1 113_824 113_824_bn 0=128 1=.00001
Convolution 114_832 1 1 113_824_bn 114_832 0=255 1=1 2=1 3=1 4=0 5=1 6=32640
Interp 117_862 1 1 109_788_bn_leaky_split_1 117_862 0=1 1=2.f 2=2.f
Concat 118_865 2 1 117_862 81_597_bn_leaky_split_1 118_865
Convolution 119_868 1 1 118_865 119_868 0=96 1=1 2=1 3=1 4=0 5=0 6=35328
BatchNorm 119_868_bn 1 1 119_868 119_868_bn 0=96 1=.00001
ReLU 119_868_bn_leaky 1 1 119_868_bn 119_868_bn_leaky 0=0.1
ConvolutionDepthWise 120_876 1 1 119_868_bn_leaky 120_876 0=96 1=5 2=1 3=1 4=2 5=0 6=2400 7=96
BatchNorm 120_876_bn 1 1 120_876 120_876_bn 0=96 1=.00001
ReLU 120_876_bn_leaky 1 1 120_876_bn 120_876_bn_leaky 0=0.1
Convolution 121_885 1 1 120_876_bn_leaky 121_885 0=96 1=1 2=1 3=1 4=0 5=0 6=9216
BatchNorm 121_885_bn 1 1 121_885 121_885_bn 0=96 1=.00001
ConvolutionDepthWise 122_893 1 1 121_885_bn 122_893 0=96 1=5 2=1 3=1 4=2 5=0 6=2400 7=96
BatchNorm 122_893_bn 1 1 122_893 122_893_bn 0=96 1=.00001
ReLU 122_893_bn_leaky 1 1 122_893_bn 122_893_bn_leaky 0=0.1
Convolution 123_902 1 1 122_893_bn_leaky 123_902 0=96 1=1 2=1 3=1 4=0 5=0 6=9216
BatchNorm 123_902_bn 1 1 123_902 123_902_bn 0=96 1=.00001
Convolution 124_910 1 1 123_902_bn 124_910 0=255 1=1 2=1 3=1 4=0 5=1 6=24480
Yolov3DetectionOutput detection_out 2 1 114_832 124_910 output 0=80 1=3 2=0.250000 -23304=12,12.000000,18.000000,37.000000,49.000000,52.000000,132.000000,115.000000,73.000000,119.000000,199.000000,242.000000,238.000000 -23305=6,3.000000,4.000000,5.000000,0.000000,1.000000,2.000000 -23306=2,32.000000,16.000000

@ -0,0 +1,96 @@
7767517
94 109
Input data 0 1 data -23330=4,3,320,256,3 0=320 1=256 2=3
Convolution 0_21 1 1 data 0_21_bn_relu -23330=4,3,160,128,8 0=8 1=3 3=2 4=1 5=1 6=216 9=1
ConvolutionDepthWise 1_30 1 1 0_21_bn_relu 1_30_bn_relu -23330=4,3,160,128,8 0=8 1=3 4=1 5=1 6=72 7=8 9=1
Convolution 2_39 1 1 1_30_bn_relu 2_39_bn -23330=4,3,160,128,4 0=4 1=1 5=1 6=32
Convolution 3_48 1 1 2_39_bn 3_48_bn_relu -23330=4,3,160,128,24 0=24 1=1 5=1 6=96 9=1
ConvolutionDepthWise 4_57 1 1 3_48_bn_relu 4_57_bn_relu -23330=4,3,80,64,24 0=24 1=3 3=2 4=1 5=1 6=216 7=24 9=1
Convolution 5_66 1 1 4_57_bn_relu 5_66_bn -23330=4,3,80,64,6 0=6 1=1 5=1 6=144
Split 5_66_bn_split 1 2 5_66_bn 5_66_bn_split_0 5_66_bn_split_1 -23330=8,3,80,64,6,3,80,64,6
Convolution 6_75 1 1 5_66_bn_split_0 6_75_bn_relu -23330=4,3,80,64,36 0=36 1=1 5=1 6=216 9=1
ConvolutionDepthWise 7_84 1 1 6_75_bn_relu 7_84_bn_relu -23330=4,3,80,64,36 0=36 1=3 4=1 5=1 6=324 7=36 9=1
Convolution 8_93 1 1 7_84_bn_relu 8_93_bn -23330=4,3,80,64,6 0=6 1=1 5=1 6=216
Eltwise 9_102 2 1 8_93_bn 5_66_bn_split_1 9_102 -23330=4,3,80,64,6 0=1
Convolution 10_107 1 1 9_102 10_107_bn_relu -23330=4,3,80,64,36 0=36 1=1 5=1 6=216 9=1
Split 10_107_bn_relu_split 1 2 10_107_bn_relu 10_107_bn_relu_split_0 10_107_bn_relu_split_1 -23330=8,3,80,64,36,3,80,64,36
ConvolutionDepthWise 11_116 1 1 10_107_bn_relu_split_0 11_116_bn_relu -23330=4,3,40,32,36 0=36 1=3 3=2 4=1 5=1 6=324 7=36 9=1
Convolution 12_125 1 1 11_116_bn_relu 12_125_bn -23330=4,3,40,32,8 0=8 1=1 5=1 6=288
Split 12_125_bn_split 1 2 12_125_bn 12_125_bn_split_0 12_125_bn_split_1 -23330=8,3,40,32,8,3,40,32,8
Convolution 13_134 1 1 12_125_bn_split_0 13_134_bn_relu -23330=4,3,40,32,48 0=48 1=1 5=1 6=384 9=1
ConvolutionDepthWise 14_143 1 1 13_134_bn_relu 14_143_bn_relu -23330=4,3,40,32,48 0=48 1=3 4=1 5=1 6=432 7=48 9=1
Convolution 15_152 1 1 14_143_bn_relu 15_152_bn -23330=4,3,40,32,8 0=8 1=1 5=1 6=384
Eltwise 16_161 2 1 15_152_bn 12_125_bn_split_1 16_161 -23330=4,3,40,32,8 0=1
Split 16_161_split 1 2 16_161 16_161_split_0 16_161_split_1 -23330=8,3,40,32,8,3,40,32,8
Convolution 17_166 1 1 16_161_split_0 17_166_bn_relu -23330=4,3,40,32,48 0=48 1=1 5=1 6=384 9=1
ConvolutionDepthWise 18_175 1 1 17_166_bn_relu 18_175_bn_relu -23330=4,3,40,32,48 0=48 1=3 4=1 5=1 6=432 7=48 9=1
Convolution 19_184 1 1 18_175_bn_relu 19_184_bn -23330=4,3,40,32,8 0=8 1=1 5=1 6=384
Eltwise 20_193 2 1 19_184_bn 16_161_split_1 20_193 -23330=4,3,40,32,8 0=1
Convolution 21_198 1 1 20_193 21_198_bn_relu -23330=4,3,40,32,48 0=48 1=1 5=1 6=384 9=1
Split 21_198_bn_relu_split 1 2 21_198_bn_relu 21_198_bn_relu_split_0 21_198_bn_relu_split_1 -23330=8,3,40,32,48,3,40,32,48
ConvolutionDepthWise 22_207 1 1 21_198_bn_relu_split_0 22_207_bn_relu -23330=4,3,20,16,48 0=48 1=3 3=2 4=1 5=1 6=432 7=48 9=1
Convolution 23_216 1 1 22_207_bn_relu 23_216_bn -23330=4,3,20,16,16 0=16 1=1 5=1 6=768
Split 23_216_bn_split 1 2 23_216_bn 23_216_bn_split_0 23_216_bn_split_1 -23330=8,3,20,16,16,3,20,16,16
Convolution 24_225 1 1 23_216_bn_split_0 24_225_bn_relu -23330=4,3,20,16,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 25_234 1 1 24_225_bn_relu 25_234_bn_relu -23330=4,3,20,16,96 0=96 1=3 4=1 5=1 6=864 7=96 9=1
Convolution 26_243 1 1 25_234_bn_relu 26_243_bn -23330=4,3,20,16,16 0=16 1=1 5=1 6=1536
Eltwise 27_252 2 1 26_243_bn 23_216_bn_split_1 27_252 -23330=4,3,20,16,16 0=1
Split 27_252_split 1 2 27_252 27_252_split_0 27_252_split_1 -23330=8,3,20,16,16,3,20,16,16
Convolution 28_257 1 1 27_252_split_0 28_257_bn_relu -23330=4,3,20,16,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 29_266 1 1 28_257_bn_relu 29_266_bn_relu -23330=4,3,20,16,96 0=96 1=3 4=1 5=1 6=864 7=96 9=1
Convolution 30_275 1 1 29_266_bn_relu 30_275_bn -23330=4,3,20,16,16 0=16 1=1 5=1 6=1536
Eltwise 31_284 2 1 30_275_bn 27_252_split_1 31_284 -23330=4,3,20,16,16 0=1
Split 31_284_split 1 2 31_284 31_284_split_0 31_284_split_1 -23330=8,3,20,16,16,3,20,16,16
Convolution 32_289 1 1 31_284_split_0 32_289_bn_relu -23330=4,3,20,16,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 33_298 1 1 32_289_bn_relu 33_298_bn_relu -23330=4,3,20,16,96 0=96 1=3 4=1 5=1 6=864 7=96 9=1
Convolution 34_307 1 1 33_298_bn_relu 34_307_bn -23330=4,3,20,16,16 0=16 1=1 5=1 6=1536
Eltwise 35_316 2 1 34_307_bn 31_284_split_1 35_316 -23330=4,3,20,16,16 0=1
Convolution 36_321 1 1 35_316 36_321_bn_relu -23330=4,3,20,16,96 0=96 1=1 5=1 6=1536 9=1
ConvolutionDepthWise 37_330 1 1 36_321_bn_relu 37_330_bn_relu -23330=4,3,20,16,96 0=96 1=3 4=1 5=1 6=864 7=96 9=1
Convolution 38_339 1 1 37_330_bn_relu 38_339_bn -23330=4,3,20,16,24 0=24 1=1 5=1 6=2304
Split 38_339_bn_split 1 2 38_339_bn 38_339_bn_split_0 38_339_bn_split_1 -23330=8,3,20,16,24,3,20,16,24
Convolution 39_348 1 1 38_339_bn_split_0 39_348_bn_relu -23330=4,3,20,16,144 0=144 1=1 5=1 6=3456 9=1
ConvolutionDepthWise 40_357 1 1 39_348_bn_relu 40_357_bn_relu -23330=4,3,20,16,144 0=144 1=3 4=1 5=1 6=1296 7=144 9=1
Convolution 41_366 1 1 40_357_bn_relu 41_366_bn -23330=4,3,20,16,24 0=24 1=1 5=1 6=3456
Eltwise 42_375 2 1 41_366_bn 38_339_bn_split_1 42_375 -23330=4,3,20,16,24 0=1
Split 42_375_split 1 2 42_375 42_375_split_0 42_375_split_1 -23330=8,3,20,16,24,3,20,16,24
Convolution 43_380 1 1 42_375_split_0 43_380_bn_relu -23330=4,3,20,16,144 0=144 1=1 5=1 6=3456 9=1
ConvolutionDepthWise 44_389 1 1 43_380_bn_relu 44_389_bn_relu -23330=4,3,20,16,144 0=144 1=3 4=1 5=1 6=1296 7=144 9=1
Convolution 45_398 1 1 44_389_bn_relu 45_398_bn -23330=4,3,20,16,24 0=24 1=1 5=1 6=3456
Eltwise 46_407 2 1 45_398_bn 42_375_split_1 46_407 -23330=4,3,20,16,24 0=1
Convolution 47_412 1 1 46_407 47_412_bn_relu -23330=4,3,20,16,144 0=144 1=1 5=1 6=3456 9=1
Split 47_412_bn_relu_split 1 2 47_412_bn_relu 47_412_bn_relu_split_0 47_412_bn_relu_split_1 -23330=8,3,20,16,144,3,20,16,144
ConvolutionDepthWise 48_421 1 1 47_412_bn_relu_split_0 48_421_bn_relu -23330=4,3,10,8,144 0=144 1=3 3=2 4=1 5=1 6=1296 7=144 9=1
Convolution 49_430 1 1 48_421_bn_relu 49_430_bn -23330=4,3,10,8,40 0=40 1=1 5=1 6=5760
Split 49_430_bn_split 1 2 49_430_bn 49_430_bn_split_0 49_430_bn_split_1 -23330=8,3,10,8,40,3,10,8,40
Convolution 50_439 1 1 49_430_bn_split_0 50_439_bn_relu -23330=4,3,10,8,240 0=240 1=1 5=1 6=9600 9=1
ConvolutionDepthWise 51_448 1 1 50_439_bn_relu 51_448_bn_relu -23330=4,3,10,8,240 0=240 1=3 4=1 5=1 6=2160 7=240 9=1
Convolution 52_457 1 1 51_448_bn_relu 52_457_bn -23330=4,3,10,8,40 0=40 1=1 5=1 6=9600
Eltwise 53_466 2 1 52_457_bn 49_430_bn_split_1 53_466 -23330=4,3,10,8,40 0=1
Split 53_466_split 1 2 53_466 53_466_split_0 53_466_split_1 -23330=8,3,10,8,40,3,10,8,40
Convolution 54_470 1 1 53_466_split_0 54_470_bn_relu -23330=4,3,10,8,240 0=240 1=1 5=1 6=9600 9=1
ConvolutionDepthWise 55_479 1 1 54_470_bn_relu 55_479_bn_relu -23330=4,3,10,8,240 0=240 1=3 4=1 5=1 6=2160 7=240 9=1
Convolution 56_488 1 1 55_479_bn_relu 56_488_bn -23330=4,3,10,8,40 0=40 1=1 5=1 6=9600
Eltwise 57_497 2 1 56_488_bn 53_466_split_1 57_497 -23330=4,3,10,8,40 0=1
Convolution 58_501 1 1 57_497 58_501_bn_relu -23330=4,3,10,8,80 0=80 1=1 5=1 6=3200 9=1
Interp 59_509 1 1 58_501_bn_relu 59_509 -23330=4,3,20,16,80 0=1 1=2.000000e+00 2=2.000000e+00
Concat 60_512 2 1 59_509 47_412_bn_relu_split_1 60_512 -23330=4,3,20,16,224
Convolution 61_515 1 1 60_512 61_515_bn_relu -23330=4,3,20,16,48 0=48 1=1 5=1 6=10752 9=1
Split 61_515_bn_relu_split 1 2 61_515_bn_relu 61_515_bn_relu_split_0 61_515_bn_relu_split_1 -23330=8,3,20,16,48,3,20,16,48
ConvolutionDepthWise 62_523 1 1 61_515_bn_relu_split_0 62_523_bn_relu -23330=4,3,20,16,48 0=48 1=3 4=1 5=1 6=432 7=48 9=1
Convolution 63_532 1 1 62_523_bn_relu 63_532_bn_relu -23330=4,3,20,16,36 0=36 1=1 5=1 6=1728 9=1
Convolution 64_540 1 1 63_532_bn_relu 64_540 -23330=4,3,20,16,18 0=18 1=1 5=1 6=648
Interp 67_568 1 1 61_515_bn_relu_split_1 67_568 -23330=4,3,40,32,48 0=1 1=2.000000e+00 2=2.000000e+00
Concat 68_571 2 1 67_568 21_198_bn_relu_split_1 68_571 -23330=4,3,40,32,96
Convolution 69_574 1 1 68_571 69_574_bn_relu -23330=4,3,40,32,24 0=24 1=1 5=1 6=2304 9=1
Split 69_574_bn_relu_split 1 2 69_574_bn_relu 69_574_bn_relu_split_0 69_574_bn_relu_split_1 -23330=8,3,40,32,24,3,40,32,24
ConvolutionDepthWise 70_582 1 1 69_574_bn_relu_split_0 70_582_bn_relu -23330=4,3,40,32,24 0=24 1=3 4=1 5=1 6=216 7=24 9=1
Convolution 71_591 1 1 70_582_bn_relu 71_591_bn_relu -23330=4,3,40,32,30 0=30 1=1 5=1 6=720 9=1
Convolution 72_599 1 1 71_591_bn_relu 72_599 -23330=4,3,40,32,18 0=18 1=1 5=1 6=540
Interp 75_627 1 1 69_574_bn_relu_split_1 75_627 -23330=4,3,80,64,24 0=1 1=2.000000e+00 2=2.000000e+00
Concat 76_630 2 1 75_627 10_107_bn_relu_split_1 76_630 -23330=4,3,80,64,60
Convolution 77_633 1 1 76_630 77_633_bn_relu -23330=4,3,80,64,18 0=18 1=1 5=1 6=1080 9=1
ConvolutionDepthWise 78_641 1 1 77_633_bn_relu 78_641_bn_relu -23330=4,3,80,64,18 0=18 1=3 4=1 5=1 6=162 7=18 9=1
Convolution 79_650 1 1 78_641_bn_relu 79_650_bn_relu -23330=4,3,80,64,24 0=24 1=1 5=1 6=432 9=1
Convolution 80_658 1 1 79_650_bn_relu 80_658 -23330=4,3,80,64,18 0=18 1=1 5=1 6=432
Yolov3DetectionOutput detection_out 3 1 64_540 72_599 80_658 output -23330=4,2,6,297,1 0=1 1=3 2=5.500000e-01 -23304=18,4.000000e+00,6.000000e+00,7.000000e+00,1.000000e+01,1.100000e+01,1.500000e+01,1.600000e+01,2.400000e+01,3.300000e+01,2.500000e+01,2.600000e+01,4.100000e+01,4.700000e+01,6.000000e+01,8.300000e+01,9.700000e+01,1.410000e+02,1.490000e+02 -23305=9,1086324736,1088421888,1090519040,1077936128,1082130432,1084227584,0,1065353216,1073741824 -23306=3,1.600000e+01,8.000000e+00,4.000000e+00

@ -0,0 +1,47 @@
7767517
45 53
Input data 0 1 data -23330=4,3,416,416,3 0=416 1=416 2=3
Convolution 0_25 1 1 data 0_25_bn_leaky -23330=4,3,208,208,32 0=32 1=3 3=2 4=1 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution 1_33 1 1 0_25_bn_leaky 1_33_bn_leaky -23330=4,3,104,104,64 0=64 1=3 3=2 4=1 5=1 6=18432 9=2 -23310=1,1.000000e-01
Convolution 2_41 1 1 1_33_bn_leaky 2_41_bn_leaky -23330=4,3,104,104,64 0=64 1=3 4=1 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split 2_41_bn_leaky_split 1 2 2_41_bn_leaky 2_41_bn_leaky_split_0 2_41_bn_leaky_split_1 -23330=8,3,104,104,64,3,104,104,64
Crop 3_49 1 1 2_41_bn_leaky_split_0 3_49 -23330=4,3,104,104,32 2=32 3=104 4=104 5=32
Convolution 4_54 1 1 3_49 4_54_bn_leaky -23330=4,3,104,104,32 0=32 1=3 4=1 5=1 6=9216 9=2 -23310=1,1.000000e-01
Split 4_54_bn_leaky_split 1 2 4_54_bn_leaky 4_54_bn_leaky_split_0 4_54_bn_leaky_split_1 -23330=8,3,104,104,32,3,104,104,32
Convolution 5_62 1 1 4_54_bn_leaky_split_0 5_62_bn_leaky -23330=4,3,104,104,32 0=32 1=3 4=1 5=1 6=9216 9=2 -23310=1,1.000000e-01
Concat 6_70 2 1 5_62_bn_leaky 4_54_bn_leaky_split_1 6_70 -23330=4,3,104,104,64
Convolution 7_73 1 1 6_70 7_73_bn_leaky -23330=4,3,104,104,64 0=64 1=1 5=1 6=4096 9=2 -23310=1,1.000000e-01
Concat 8_81 2 1 2_41_bn_leaky_split_1 7_73_bn_leaky 8_81 -23330=4,3,104,104,128
Pooling 9_84 1 1 8_81 9_84 -23330=4,3,52,52,128 1=2 2=2 14=1 15=1 5=1
Convolution 10_88 1 1 9_84 10_88_bn_leaky -23330=4,3,52,52,128 0=128 1=3 4=1 5=1 6=147456 9=2 -23310=1,1.000000e-01
Split 10_88_bn_leaky_split 1 2 10_88_bn_leaky 10_88_bn_leaky_split_0 10_88_bn_leaky_split_1 -23330=8,3,52,52,128,3,52,52,128
Crop 11_96 1 1 10_88_bn_leaky_split_0 11_96 -23330=4,3,52,52,64 2=64 3=52 4=52 5=64
Convolution 12_101 1 1 11_96 12_101_bn_leaky -23330=4,3,52,52,64 0=64 1=3 4=1 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split 12_101_bn_leaky_split 1 2 12_101_bn_leaky 12_101_bn_leaky_split_0 12_101_bn_leaky_split_1 -23330=8,3,52,52,64,3,52,52,64
Convolution 13_109 1 1 12_101_bn_leaky_split_0 13_109_bn_leaky -23330=4,3,52,52,64 0=64 1=3 4=1 5=1 6=36864 9=2 -23310=1,1.000000e-01
Concat 14_117 2 1 13_109_bn_leaky 12_101_bn_leaky_split_1 14_117 -23330=4,3,52,52,128
Convolution 15_120 1 1 14_117 15_120_bn_leaky -23330=4,3,52,52,128 0=128 1=1 5=1 6=16384 9=2 -23310=1,1.000000e-01
Concat 16_128 2 1 10_88_bn_leaky_split_1 15_120_bn_leaky 16_128 -23330=4,3,52,52,256
Pooling 17_131 1 1 16_128 17_131 -23330=4,3,26,26,256 1=2 2=2 14=1 15=1 5=1
Convolution 18_135 1 1 17_131 18_135_bn_leaky -23330=4,3,26,26,256 0=256 1=3 4=1 5=1 6=589824 9=2 -23310=1,1.000000e-01
Split 18_135_bn_leaky_split 1 2 18_135_bn_leaky 18_135_bn_leaky_split_0 18_135_bn_leaky_split_1 -23330=8,3,26,26,256,3,26,26,256
Crop 19_143 1 1 18_135_bn_leaky_split_0 19_143 -23330=4,3,26,26,128 2=128 3=26 4=26 5=128
Convolution 20_148 1 1 19_143 20_148_bn_leaky -23330=4,3,26,26,128 0=128 1=3 4=1 5=1 6=147456 9=2 -23310=1,1.000000e-01
Split 20_148_bn_leaky_split 1 2 20_148_bn_leaky 20_148_bn_leaky_split_0 20_148_bn_leaky_split_1 -23330=8,3,26,26,128,3,26,26,128
Convolution 21_156 1 1 20_148_bn_leaky_split_0 21_156_bn_leaky -23330=4,3,26,26,128 0=128 1=3 4=1 5=1 6=147456 9=2 -23310=1,1.000000e-01
Concat 22_164 2 1 21_156_bn_leaky 20_148_bn_leaky_split_1 22_164 -23330=4,3,26,26,256
Convolution 23_167 1 1 22_164 23_167_bn_leaky -23330=4,3,26,26,256 0=256 1=1 5=1 6=65536 9=2 -23310=1,1.000000e-01
Split 23_167_bn_leaky_split 1 2 23_167_bn_leaky 23_167_bn_leaky_split_0 23_167_bn_leaky_split_1 -23330=8,3,26,26,256,3,26,26,256
Concat 24_175 2 1 18_135_bn_leaky_split_1 23_167_bn_leaky_split_0 24_175 -23330=4,3,26,26,512
Pooling 25_178 1 1 24_175 25_178 -23330=4,3,13,13,512 1=2 2=2 14=1 15=1 5=1
Convolution 26_182 1 1 25_178 26_182_bn_leaky -23330=4,3,13,13,512 0=512 1=3 4=1 5=1 6=2359296 9=2 -23310=1,1.000000e-01
Convolution 27_192 1 1 26_182_bn_leaky 27_192_bn_leaky -23330=4,3,13,13,256 0=256 1=1 5=1 6=131072 9=2 -23310=1,1.000000e-01
Split 27_192_bn_leaky_split 1 2 27_192_bn_leaky 27_192_bn_leaky_split_0 27_192_bn_leaky_split_1 -23330=8,3,13,13,256,3,13,13,256
Convolution 28_200 1 1 27_192_bn_leaky_split_0 28_200_bn_leaky -23330=4,3,13,13,512 0=512 1=3 4=1 5=1 6=1179648 9=2 -23310=1,1.000000e-01
Convolution 29_208 1 1 28_200_bn_leaky 29_208 -23330=4,3,13,13,255 0=255 1=1 5=1 6=130560
Convolution 32_237 1 1 27_192_bn_leaky_split_1 32_237_bn_leaky -23330=4,3,13,13,128 0=128 1=1 5=1 6=32768 9=2 -23310=1,1.000000e-01
Interp 33_245 1 1 32_237_bn_leaky 33_245 -23330=4,3,26,26,128 0=1 1=2.000000e+00 2=2.000000e+00
Concat 34_248 2 1 33_245 23_167_bn_leaky_split_1 34_248 -23330=4,3,26,26,384
Convolution 35_251 1 1 34_248 35_251_bn_leaky -23330=4,3,26,26,256 0=256 1=3 4=1 5=1 6=884736 9=2 -23310=1,1.000000e-01
Convolution 36_259 1 1 35_251_bn_leaky 36_259 -23330=4,3,26,26,255 0=255 1=1 5=1 6=65280
Yolov3DetectionOutput detection_out 2 1 29_208 36_259 output -23330=4,2,6,1637,1 0=80 1=3 2=2.500000e-01 -23304=12,1.000000e+01,1.400000e+01,2.300000e+01,2.700000e+01,3.700000e+01,5.800000e+01,8.100000e+01,8.200000e+01,1.350000e+02,1.690000e+02,3.440000e+02,3.190000e+02 -23305=6,1077936128,1082130432,1084227584,1065353216,1073741824,1077936128 -23306=2,3.360000e+01,1.680000e+01

@ -0,0 +1,126 @@
7767517
124 149
Input images 0 1 images
Split splitncnn_input0 1 4 images images_splitncnn_0 images_splitncnn_1 images_splitncnn_2 images_splitncnn_3
Concat Concat_0 4 1 images_splitncnn_3 images_splitncnn_2 images_splitncnn_1 images_splitncnn_0 141
Convolution Conv_1 1 1 141 143 0=32 1=3 4=1 5=1 6=3456 9=2 -23310=1,1.000000e-01
Convolution Conv_3 1 1 143 145 0=64 1=3 3=2 4=1 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 145 145_splitncnn_0 145_splitncnn_1
Convolution Conv_5 1 1 145_splitncnn_1 147 0=32 1=1 5=1 6=2048 9=2 -23310=1,1.000000e-01
Convolution Conv_7 1 1 147 149 0=64 1=3 4=1 5=1 6=18432 9=2 -23310=1,1.000000e-01
BinaryOp Add_9 2 1 145_splitncnn_0 149 150
Convolution Conv_10 1 1 150 152 0=128 1=3 3=2 4=1 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 152 152_splitncnn_0 152_splitncnn_1
Convolution Conv_12 1 1 152_splitncnn_1 154 0=64 1=1 5=1 6=8192 9=2 -23310=1,1.000000e-01
Split splitncnn_2 1 2 154 154_splitncnn_0 154_splitncnn_1
Convolution Conv_14 1 1 154_splitncnn_1 156 0=64 1=1 5=1 6=4096 9=2 -23310=1,1.000000e-01
Convolution Conv_16 1 1 156 158 0=64 1=3 4=1 5=1 6=36864 9=2 -23310=1,1.000000e-01
BinaryOp Add_18 2 1 154_splitncnn_0 158 159
Split splitncnn_3 1 2 159 159_splitncnn_0 159_splitncnn_1
Convolution Conv_19 1 1 159_splitncnn_1 161 0=64 1=1 5=1 6=4096 9=2 -23310=1,1.000000e-01
Convolution Conv_21 1 1 161 163 0=64 1=3 4=1 5=1 6=36864 9=2 -23310=1,1.000000e-01
BinaryOp Add_23 2 1 159_splitncnn_0 163 164
Split splitncnn_4 1 2 164 164_splitncnn_0 164_splitncnn_1
Convolution Conv_24 1 1 164_splitncnn_1 166 0=64 1=1 5=1 6=4096 9=2 -23310=1,1.000000e-01
Convolution Conv_26 1 1 166 168 0=64 1=3 4=1 5=1 6=36864 9=2 -23310=1,1.000000e-01
BinaryOp Add_28 2 1 164_splitncnn_0 168 169
Convolution Conv_29 1 1 169 170 0=64 1=1 6=4096
Convolution Conv_30 1 1 152_splitncnn_0 171 0=64 1=1 6=8192
Concat Concat_31 2 1 170 171 172
BatchNorm BatchNormalization_32 1 1 172 173 0=128
ReLU LeakyRelu_33 1 1 173 174 0=1.000000e-01
Convolution Conv_34 1 1 174 176 0=128 1=1 5=1 6=16384 9=2 -23310=1,1.000000e-01
Split splitncnn_5 1 2 176 176_splitncnn_0 176_splitncnn_1
Convolution Conv_36 1 1 176_splitncnn_1 178 0=256 1=3 3=2 4=1 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 178 178_splitncnn_0 178_splitncnn_1
Convolution Conv_38 1 1 178_splitncnn_1 180 0=128 1=1 5=1 6=32768 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 180 180_splitncnn_0 180_splitncnn_1
Convolution Conv_40 1 1 180_splitncnn_1 182 0=128 1=1 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution Conv_42 1 1 182 184 0=128 1=3 4=1 5=1 6=147456 9=2 -23310=1,1.000000e-01
BinaryOp Add_44 2 1 180_splitncnn_0 184 185
Split splitncnn_8 1 2 185 185_splitncnn_0 185_splitncnn_1
Convolution Conv_45 1 1 185_splitncnn_1 187 0=128 1=1 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution Conv_47 1 1 187 189 0=128 1=3 4=1 5=1 6=147456 9=2 -23310=1,1.000000e-01
BinaryOp Add_49 2 1 185_splitncnn_0 189 190
Split splitncnn_9 1 2 190 190_splitncnn_0 190_splitncnn_1
Convolution Conv_50 1 1 190_splitncnn_1 192 0=128 1=1 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution Conv_52 1 1 192 194 0=128 1=3 4=1 5=1 6=147456 9=2 -23310=1,1.000000e-01
BinaryOp Add_54 2 1 190_splitncnn_0 194 195
Convolution Conv_55 1 1 195 196 0=128 1=1 6=16384
Convolution Conv_56 1 1 178_splitncnn_0 197 0=128 1=1 6=32768
Concat Concat_57 2 1 196 197 198
BatchNorm BatchNormalization_58 1 1 198 199 0=256
ReLU LeakyRelu_59 1 1 199 200 0=1.000000e-01
Convolution Conv_60 1 1 200 202 0=256 1=1 5=1 6=65536 9=2 -23310=1,1.000000e-01
Split splitncnn_10 1 2 202 202_splitncnn_0 202_splitncnn_1
Convolution Conv_62 1 1 202_splitncnn_1 204 0=512 1=3 3=2 4=1 5=1 6=1179648 9=2 -23310=1,1.000000e-01
Convolution Conv_64 1 1 204 206 0=256 1=1 5=1 6=131072 9=2 -23310=1,1.000000e-01
Split splitncnn_11 1 4 206 206_splitncnn_0 206_splitncnn_1 206_splitncnn_2 206_splitncnn_3
Pooling MaxPool_66 1 1 206_splitncnn_3 207 1=5 3=2 5=1
Pooling MaxPool_67 1 1 206_splitncnn_2 208 1=9 3=4 5=1
Pooling MaxPool_68 1 1 206_splitncnn_1 209 1=13 3=6 5=1
Concat Concat_69 4 1 206_splitncnn_0 207 208 209 210
Convolution Conv_70 1 1 210 212 0=512 1=1 5=1 6=524288 9=2 -23310=1,1.000000e-01
Split splitncnn_12 1 2 212 212_splitncnn_0 212_splitncnn_1
Convolution Conv_72 1 1 212_splitncnn_1 214 0=256 1=1 5=1 6=131072 9=2 -23310=1,1.000000e-01
Split splitncnn_13 1 2 214 214_splitncnn_0 214_splitncnn_1
Convolution Conv_74 1 1 214_splitncnn_1 216 0=256 1=1 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution Conv_76 1 1 216 218 0=256 1=3 4=1 5=1 6=589824 9=2 -23310=1,1.000000e-01
BinaryOp Add_78 2 1 214_splitncnn_0 218 219
Split splitncnn_14 1 2 219 219_splitncnn_0 219_splitncnn_1
Convolution Conv_79 1 1 219_splitncnn_1 221 0=256 1=1 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution Conv_81 1 1 221 223 0=256 1=3 4=1 5=1 6=589824 9=2 -23310=1,1.000000e-01
BinaryOp Add_83 2 1 219_splitncnn_0 223 224
Convolution Conv_84 1 1 224 225 0=256 1=1 6=65536
Convolution Conv_85 1 1 212_splitncnn_0 226 0=256 1=1 6=131072
Concat Concat_86 2 1 225 226 227
BatchNorm BatchNormalization_87 1 1 227 228 0=512
ReLU LeakyRelu_88 1 1 228 229 0=1.000000e-01
Convolution Conv_89 1 1 229 231 0=512 1=1 5=1 6=262144 9=2 -23310=1,1.000000e-01
Split splitncnn_15 1 2 231 231_splitncnn_0 231_splitncnn_1
Convolution Conv_91 1 1 231_splitncnn_1 233 0=256 1=1 5=1 6=131072 9=2 -23310=1,1.000000e-01
Convolution Conv_93 1 1 233 235 0=256 1=1 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution Conv_95 1 1 235 237 0=256 1=3 4=1 5=1 6=589824 9=2 -23310=1,1.000000e-01
Convolution Conv_97 1 1 237 238 0=256 1=1 6=65536
Convolution Conv_98 1 1 231_splitncnn_0 239 0=256 1=1 6=131072
Concat Concat_99 2 1 238 239 240
BatchNorm BatchNormalization_100 1 1 240 241 0=512
ReLU LeakyRelu_101 1 1 241 242 0=1.000000e-01
Convolution Conv_102 1 1 242 244 0=512 1=1 5=1 6=262144 9=2 -23310=1,1.000000e-01
Split splitncnn_16 1 2 244 244_splitncnn_0 244_splitncnn_1
Convolution Conv_104 1 1 244_splitncnn_1 245 0=255 1=1 5=1 6=130560
Interp Resize_133 1 1 244_splitncnn_0 274 0=1 3=40 4=40
Concat Concat_134 2 1 274 202_splitncnn_0 275
Convolution Conv_135 1 1 275 277 0=256 1=1 5=1 6=196608 9=2 -23310=1,1.000000e-01
Split splitncnn_17 1 2 277 277_splitncnn_0 277_splitncnn_1
Convolution Conv_137 1 1 277_splitncnn_1 279 0=128 1=1 5=1 6=32768 9=2 -23310=1,1.000000e-01
Convolution Conv_139 1 1 279 281 0=128 1=1 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution Conv_141 1 1 281 283 0=128 1=3 4=1 5=1 6=147456 9=2 -23310=1,1.000000e-01
Convolution Conv_143 1 1 283 284 0=128 1=1 6=16384
Convolution Conv_144 1 1 277_splitncnn_0 285 0=128 1=1 6=32768
Concat Concat_145 2 1 284 285 286
BatchNorm BatchNormalization_146 1 1 286 287 0=256
ReLU LeakyRelu_147 1 1 287 288 0=1.000000e-01
Convolution Conv_148 1 1 288 290 0=256 1=1 5=1 6=65536 9=2 -23310=1,1.000000e-01
Split splitncnn_18 1 2 290 290_splitncnn_0 290_splitncnn_1
Convolution Conv_150 1 1 290_splitncnn_1 291 0=255 1=1 5=1 6=65280
Interp Resize_179 1 1 290_splitncnn_0 320 0=1 3=80 4=80
Concat Concat_180 2 1 320 176_splitncnn_0 321
Convolution Conv_181 1 1 321 323 0=128 1=1 5=1 6=49152 9=2 -23310=1,1.000000e-01
Split splitncnn_19 1 2 323 323_splitncnn_0 323_splitncnn_1
Convolution Conv_183 1 1 323_splitncnn_1 325 0=64 1=1 5=1 6=8192 9=2 -23310=1,1.000000e-01
Convolution Conv_185 1 1 325 327 0=64 1=1 5=1 6=4096 9=2 -23310=1,1.000000e-01
Convolution Conv_187 1 1 327 329 0=64 1=3 4=1 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution Conv_189 1 1 329 330 0=64 1=1 6=4096
Convolution Conv_190 1 1 323_splitncnn_0 331 0=64 1=1 6=8192
Concat Concat_191 2 1 330 331 332
BatchNorm BatchNormalization_192 1 1 332 333 0=128
ReLU LeakyRelu_193 1 1 333 334 0=1.000000e-01
Convolution Conv_194 1 1 334 336 0=128 1=1 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution Conv_196 1 1 336 337 0=255 1=1 5=1 6=32640
Reshape Reshape_210 1 1 337 355 0=6400 1=85 2=3
Permute Transpose_211 1 1 355 output 0=1
Reshape Reshape_225 1 1 291 374 0=1600 1=85 2=3
Permute Transpose_226 1 1 374 375 0=1
Reshape Reshape_240 1 1 245 393 0=400 1=85 2=3
Permute Transpose_241 1 1 393 394 0=1

@ -0,0 +1,194 @@
7767517
192 216
Input images 0 1 images
YoloV5Focus focus 1 1 images 207
Convolution Conv_41 1 1 207 208 0=32 1=3 4=1 5=1 6=3456
HardSwish Div_49 1 1 208 216 0=1.666667e-01
Convolution Conv_50 1 1 216 217 0=64 1=3 3=2 4=1 5=1 6=18432
HardSwish Div_58 1 1 217 225 0=1.666667e-01
Split splitncnn_0 1 2 225 225_splitncnn_0 225_splitncnn_1
Convolution Conv_59 1 1 225_splitncnn_1 226 0=32 1=1 5=1 6=2048
HardSwish Div_67 1 1 226 234 0=1.666667e-01
Split splitncnn_1 1 2 234 234_splitncnn_0 234_splitncnn_1
Convolution Conv_68 1 1 234_splitncnn_1 235 0=32 1=1 5=1 6=1024
HardSwish Div_76 1 1 235 243 0=1.666667e-01
Convolution Conv_77 1 1 243 244 0=32 1=3 4=1 5=1 6=9216
HardSwish Div_85 1 1 244 252 0=1.666667e-01
BinaryOp Add_86 2 1 234_splitncnn_0 252 253
Convolution Conv_87 1 1 253 254 0=32 1=1 6=1024
Convolution Conv_88 1 1 225_splitncnn_0 255 0=32 1=1 6=2048
Concat Concat_89 2 1 254 255 256
BatchNorm BatchNormalization_90 1 1 256 257 0=64
ReLU LeakyRelu_91 1 1 257 258 0=1.000000e-01
Convolution Conv_92 1 1 258 259 0=64 1=1 5=1 6=4096
HardSwish Div_100 1 1 259 267 0=1.666667e-01
Convolution Conv_101 1 1 267 268 0=128 1=3 3=2 4=1 5=1 6=73728
HardSwish Div_109 1 1 268 276 0=1.666667e-01
Split splitncnn_2 1 2 276 276_splitncnn_0 276_splitncnn_1
Convolution Conv_110 1 1 276_splitncnn_1 277 0=64 1=1 5=1 6=8192
HardSwish Div_118 1 1 277 285 0=1.666667e-01
Split splitncnn_3 1 2 285 285_splitncnn_0 285_splitncnn_1
Convolution Conv_119 1 1 285_splitncnn_1 286 0=64 1=1 5=1 6=4096
HardSwish Div_127 1 1 286 294 0=1.666667e-01
Convolution Conv_128 1 1 294 295 0=64 1=3 4=1 5=1 6=36864
HardSwish Div_136 1 1 295 303 0=1.666667e-01
BinaryOp Add_137 2 1 285_splitncnn_0 303 304
Split splitncnn_4 1 2 304 304_splitncnn_0 304_splitncnn_1
Convolution Conv_138 1 1 304_splitncnn_1 305 0=64 1=1 5=1 6=4096
HardSwish Div_146 1 1 305 313 0=1.666667e-01
Convolution Conv_147 1 1 313 314 0=64 1=3 4=1 5=1 6=36864
HardSwish Div_155 1 1 314 322 0=1.666667e-01
BinaryOp Add_156 2 1 304_splitncnn_0 322 323
Split splitncnn_5 1 2 323 323_splitncnn_0 323_splitncnn_1
Convolution Conv_157 1 1 323_splitncnn_1 324 0=64 1=1 5=1 6=4096
HardSwish Div_165 1 1 324 332 0=1.666667e-01
Convolution Conv_166 1 1 332 333 0=64 1=3 4=1 5=1 6=36864
HardSwish Div_174 1 1 333 341 0=1.666667e-01
BinaryOp Add_175 2 1 323_splitncnn_0 341 342
Convolution Conv_176 1 1 342 343 0=64 1=1 6=4096
Convolution Conv_177 1 1 276_splitncnn_0 344 0=64 1=1 6=8192
Concat Concat_178 2 1 343 344 345
BatchNorm BatchNormalization_179 1 1 345 346 0=128
ReLU LeakyRelu_180 1 1 346 347 0=1.000000e-01
Convolution Conv_181 1 1 347 348 0=128 1=1 5=1 6=16384
HardSwish Div_189 1 1 348 356 0=1.666667e-01
Split splitncnn_6 1 2 356 356_splitncnn_0 356_splitncnn_1
Convolution Conv_190 1 1 356_splitncnn_1 357 0=256 1=3 3=2 4=1 5=1 6=294912
HardSwish Div_198 1 1 357 365 0=1.666667e-01
Split splitncnn_7 1 2 365 365_splitncnn_0 365_splitncnn_1
Convolution Conv_199 1 1 365_splitncnn_1 366 0=128 1=1 5=1 6=32768
HardSwish Div_207 1 1 366 374 0=1.666667e-01
Split splitncnn_8 1 2 374 374_splitncnn_0 374_splitncnn_1
Convolution Conv_208 1 1 374_splitncnn_1 375 0=128 1=1 5=1 6=16384
HardSwish Div_216 1 1 375 383 0=1.666667e-01
Convolution Conv_217 1 1 383 384 0=128 1=3 4=1 5=1 6=147456
HardSwish Div_225 1 1 384 392 0=1.666667e-01
BinaryOp Add_226 2 1 374_splitncnn_0 392 393
Split splitncnn_9 1 2 393 393_splitncnn_0 393_splitncnn_1
Convolution Conv_227 1 1 393_splitncnn_1 394 0=128 1=1 5=1 6=16384
HardSwish Div_235 1 1 394 402 0=1.666667e-01
Convolution Conv_236 1 1 402 403 0=128 1=3 4=1 5=1 6=147456
HardSwish Div_244 1 1 403 411 0=1.666667e-01
BinaryOp Add_245 2 1 393_splitncnn_0 411 412
Split splitncnn_10 1 2 412 412_splitncnn_0 412_splitncnn_1
Convolution Conv_246 1 1 412_splitncnn_1 413 0=128 1=1 5=1 6=16384
HardSwish Div_254 1 1 413 421 0=1.666667e-01
Convolution Conv_255 1 1 421 422 0=128 1=3 4=1 5=1 6=147456
HardSwish Div_263 1 1 422 430 0=1.666667e-01
BinaryOp Add_264 2 1 412_splitncnn_0 430 431
Convolution Conv_265 1 1 431 432 0=128 1=1 6=16384
Convolution Conv_266 1 1 365_splitncnn_0 433 0=128 1=1 6=32768
Concat Concat_267 2 1 432 433 434
BatchNorm BatchNormalization_268 1 1 434 435 0=256
ReLU LeakyRelu_269 1 1 435 436 0=1.000000e-01
Convolution Conv_270 1 1 436 437 0=256 1=1 5=1 6=65536
HardSwish Div_278 1 1 437 445 0=1.666667e-01
Split splitncnn_11 1 2 445 445_splitncnn_0 445_splitncnn_1
Convolution Conv_279 1 1 445_splitncnn_1 446 0=512 1=3 3=2 4=1 5=1 6=1179648
HardSwish Div_287 1 1 446 454 0=1.666667e-01
Convolution Conv_288 1 1 454 455 0=256 1=1 5=1 6=131072
HardSwish Div_296 1 1 455 463 0=1.666667e-01
Split splitncnn_12 1 4 463 463_splitncnn_0 463_splitncnn_1 463_splitncnn_2 463_splitncnn_3
Pooling MaxPool_297 1 1 463_splitncnn_3 464 1=5 3=2 5=1
Pooling MaxPool_298 1 1 463_splitncnn_2 465 1=9 3=4 5=1
Pooling MaxPool_299 1 1 463_splitncnn_1 466 1=13 3=6 5=1
Concat Concat_300 4 1 463_splitncnn_0 464 465 466 467
Convolution Conv_301 1 1 467 468 0=512 1=1 5=1 6=524288
HardSwish Div_309 1 1 468 476 0=1.666667e-01
Split splitncnn_13 1 2 476 476_splitncnn_0 476_splitncnn_1
Convolution Conv_310 1 1 476_splitncnn_1 477 0=256 1=1 5=1 6=131072
HardSwish Div_318 1 1 477 485 0=1.666667e-01
Convolution Conv_319 1 1 485 486 0=256 1=1 5=1 6=65536
HardSwish Div_327 1 1 486 494 0=1.666667e-01
Convolution Conv_328 1 1 494 495 0=256 1=3 4=1 5=1 6=589824
HardSwish Div_336 1 1 495 503 0=1.666667e-01
Convolution Conv_337 1 1 503 504 0=256 1=1 6=65536
Convolution Conv_338 1 1 476_splitncnn_0 505 0=256 1=1 6=131072
Concat Concat_339 2 1 504 505 506
BatchNorm BatchNormalization_340 1 1 506 507 0=512
ReLU LeakyRelu_341 1 1 507 508 0=1.000000e-01
Convolution Conv_342 1 1 508 509 0=512 1=1 5=1 6=262144
HardSwish Div_350 1 1 509 517 0=1.666667e-01
Convolution Conv_351 1 1 517 518 0=256 1=1 5=1 6=131072
HardSwish Div_359 1 1 518 526 0=1.666667e-01
Split splitncnn_14 1 2 526 526_splitncnn_0 526_splitncnn_1
Interp Resize_361 1 1 526_splitncnn_1 536 0=1 1=2.000000e+00 2=2.000000e+00
Concat Concat_362 2 1 536 445_splitncnn_0 537
Split splitncnn_15 1 2 537 537_splitncnn_0 537_splitncnn_1
Convolution Conv_363 1 1 537_splitncnn_1 538 0=128 1=1 5=1 6=65536
HardSwish Div_371 1 1 538 546 0=1.666667e-01
Convolution Conv_372 1 1 546 547 0=128 1=1 5=1 6=16384
HardSwish Div_380 1 1 547 555 0=1.666667e-01
Convolution Conv_381 1 1 555 556 0=128 1=3 4=1 5=1 6=147456
HardSwish Div_389 1 1 556 564 0=1.666667e-01
Convolution Conv_390 1 1 564 565 0=128 1=1 6=16384
Convolution Conv_391 1 1 537_splitncnn_0 566 0=128 1=1 6=65536
Concat Concat_392 2 1 565 566 567
BatchNorm BatchNormalization_393 1 1 567 568 0=256
ReLU LeakyRelu_394 1 1 568 569 0=1.000000e-01
Convolution Conv_395 1 1 569 570 0=256 1=1 5=1 6=65536
HardSwish Div_403 1 1 570 578 0=1.666667e-01
Convolution Conv_404 1 1 578 579 0=128 1=1 5=1 6=32768
HardSwish Div_412 1 1 579 587 0=1.666667e-01
Split splitncnn_16 1 2 587 587_splitncnn_0 587_splitncnn_1
Interp Resize_414 1 1 587_splitncnn_1 597 0=1 1=2.000000e+00 2=2.000000e+00
Concat Concat_415 2 1 597 356_splitncnn_0 598
Split splitncnn_17 1 2 598 598_splitncnn_0 598_splitncnn_1
Convolution Conv_416 1 1 598_splitncnn_1 599 0=64 1=1 5=1 6=16384
HardSwish Div_424 1 1 599 607 0=1.666667e-01
Convolution Conv_425 1 1 607 608 0=64 1=1 5=1 6=4096
HardSwish Div_433 1 1 608 616 0=1.666667e-01
Convolution Conv_434 1 1 616 617 0=64 1=3 4=1 5=1 6=36864
HardSwish Div_442 1 1 617 625 0=1.666667e-01
Convolution Conv_443 1 1 625 626 0=64 1=1 6=4096
Convolution Conv_444 1 1 598_splitncnn_0 627 0=64 1=1 6=16384
Concat Concat_445 2 1 626 627 628
BatchNorm BatchNormalization_446 1 1 628 629 0=128
ReLU LeakyRelu_447 1 1 629 630 0=1.000000e-01
Convolution Conv_448 1 1 630 631 0=128 1=1 5=1 6=16384
HardSwish Div_456 1 1 631 639 0=1.666667e-01
Split splitncnn_18 1 2 639 639_splitncnn_0 639_splitncnn_1
Convolution Conv_457 1 1 639_splitncnn_1 640 0=128 1=3 3=2 4=1 5=1 6=147456
HardSwish Div_465 1 1 640 648 0=1.666667e-01
Concat Concat_466 2 1 648 587_splitncnn_0 649
Split splitncnn_19 1 2 649 649_splitncnn_0 649_splitncnn_1
Convolution Conv_467 1 1 649_splitncnn_1 650 0=128 1=1 5=1 6=32768
HardSwish Div_475 1 1 650 658 0=1.666667e-01
Convolution Conv_476 1 1 658 659 0=128 1=1 5=1 6=16384
HardSwish Div_484 1 1 659 667 0=1.666667e-01
Convolution Conv_485 1 1 667 668 0=128 1=3 4=1 5=1 6=147456
HardSwish Div_493 1 1 668 676 0=1.666667e-01
Convolution Conv_494 1 1 676 677 0=128 1=1 6=16384
Convolution Conv_495 1 1 649_splitncnn_0 678 0=128 1=1 6=32768
Concat Concat_496 2 1 677 678 679
BatchNorm BatchNormalization_497 1 1 679 680 0=256
ReLU LeakyRelu_498 1 1 680 681 0=1.000000e-01
Convolution Conv_499 1 1 681 682 0=256 1=1 5=1 6=65536
HardSwish Div_507 1 1 682 690 0=1.666667e-01
Split splitncnn_20 1 2 690 690_splitncnn_0 690_splitncnn_1
Convolution Conv_508 1 1 690_splitncnn_1 691 0=256 1=3 3=2 4=1 5=1 6=589824
HardSwish Div_516 1 1 691 699 0=1.666667e-01
Concat Concat_517 2 1 699 526_splitncnn_0 700
Split splitncnn_21 1 2 700 700_splitncnn_0 700_splitncnn_1
Convolution Conv_518 1 1 700_splitncnn_1 701 0=256 1=1 5=1 6=131072
HardSwish Div_526 1 1 701 709 0=1.666667e-01
Convolution Conv_527 1 1 709 710 0=256 1=1 5=1 6=65536
HardSwish Div_535 1 1 710 718 0=1.666667e-01
Convolution Conv_536 1 1 718 719 0=256 1=3 4=1 5=1 6=589824
HardSwish Div_544 1 1 719 727 0=1.666667e-01
Convolution Conv_545 1 1 727 728 0=256 1=1 6=65536
Convolution Conv_546 1 1 700_splitncnn_0 729 0=256 1=1 6=131072
Concat Concat_547 2 1 728 729 730
BatchNorm BatchNormalization_548 1 1 730 731 0=512
ReLU LeakyRelu_549 1 1 731 732 0=1.000000e-01
Convolution Conv_550 1 1 732 733 0=512 1=1 5=1 6=262144
HardSwish Div_558 1 1 733 741 0=1.666667e-01
Convolution Conv_559 1 1 639_splitncnn_0 742 0=255 1=1 5=1 6=32640
Reshape Reshape_573 1 1 742 760 0=-1 1=85 2=3
Permute Transpose_574 1 1 760 output 0=1
Convolution Conv_575 1 1 690_splitncnn_0 762 0=255 1=1 5=1 6=65280
Reshape Reshape_589 1 1 762 780 0=-1 1=85 2=3
Permute Transpose_590 1 1 780 781 0=1
Convolution Conv_591 1 1 741 782 0=255 1=1 5=1 6=130560
Reshape Reshape_605 1 1 782 800 0=-1 1=85 2=3
Permute Transpose_606 1 1 800 801 0=1

@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.4.1)
project(yolov5)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
if (DEFINED ANDROID_NDK_MAJOR AND ${ANDROID_NDK_MAJOR} GREATER 20)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-openmp")
endif ()
# disable rtti and exceptions
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
# enable rtti and exceptions
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
set(ncnn_DIR ${CMAKE_SOURCE_DIR}/ncnnvulkan/${ANDROID_ABI}/lib/cmake/ncnn)
find_package(ncnn REQUIRED)
set_target_properties(
ncnn PROPERTIES
INTERFACE_COMPILE_OPTIONS "-frtti;-fexceptions"
# ncnn.cmake opencv2ncnn
)
# .cpp
aux_source_directory(. SRC_LIST)
aux_source_directory(./ocr OCR_SRC_LIST)
add_library(
yolov5
SHARED
${SRC_LIST}
${OCR_SRC_LIST}
)
include_directories(
ocr
# ./ncnnvulkan # 使 "net.h" "ncnn/net.h"
${CMAKE_SOURCE_DIR}/ncnnvulkan/${ANDROID_ABI}/include/ # "ncnn/net.h"
${CMAKE_SOURCE_DIR}/opencv/include/
)
add_library(libopencv_java4 STATIC IMPORTED)
set_target_properties(
libopencv_java4
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/opencv/${ANDROID_ABI}/libopencv_java4.so
)
target_link_libraries(
yolov5
libopencv_java4
ncnn
)

@ -0,0 +1,204 @@
//
// Created by WZTENG on 2020/09/14 014.
//
#include "DBFace.h"
bool DBFace::hasGPU = true;
bool DBFace::toUseGPU = true;
DBFace *DBFace::detector = nullptr;
DBFace::DBFace(AAssetManager *mgr, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
DBFaceNet = new ncnn::Net();
// opt 需要在加载前设置
DBFaceNet->opt.use_vulkan_compute = toUseGPU; // gpu
DBFaceNet->opt.use_fp16_arithmetic = true; // fp16运算加速
DBFaceNet->load_param(mgr, "dbface.param");
DBFaceNet->load_model(mgr, "dbface.bin");
// LOGD("dbface_detector");
}
DBFace::~DBFace() {
DBFaceNet->clear();
delete DBFaceNet;
}
std::vector<Obj> DBFace::detect(JNIEnv *env, jobject image, double threshold, double nms_threshold) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
ncnn::Mat src_img = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB,
img_size.width, img_size.height);
cv::Mat im_bgr(src_img.h, src_img.w, CV_8UC3);
src_img.to_pixels(im_bgr.data, ncnn::Mat::PIXEL_RGB2BGR);
// 图像缩放
auto im = pad(im_bgr);
ncnn::Mat in = ncnn::Mat::from_pixels(im.data, ncnn::Mat::PIXEL_BGR2RGB, im.cols, im.rows);
const float mean_vals_1[3] = {0.485f * 255.0f, 0.456f * 255.0f, 0.406f * 255.0f};
const float norm_vals_1[3] = {1.0f / 0.229f / 255.0f, 1.0f / 0.224f / 255.0f, 1.0f / 0.225f / 255.0f};
in.substract_mean_normalize(mean_vals_1, norm_vals_1);
ncnn::Extractor ex = DBFaceNet->create_extractor();
ex.input("0", in);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ncnn::Mat landmark, hm, hmPool, tlrb;
ex.extract("landmark", landmark);
ex.extract("hm", hm);
ex.extract("pool_hm", hmPool);
ex.extract("tlrb", tlrb);
int hmWeight = hm.w;
hm = hm.reshape(hm.c * hm.h * hm.w);
hmPool = hmPool.reshape(hmPool.c * hmPool.w * hmPool.h);
std::vector<Id> ids;
//get suspected boxs
genIds(hm, hmPool, hmWeight, threshold, ids);
std::vector<Obj> objs;
//get each box and key point information
decode(hmWeight, ids, tlrb, landmark, objs);
return nms(objs, (float) (1 - nms_threshold)); // 注意这里: 1 - iou
}
void DBFace::genIds(ncnn::Mat hm, ncnn::Mat hmPool, int w, double thresh, std::vector<Id> &ids) {
const float *ptr = hm.channel(0);
const float *ptrPool = hmPool.channel(0);
for (int i = 0; i < hm.w; i++) {
float temp = 0.0;
if ((ptr[i] - ptrPool[i]) < 0.01) {
temp = ptr[i];
}
if (ptr[i] > thresh) {
Id temp;
temp.idx = i % w;
temp.idy = (int) (i / w);
temp.score = ptr[i];
ids.push_back(temp);
}
}
}
void DBFace::decode(int w, std::vector<Id> ids, ncnn::Mat tlrb, ncnn::Mat landmark, std::vector<Obj> &objs) {
for (int i = 0; i < ids.size(); i++) {
Obj objTemp;
int cx = ids[i].idx;
int cy = ids[i].idy;
double score = ids[i].score;
std::vector<float> boxTemp;
//get each box information
for (int j = 0; j < tlrb.c; j++) {
const float *ptr = tlrb.channel(j);
boxTemp.push_back(ptr[w * (cy - 1) + cx]);
}
objTemp.box.x = (cx - boxTemp[0]) * STRIDE;
objTemp.box.y = (cy - boxTemp[1]) * STRIDE;
objTemp.box.r = (cx + boxTemp[2]) * STRIDE;
objTemp.box.b = (cy + boxTemp[3]) * STRIDE;
objTemp.score = score;
//get key point information
Landmark lanTemp;
for (int j = 0; j < 10; j++) {
const float *ptr = landmark.channel(j);
if (j < 5) {
float temp = (myExp(ptr[w * (cy - 1) + cx] * 4) + cx) * STRIDE;
lanTemp.x.push_back(temp);
} else {
float temp = (myExp(ptr[w * (cy - 1) + cx] * 4) + cy) * STRIDE;
lanTemp.y.push_back(temp);
}
}
objTemp.landmark = lanTemp;
objs.push_back(objTemp);
}
}
inline float DBFace::fast_exp(float x) {
union {
uint32_t i;
float f;
} v{};
v.i = (1 << 23) * (1.4426950409 * x + 126.93490512f);
return v.f;
}
inline float DBFace::myExp(float v) {
float gate = 1;
float base = exp(1);
if (abs(v) < gate) {
return v * base;
}
if (v > 0) {
return fast_exp(v);
} else {
return -fast_exp(-v);
}
}
cv::Mat DBFace::pad(cv::Mat img, int stride) {
bool hasChange = false;
int stdw = img.cols;
if (stdw % stride != 0) {
stdw += stride - (stdw % stride);
hasChange = true;
}
int stdh = img.rows;
if (stdh % stride != 0) {
stdh += stride - (stdh % stride);
hasChange = true;
}
if (hasChange) {
cv::Mat newImg = cv::Mat::zeros(stdh, stdw, CV_8UC3);
cv::Rect roi = cv::Rect(0, 0, img.cols, img.rows);
img.copyTo(newImg(roi));
return newImg;
}
return img;
}
std::vector<Obj> DBFace::nms(std::vector<Obj> objs, float iou) {
if (objs.size() == 0) {
return objs;
}
sort(objs.begin(), objs.end(), [](Obj a, Obj b) { return a.score < b.score; });
std::vector<Obj> keep;
int *flag = new int[objs.size()]();
for (int i = 0; i < objs.size(); i++) {
if (flag[i] != 0) {
continue;
}
keep.push_back(objs[i]);
for (int j = i + 1; j < objs.size(); j++) {
if (flag[j] == 0 && getIou(objs[i].box, objs[j].box) > iou) {
flag[j] = 1;
}
}
}
return keep;
}
float DBFace::getIou(Box a, Box b) {
float aArea = (a.r - a.x + 1) * (a.b - a.y + 1);
float bArea = (b.r - b.x + 1) * (b.b - b.y + 1);
float x1 = a.x > b.x ? a.x : b.x;
float y1 = a.y > b.y ? a.y : b.y;
float x2 = a.r < b.r ? a.r : b.r;
float y2 = a.b < b.b ? a.b : b.b;
float w = 0.0f > x2 - x1 + 1 ? 0.0f : x2 - x1 + 1;
float h = 0.0f > y2 - y1 + 1 ? 0.0f : x2 - x1 + 1;
float area = w * h;
float iou = area / (aArea + bArea - area);
return iou;
}

@ -0,0 +1,81 @@
//
// Created by WZTENG on 2020/09/14 014.
//
#ifndef YOLOV5_DBFACE_H
#define YOLOV5_DBFACE_H
#include "ncnn/net.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <opencv2/core/types.hpp>
#include "YoloV5.h"
struct Box {
float x, y, r, b;
};
struct Landmark {
std::vector<float> x;
std::vector<float> y;
};
struct Obj {
double score;
Box box;
Landmark landmark;
};
struct Id {
double score;
int idx;
int idy;
};
class DBFace {
public:
DBFace(AAssetManager *mgr, bool useGPU);
~DBFace();
std::vector<Obj> detect(JNIEnv *env, jobject image, double threshold, double nms_threshold);
private:
std::vector<Obj> nms(std::vector<Obj> objs, float iou = 0.5);
void genIds(ncnn::Mat hm, ncnn::Mat hmPool, int w, double thresh, std::vector<Id> &ids);
void decode(int w, std::vector<Id> ids, ncnn::Mat tlrb, ncnn::Mat landmark, std::vector<Obj> &objs);
cv::Mat pad(cv::Mat img, int stride = 32);
float getIou(Box a, Box b);
inline float fast_exp(float x);
inline float myExp(float v);
float THRESHOLD;
// float IOU;
float STRIDE = 4;
ncnn::Net *DBFaceNet;
public:
static DBFace *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV5_DBFACE_H

@ -0,0 +1,104 @@
//
// Created by WZTENG on 2020/08/28 028.
//
#include "ENet.h"
#include "SimplePose.h"
#include <android/log.h>
bool ENet::hasGPU = true;
bool ENet::toUseGPU = true;
ENet *ENet::detector = nullptr;
ENet::ENet(AAssetManager *mgr, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
ENetsim = new ncnn::Net();
// opt 需要在加载前设置
ENetsim->opt.use_vulkan_compute = toUseGPU; // gpu
ENetsim->opt.use_fp16_arithmetic = true; // fp16运算加速
ENetsim->load_param(mgr, "ENet_sim-opt.param");
ENetsim->load_model(mgr, "ENet_sim-opt.bin");
// LOGD("enet_detector");
}
ENet::~ENet() {
ENetsim->clear();
delete ENetsim;
}
ncnn::Mat ENet::detect_enet(JNIEnv *env, jobject image) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
ncnn::Mat in_net = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB, target_size_w,
target_size_h);
// float mean[3] = {0.0f, 0.0f, 0.0f};
// float norm[3] = {1.0 / 255.0f, 1.0 / 255.0f, 1.0 / 255.0f};
float mean[3] = {123.68f, 116.28f, 103.53f};
float norm[3] = {1.0 / 58.40f, 1.0 / 57.12f, 1.0 / 57.38f};
in_net.substract_mean_normalize(mean, norm);
ncnn::Mat maskout;
auto ex = ENetsim->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("input", in_net);
ex.extract("output", maskout);
int mask_c = maskout.c;
int mask_w = maskout.w;
int mask_h = maskout.h;
// LOGD("jni enet mask c:%d w:%d h:%d", mask_c, mask_w, mask_h);
cv::Mat prediction = cv::Mat::zeros(mask_h, mask_w, CV_8UC1);
ncnn::Mat chn[mask_c];
for (int i = 0; i < mask_c; i++) {
chn[i] = maskout.channel(i);
}
for (int i = 0; i < mask_h; i++) {
const float *pChn[mask_c];
for (int c = 0; c < mask_c; c++) {
pChn[c] = chn[c].row(i);
}
auto *pCowMask = prediction.ptr<uchar>(i);
for (int j = 0; j < mask_w; j++) {
int maxindex = 0;
float maxvalue = -1000;
for (int n = 0; n < mask_c; n++) {
if (pChn[n][j] > maxvalue) {
maxindex = n;
maxvalue = pChn[n][j];
}
}
pCowMask[j] = maxindex;
}
}
// ncnn::Mat maskMat;
// maskMat = ncnn::Mat::from_pixels(prediction.data, ncnn::Mat::PIXEL_GRAY, prediction.cols, prediction.rows);
cv::Mat pred_resize;
cv::resize(prediction, pred_resize, cv::Size(img_size.width, img_size.height), 0, 0, cv::INTER_NEAREST);
ncnn::Mat maskMat;
maskMat = ncnn::Mat::from_pixels_resize(pred_resize.data, ncnn::Mat::PIXEL_GRAY,
pred_resize.cols, pred_resize.rows,
img_size.width, img_size.height);
// LOGD("jni enet maskMat 0:%f", maskMat.channel(0).row(0)[0]);
// LOGD("jni enet maskMat end w:%d h:%d", maskMat.w, maskMat.h);
return maskMat;
}

@ -0,0 +1,37 @@
//
// Created by WZTENG on 2020/08/28 028.
//
#ifndef YOLOV5_ENET_H
#define YOLOV5_ENET_H
#include "ncnn/net.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <vector>
class ENet {
public:
ENet(AAssetManager *mgr, bool useGPU);
~ENet();
ncnn::Mat detect_enet(JNIEnv *env, jobject image);
private:
ncnn::Net *ENetsim;
int target_size_w = 512;
int target_size_h = 512;
public:
static ENet *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV5_ENET_H

@ -0,0 +1,170 @@
//
// Created by WZTENG on 2020/08/29 029.
//
#include "FaceLandmark.h"
#include "SimplePose.h"
bool FaceLandmark::hasGPU = true;
bool FaceLandmark::toUseGPU = true;
FaceLandmark *FaceLandmark::detector = nullptr;
FaceLandmark::FaceLandmark(AAssetManager *mgr, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
FaceNet = new ncnn::Net();
// opt 需要在加载前设置
FaceNet->opt.use_vulkan_compute = toUseGPU; // gpu
FaceNet->opt.use_fp16_arithmetic = true; // fp16运算加速
FaceNet->load_param(mgr, "yoloface-500k.param");
FaceNet->load_model(mgr, "yoloface-500k.bin");
// LOGD("face_detector");
LandmarkNet = new ncnn::Net();
LandmarkNet->opt.use_vulkan_compute = toUseGPU; // gpu
LandmarkNet->opt.use_fp16_arithmetic = true; // fp16运算加速
LandmarkNet->load_param(mgr, "landmark106.param");
LandmarkNet->load_model(mgr, "landmark106.bin");
// LOGD("landmark106");
}
FaceLandmark::~FaceLandmark() {
FaceNet->clear();
LandmarkNet->clear();
delete FaceNet;
delete LandmarkNet;
}
int FaceLandmark::runlandmark(cv::Mat &roi, int face_size_w, int face_size_h, std::vector<FaceKeyPoint> &keypoints,
float x1, float y1) {
int w = roi.cols;
int h = roi.rows;
ncnn::Mat in = ncnn::Mat::from_pixels_resize(roi.data, ncnn::Mat::PIXEL_BGR2RGB, \
roi.cols, roi.rows, face_size_w, face_size_h);
// LOGD("in w:%d h:%d", roi.cols, roi.rows);
//数据预处理
const float mean_vals[3] = {127.5f, 127.5f, 127.5f};
const float norm_vals[3] = {1 / 127.5f, 1 / 127.5f, 1 / 127.5f};
in.substract_mean_normalize(mean_vals, norm_vals);
auto ex = LandmarkNet->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("data", in);
ncnn::Mat out;
ex.extract("bn6_3_bn6_3_scale", out);
keypoints.clear();
// LOGD("pose out.c:%d", out.c);
float sw, sh;
sw = (float) w / (float) landmark_size_width;
sh = (float) h / (float) landmark_size_height;
for (int i = 0; i < 106; i++) {
float px, py;
px = out[i * 2] * landmark_size_width * sw + x1;
py = out[i * 2 + 1] * landmark_size_height * sh + y1;
FaceKeyPoint keypoint;
keypoint.p = cv::Point2f(px, py);
keypoints.push_back(keypoint);
}
return 0;
}
std::vector<FaceKeyPoint> FaceLandmark::detect(JNIEnv *env, jobject image) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
ncnn::Mat src_img = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB,
img_size.width, img_size.height);
int img_w = img_size.width;
int img_h = img_size.height;
/** ncnn::Mat -> cv::Mat **/
// https://github.com/Tencent/ncnn/wiki/use-ncnn-with-opencv#ncnn-to-opencv
// float norm[3] = {1 / 255.f, 1 / 255.f, 1 / 255.f};
// float mean[3] = {0, 0, 0};
// src_img.substract_mean_normalize(mean, norm);
cv::Mat bgr(src_img.h, src_img.w, CV_8UC3);
src_img.to_pixels(bgr.data, ncnn::Mat::PIXEL_RGB2BGR);
// LOGD("bgr w:%d h:%d", bgr.cols, bgr.rows);
ncnn::Mat in = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB,
detector_size_width, detector_size_height);
float norm[3] = {1 / 255.f, 1 / 255.f, 1 / 255.f};
float mean[3] = {0, 0, 0};
in.substract_mean_normalize(mean, norm);
auto ex = FaceNet->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("data", in);
ncnn::Mat out;
ex.extract("output", out);
// LOGD("person out.h:%d", out.h);
std::vector<FaceKeyPoint> keyPointList;
// std::vector<BoxInfo> boxInfoList;
for (int i = 0; i < out.h; i++) {
float x1, y1, x2, y2, score, label;
float pw, ph, cx, cy;
const float *values = out.row(i);
x1 = values[2] * img_w;
y1 = values[3] * img_h;
x2 = values[4] * img_w;
y2 = values[5] * img_h;
pw = x2 - x1;
ph = y2 - y1;
cx = x1 + 0.5 * pw;
cy = y1 + 0.5 * ph;
x1 = cx - 0.55 * pw;
y1 = cy - 0.35 * ph;
x2 = cx + 0.55 * pw;
y2 = cy + 0.55 * ph;
score = values[1];
label = values[0];
//处理坐标越界问题
if (x1 < 0) x1 = 0;
if (y1 < 0) y1 = 0;
if (x2 < 0) x2 = 0;
if (y2 < 0) y2 = 0;
if (x1 > img_w) x1 = img_w;
if (y1 > img_h) y1 = img_h;
if (x2 > img_w) x2 = img_w;
if (y2 > img_h) y2 = img_h;
//截取脸ROI
// LOGD("x1:%f y1:%f x2:%f y2:%f\n", x1, y1, x2, y2);
if (x2 - x1 > 66 && y2 - y1 > 66) {
cv::Mat roi = bgr(cv::Rect(x1, y1, x2 - x1, y2 - y1)).clone();
// LOGD("roi w:%d h:%d", roi.cols, roi.rows);
std::vector<FaceKeyPoint> keypoints;
runlandmark(roi, landmark_size_width, landmark_size_height, keypoints, x1, y1);
keyPointList.insert(keyPointList.begin(), keypoints.begin(), keypoints.end());
}
// BoxInfo box;
// box.x1 = x1;
// box.x2 = x2;
// box.y1 = y1;
// box.y2 = y2;
// box.label = label;
// box.score = score;
// boxInfoList.push_back(box);
}
// result.insert(result.begin(), boxes.begin(), boxes.end());
return keyPointList;
}

@ -0,0 +1,54 @@
//
// Created by WZTENG on 2020/08/29 029.
//
#ifndef YOLOV5_FACELANDMARK_H
#define YOLOV5_FACELANDMARK_H
#include "ncnn/net.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <opencv2/core/types.hpp>
#include <android/log.h>
struct FaceKeyPoint {
cv::Point2f p;
float prob;
};
class FaceLandmark {
public:
FaceLandmark(AAssetManager *mgr, bool useGPU);
~FaceLandmark();
std::vector<FaceKeyPoint> detect(JNIEnv *env, jobject image);
private:
int runlandmark(cv::Mat &roi, int pose_size_width, int pose_size_height,
std::vector<FaceKeyPoint> &keypoints,
float x1, float y1);
// static std::vector<FaceKeyPoint> decode_infer(ncnn::Mat &data, const cv::Size& frame_size, int net_size);
ncnn::Net *FaceNet;
ncnn::Net *LandmarkNet;
int detector_size_width = 320;
int detector_size_height = 256;
int landmark_size_width = 112;
int landmark_size_height = 112;
public:
static FaceLandmark *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV5_FACELANDMARK_H

@ -0,0 +1,508 @@
#include "LightOpenPose.h"
static const std::pair<int, int> limbIdsHeatmap[] = {
{1, 2}, {1, 5}, {2, 3}, {3, 4}, {5, 6},
{6, 7}, {1, 8}, {8, 9}, {9, 10}, {1, 11},
{11, 12}, {12, 13}, {1, 0}, {0, 14}, {14, 16},
{0, 15}, {15, 17}, {2, 16}, {5, 17}
};
static const std::pair<int, int> limbIdsPaf[] = {
{12, 13}, {20, 21}, {14, 15}, {16, 17}, {22, 23},
{24, 25}, {0, 1}, {2, 3}, {4, 5}, {6, 7},
{8, 9}, {10, 11}, {28, 29}, {30, 31}, {34, 35},
{32, 33}, {36, 37}, {18, 19}, {26, 27}
};
namespace human_pose_estimation {
HumanPose::HumanPose(const std::vector<cv::Point2f> &keypoints,
const float &score)
: keypoints(keypoints),
score(score) {
}
} // namespace human_pose_estimation
namespace human_pose_estimation {
Peak::Peak(const int id, const cv::Point2f &pos, const float score)
: id(id),
pos(pos),
score(score) {
}
HumanPoseByPeaksIndices::HumanPoseByPeaksIndices(const int keypointsNumber)
: peaksIndices(std::vector<int>(keypointsNumber, -1)),
nJoints(0),
score(0.0f) {
}
TwoJointsConnection::TwoJointsConnection(const int firstJointIdx,
const int secondJointIdx,
const float score)
: firstJointIdx(firstJointIdx),
secondJointIdx(secondJointIdx),
score(score) {
}
void findPeaks(const std::vector<cv::Mat> &heatMaps,
const float minPeaksDistance,
std::vector<std::vector<Peak> > &allPeaks,
int heatMapId) {
const float threshold = 0.1f;
std::vector<cv::Point> peaks;
const cv::Mat &heatMap = heatMaps[heatMapId];
const float *heatMapData = heatMap.ptr<float>();
size_t heatMapStep = heatMap.step1();
for (int y = -1; y < heatMap.rows + 1; y++) {
for (int x = -1; x < heatMap.cols + 1; x++) {
float val = 0;
if (x >= 0
&& y >= 0
&& x < heatMap.cols
&& y < heatMap.rows) {
val = heatMapData[y * heatMapStep + x];
val = val >= threshold ? val : 0;
}
float left_val = 0;
if (y >= 0
&& x < (heatMap.cols - 1)
&& y < heatMap.rows) {
left_val = heatMapData[y * heatMapStep + x + 1];
left_val = left_val >= threshold ? left_val : 0;
}
float right_val = 0;
if (x > 0
&& y >= 0
&& y < heatMap.rows) {
right_val = heatMapData[y * heatMapStep + x - 1];
right_val = right_val >= threshold ? right_val : 0;
}
float top_val = 0;
if (x >= 0
&& x < heatMap.cols
&& y < (heatMap.rows - 1)) {
top_val = heatMapData[(y + 1) * heatMapStep + x];
top_val = top_val >= threshold ? top_val : 0;
}
float bottom_val = 0;
if (x >= 0
&& y > 0
&& x < heatMap.cols) {
bottom_val = heatMapData[(y - 1) * heatMapStep + x];
bottom_val = bottom_val >= threshold ? bottom_val : 0;
}
if ((val > left_val)
&& (val > right_val)
&& (val > top_val)
&& (val > bottom_val)) {
peaks.push_back(cv::Point(x, y));
}
}
}
std::sort(peaks.begin(), peaks.end(), [](const cv::Point &a, const cv::Point &b) {
return a.x < b.x;
});
std::vector<bool> isActualPeak(peaks.size(), true);
int peakCounter = 0;
std::vector<Peak> &peaksWithScoreAndID = allPeaks[heatMapId];
for (size_t i = 0; i < peaks.size(); i++) {
if (isActualPeak[i]) {
for (size_t j = i + 1; j < peaks.size(); j++) {
if (sqrt((peaks[i].x - peaks[j].x) * (peaks[i].x - peaks[j].x) +
(peaks[i].y - peaks[j].y) * (peaks[i].y - peaks[j].y)) < minPeaksDistance) {
isActualPeak[j] = false;
}
}
peaksWithScoreAndID.push_back(Peak(peakCounter++, peaks[i], heatMap.at<float>(peaks[i])));
}
}
}
std::vector<HumanPose> groupPeaksToPoses(const std::vector<std::vector<Peak> > &allPeaks,
const std::vector<cv::Mat> &pafs,
const size_t keypointsNumber,
const float midPointsScoreThreshold,
const float foundMidPointsRatioThreshold,
const int minJointsNumber,
const float minSubsetScore) {
std::vector<Peak> candidates;
for (const auto &peaks : allPeaks) {
candidates.insert(candidates.end(), peaks.begin(), peaks.end());
}
std::vector<HumanPoseByPeaksIndices> subset(0, HumanPoseByPeaksIndices(keypointsNumber));
for (size_t k = 0; k < arraySize(limbIdsPaf); k++) {
std::vector<TwoJointsConnection> connections;
const int mapIdxOffset = 0; // keypointsNumber + 1;
std::pair<cv::Mat, cv::Mat> scoreMid = {pafs[limbIdsPaf[k].first - mapIdxOffset],
pafs[limbIdsPaf[k].second - mapIdxOffset]};
const int idxJointA = limbIdsHeatmap[k].first; // first - 1;
const int idxJointB = limbIdsHeatmap[k].second; // second - 1;
const std::vector<Peak> &candA = allPeaks[idxJointA];
const std::vector<Peak> &candB = allPeaks[idxJointB];
const size_t nJointsA = candA.size();
const size_t nJointsB = candB.size();
if (nJointsA == 0 && nJointsB == 0) {
continue;
} else if (nJointsA == 0) {
for (size_t i = 0; i < nJointsB; i++) {
int num = 0;
for (size_t j = 0; j < subset.size(); j++) {
if (subset[j].peaksIndices[idxJointB] == candB[i].id) {
num++;
continue;
}
}
if (num == 0) {
HumanPoseByPeaksIndices personKeypoints(keypointsNumber);
personKeypoints.peaksIndices[idxJointB] = candB[i].id;
personKeypoints.nJoints = 1;
personKeypoints.score = candB[i].score;
subset.push_back(personKeypoints);
}
}
continue;
} else if (nJointsB == 0) {
for (size_t i = 0; i < nJointsA; i++) {
int num = 0;
for (size_t j = 0; j < subset.size(); j++) {
if (subset[j].peaksIndices[idxJointA] == candA[i].id) {
num++;
continue;
}
}
if (num == 0) {
HumanPoseByPeaksIndices personKeypoints(keypointsNumber);
personKeypoints.peaksIndices[idxJointA] = candA[i].id;
personKeypoints.nJoints = 1;
personKeypoints.score = candA[i].score;
subset.push_back(personKeypoints);
}
}
continue;
}
std::vector<TwoJointsConnection> tempJointConnections;
for (size_t i = 0; i < nJointsA; i++) {
for (size_t j = 0; j < nJointsB; j++) {
cv::Point2f pt = candA[i].pos * 0.5 + candB[j].pos * 0.5;
cv::Point mid = cv::Point(cvRound(pt.x), cvRound(pt.y));
cv::Point2f vec = candB[j].pos - candA[i].pos;
double norm_vec = cv::norm(vec);
if (norm_vec == 0) {
continue;
}
vec /= norm_vec;
float score = vec.x * scoreMid.first.at<float>(mid) + vec.y * scoreMid.second.at<float>(mid);
int height_n = pafs[0].rows / 2;
float suc_ratio = 0.0f;
float mid_score = 0.0f;
const int mid_num = 10;
const float scoreThreshold = -100.0f;
if (score > scoreThreshold) {
float p_sum = 0;
int p_count = 0;
cv::Size2f step((candB[j].pos.x - candA[i].pos.x) / (mid_num - 1),
(candB[j].pos.y - candA[i].pos.y) / (mid_num - 1));
for (int n = 0; n < mid_num; n++) {
cv::Point midPoint(cvRound(candA[i].pos.x + n * step.width),
cvRound(candA[i].pos.y + n * step.height));
cv::Point2f pred(scoreMid.first.at<float>(midPoint),
scoreMid.second.at<float>(midPoint));
score = vec.x * pred.x + vec.y * pred.y;
if (score > midPointsScoreThreshold) {
p_sum += score;
p_count++;
}
}
suc_ratio = static_cast<float>(p_count / mid_num);
float ratio = p_count > 0 ? p_sum / p_count : 0.0f;
mid_score = ratio + static_cast<float>(std::min(height_n / norm_vec - 1, 0.0));
}
if (mid_score > 0
&& suc_ratio > foundMidPointsRatioThreshold) {
tempJointConnections.push_back(TwoJointsConnection(i, j, mid_score));
}
}
}
if (!tempJointConnections.empty()) {
std::sort(tempJointConnections.begin(), tempJointConnections.end(),
[](const TwoJointsConnection &a,
const TwoJointsConnection &b) {
return (a.score > b.score);
});
}
size_t num_limbs = std::min(nJointsA, nJointsB);
size_t cnt = 0;
std::vector<int> occurA(nJointsA, 0);
std::vector<int> occurB(nJointsB, 0);
for (size_t row = 0; row < tempJointConnections.size(); row++) {
if (cnt == num_limbs) {
break;
}
const int &indexA = tempJointConnections[row].firstJointIdx;
const int &indexB = tempJointConnections[row].secondJointIdx;
const float &score = tempJointConnections[row].score;
if (occurA[indexA] == 0
&& occurB[indexB] == 0) {
connections.push_back(TwoJointsConnection(candA[indexA].id, candB[indexB].id, score));
cnt++;
occurA[indexA] = 1;
occurB[indexB] = 1;
}
}
if (connections.empty()) {
continue;
}
bool extraJointConnections = (k == 17 || k == 18);
if (k == 0) {
subset = std::vector<HumanPoseByPeaksIndices>(
connections.size(), HumanPoseByPeaksIndices(keypointsNumber));
for (size_t i = 0; i < connections.size(); i++) {
const int &indexA = connections[i].firstJointIdx;
const int &indexB = connections[i].secondJointIdx;
subset[i].peaksIndices[idxJointA] = indexA;
subset[i].peaksIndices[idxJointB] = indexB;
subset[i].nJoints = 2;
subset[i].score = candidates[indexA].score + candidates[indexB].score + connections[i].score;
}
} else if (extraJointConnections) {
for (size_t i = 0; i < connections.size(); i++) {
const int &indexA = connections[i].firstJointIdx;
const int &indexB = connections[i].secondJointIdx;
for (size_t j = 0; j < subset.size(); j++) {
if (subset[j].peaksIndices[idxJointA] == indexA
&& subset[j].peaksIndices[idxJointB] == -1) {
subset[j].peaksIndices[idxJointB] = indexB;
} else if (subset[j].peaksIndices[idxJointB] == indexB
&& subset[j].peaksIndices[idxJointA] == -1) {
subset[j].peaksIndices[idxJointA] = indexA;
}
}
}
continue;
} else {
for (size_t i = 0; i < connections.size(); i++) {
const int &indexA = connections[i].firstJointIdx;
const int &indexB = connections[i].secondJointIdx;
bool num = false;
for (size_t j = 0; j < subset.size(); j++) {
if (subset[j].peaksIndices[idxJointA] == indexA) {
subset[j].peaksIndices[idxJointB] = indexB;
subset[j].nJoints++;
subset[j].score += candidates[indexB].score + connections[i].score;
num = true;
}
}
if (!num) {
HumanPoseByPeaksIndices hpWithScore(keypointsNumber);
hpWithScore.peaksIndices[idxJointA] = indexA;
hpWithScore.peaksIndices[idxJointB] = indexB;
hpWithScore.nJoints = 2;
hpWithScore.score = candidates[indexA].score + candidates[indexB].score + connections[i].score;
subset.push_back(hpWithScore);
}
}
}
}
std::vector<HumanPose> poses;
for (const auto &subsetI : subset) {
if (subsetI.nJoints < minJointsNumber || subsetI.score / subsetI.nJoints < minSubsetScore) {
continue;
}
int position = -1;
HumanPose pose(std::vector<cv::Point2f>(keypointsNumber, cv::Point2f(-1.0f, -1.0f)),
subsetI.score * std::max(0, subsetI.nJoints - 1));
for (const auto &peakIdx : subsetI.peaksIndices) {
position++;
if (peakIdx >= 0) {
pose.keypoints[position] = candidates[peakIdx].pos;
pose.keypoints[position].x += 0.5;
pose.keypoints[position].y += 0.5;
}
}
poses.push_back(pose);
}
return poses;
}
} // namespace human_pose_estimation
void postProcess(const ncnn::Mat &pafs, const ncnn::Mat &heatmaps, std::vector<human_pose_estimation::HumanPose> &poses,
int img_h, int img_w, int net_h, int net_w) {
using namespace human_pose_estimation;
float upsample_ratio = 4;
// ncnn::Mat -> cv::Mat
// heatmaps
std::vector<cv::Mat> cv_heatmaps(heatmaps.c);
for (int p = 0; p < heatmaps.c; p++) {
cv_heatmaps[p] = cv::Mat(heatmaps.h, heatmaps.w, CV_32FC1);
memcpy((float *) cv_heatmaps[p].data, heatmaps.channel(p), heatmaps.h * heatmaps.w * sizeof(float));
}
// LOGD("%-11s C:%llu H:%d W:%d\n", "cv_heatmaps", cv_heatmaps.size(), cv_heatmaps[0].rows, cv_heatmaps[0].cols);
if (cv_heatmaps.size() != heatmaps.c || cv_heatmaps[0].rows != heatmaps.h || cv_heatmaps[0].cols != heatmaps.w) {
LOGE("ncnn::Mat -> cv::Mat fail\n");
return;
}
if (heatmaps.channel(0).row(1)[2] != cv_heatmaps[0].ptr<float>(1)[2]) // c:0 h:1 w:2
{
LOGE("ncnn::Mat != cv::Mat\n");
return;
}
// upsample
std::vector<cv::Mat> cv_heatmaps_upsample(heatmaps.c);
for (int p = 0; p < heatmaps.c; p++) {
cv::resize(cv_heatmaps[p], cv_heatmaps_upsample[p],
cv::Size(), upsample_ratio, upsample_ratio, cv::INTER_CUBIC);
}
// ncnn::Mat -> cv::Mat
// pafs
std::vector<cv::Mat> cv_pafs(pafs.c);
for (int p = 0; p < pafs.c; p++) {
cv_pafs[p] = cv::Mat(pafs.h, pafs.w, CV_32FC1);
memcpy((float *) cv_pafs[p].data, pafs.channel(p), pafs.h * pafs.w * sizeof(float));
}
// LOGD("%-11s C:%llu H:%d W:%d\n", "cv_pafs", cv_pafs.size(), cv_pafs[0].rows, cv_pafs[0].cols);
if (cv_pafs.size() != pafs.c || cv_pafs[0].rows != pafs.h || cv_pafs[0].cols != pafs.w) {
LOGE("ncnn::Mat -> cv::Mat fail\n");
return;
}
if (pafs.channel(0).row(1)[2] != cv_pafs[0].ptr<float>(1)[2]) // c:0 h:1 w:2
{
LOGE("ncnn::Mat != cv::Mat\n");
return;
}
// upsample
std::vector<cv::Mat> cv_pafs_upsample(pafs.c);
for (int p = 0; p < pafs.c; p++) {
cv::resize(cv_pafs[p], cv_pafs_upsample[p],
cv::Size(), upsample_ratio, upsample_ratio, cv::INTER_CUBIC);
}
// postprocess
const float minPeaksDistance = 3.0f;
const int keypointsNumber = 18;
const float midPointsScoreThreshold = 0.05f;
const float foundMidPointsRatioThreshold = 0.8f;
const int minJointsNumber = 3;
const float minSubsetScore = 0.2f;
std::vector<std::vector<Peak> > peaksFromHeatMap(cv_heatmaps_upsample.size());
//#pragma omp parallel for
for (int i = 0; i < cv_heatmaps_upsample.size(); i++) {
findPeaks(cv_heatmaps_upsample, minPeaksDistance, peaksFromHeatMap, i);
}
int peaksBefore = 0;
for (size_t heatmapId = 1; heatmapId < cv_heatmaps_upsample.size(); heatmapId++) {
peaksBefore += static_cast<int>(peaksFromHeatMap[heatmapId - 1].size());
for (auto &peak : peaksFromHeatMap[heatmapId]) {
peak.id += peaksBefore;
}
}
// std::vector<HumanPose> poses;
poses = groupPeaksToPoses(
peaksFromHeatMap, cv_pafs_upsample, keypointsNumber, midPointsScoreThreshold,
foundMidPointsRatioThreshold, minJointsNumber, minSubsetScore);
// LOGD("human pose total:%llu\n", poses.size());
// scale keypoint
float scale_x = 1.0f * net_w / img_w;
float scale_y = 1.0f * net_h / img_h;
float stride = 8.0f;
float upsample = upsample_ratio;
for (int i = 0; i < poses.size(); i++) {
HumanPose pose = poses[i];
for (int j = 0; j < keypointsNumber; j++) {
if (pose.keypoints[j].x == -1 || pose.keypoints[j].y == -1) {
continue;
}
poses[i].keypoints[j].x = stride / upsample * pose.keypoints[j].x / scale_x;
poses[i].keypoints[j].y = stride / upsample * pose.keypoints[j].y / scale_y;
}
}
}
bool LightOpenPose::hasGPU = true;
bool LightOpenPose::toUseGPU = true;
LightOpenPose *LightOpenPose::detector = nullptr;
LightOpenPose::LightOpenPose(AAssetManager *mgr, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
humanPoseNet = new ncnn::Net();
// opt 需要在加载前设置
humanPoseNet->opt.use_vulkan_compute = toUseGPU; // gpu
humanPoseNet->opt.use_fp16_arithmetic = true; // fp16运算加速
humanPoseNet->opt.use_fp16_packed = true;
humanPoseNet->opt.use_fp16_storage = true;
humanPoseNet->load_param(mgr, "human_pose_sim_opt.param");
humanPoseNet->load_model(mgr, "human_pose_sim_opt.bin");
}
LightOpenPose::~LightOpenPose() {
humanPoseNet->clear();
delete humanPoseNet;
}
void LightOpenPose::preprocess(JNIEnv *env, jobject image, ncnn::Mat &in) {
in = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2BGR, input_size_w, input_size_h);
const float mean_vals[3] = {127.5f, 127.5f, 127.5f};
const float norm_vals[3] = {1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f};
in.substract_mean_normalize(mean_vals, norm_vals);
}
std::vector<human_pose_estimation::HumanPose> LightOpenPose::detect(JNIEnv *env, jobject image) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
int img_w = img_size.width;
int img_h = img_size.height;
int net_w = 456;
int net_h = 456;
int w = img_w;
int h = img_h;
float scale = 1.0f;
if (w > h) {
scale = (float) net_w / w;
w = net_w;
h = h * scale;
} else {
scale = (float) net_h / h;
h = net_h;
w = w * scale;
}
net_w = w;
net_h = h;
input_size_w = w;
input_size_h = h;
ncnn::Mat in;
preprocess(env, image, in);
// forward
ncnn::Mat pafs;
ncnn::Mat heatmaps;
ncnn::Extractor ex = humanPoseNet->create_extractor();
ex.input("data", in);
ex.extract("stage_1_output_1_heatmaps", heatmaps); // or stage_0_output_1_heatmaps
ex.extract("stage_1_output_0_pafs", pafs); // or stage_0_output_0_pafs
// postprocess
std::vector<human_pose_estimation::HumanPose> poses;
postProcess(pafs, heatmaps, poses, img_h, img_w, net_h, net_w);
return poses;
}

@ -0,0 +1,106 @@
#ifndef LIGHT_OPENPOSE_H
#define LIGHT_OPENPOSE_H
#include "ncnn/net.h"
#include "YoloV5.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <vector>
#include <android/log.h>
#ifndef LOG_TAG
#define LOG_TAG "WZT_NCNN"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG ,__VA_ARGS__) // 定义LOGD类型
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG ,__VA_ARGS__) // 定义LOGI类型
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG ,__VA_ARGS__) // 定义LOGW类型
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG ,__VA_ARGS__) // 定义LOGE类型
#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,LOG_TAG ,__VA_ARGS__) // 定义LOGF类型
#endif
template<typename T, std::size_t N>
constexpr std::size_t arraySize(const T (&)[N]) noexcept {
return N;
}
// .h
namespace human_pose_estimation {
struct HumanPose {
HumanPose(const std::vector<cv::Point2f> &keypoints = std::vector<cv::Point2f>(),
const float &score = 0);
std::vector<cv::Point2f> keypoints;
float score;
};
} // namespace human_pose_estimation
namespace human_pose_estimation {
struct Peak {
Peak(const int id = -1,
const cv::Point2f &pos = cv::Point2f(),
const float score = 0.0f);
int id;
cv::Point2f pos;
float score;
};
struct HumanPoseByPeaksIndices {
explicit HumanPoseByPeaksIndices(const int keypointsNumber);
std::vector<int> peaksIndices;
int nJoints;
float score;
};
struct TwoJointsConnection {
TwoJointsConnection(const int firstJointIdx,
const int secondJointIdx,
const float score);
int firstJointIdx;
int secondJointIdx;
float score;
};
void findPeaks(const std::vector<cv::Mat> &heatMaps,
const float minPeaksDistance,
std::vector<std::vector<Peak> > &allPeaks,
int heatMapId);
std::vector<HumanPose> groupPeaksToPoses(
const std::vector<std::vector<Peak> > &allPeaks,
const std::vector<cv::Mat> &pafs,
const size_t keypointsNumber,
const float midPointsScoreThreshold,
const float foundMidPointsRatioThreshold,
const int minJointsNumber,
const float minSubsetScore);
} // namespace human_pose_estimation
class LightOpenPose {
public:
LightOpenPose(AAssetManager *mgr, bool useGPU);
~LightOpenPose();
std::vector<human_pose_estimation::HumanPose> detect(JNIEnv *env, jobject image);
private:
void preprocess(JNIEnv *env, jobject image, ncnn::Mat &in);
ncnn::Net *humanPoseNet;
int input_size_w = 456;
int input_size_h = 256;
public:
static LightOpenPose *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //LIGHT_OPENPOSE_H

@ -0,0 +1,102 @@
//
// Created by WZTENG on 2020/09/21 028.
//
#include "MbnFCN.h"
#include "SimplePose.h"
#include <android/log.h>
bool MbnFCN::hasGPU = true;
bool MbnFCN::toUseGPU = true;
MbnFCN *MbnFCN::detector = nullptr;
MbnFCN::MbnFCN(AAssetManager *mgr, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
MBNFCNsim = new ncnn::Net();
// opt 需要在加载前设置
MBNFCNsim->opt.use_vulkan_compute = toUseGPU; // gpu
MBNFCNsim->opt.use_fp16_arithmetic = true; // fp16运算加速
MBNFCNsim->load_param(mgr, "fcn_mbv2-sim-opt.param");
MBNFCNsim->load_model(mgr, "fcn_mbv2-sim-opt.bin");
// LOGD("mbnfcn_detector");
}
MbnFCN::~MbnFCN() {
MBNFCNsim->clear();
delete MBNFCNsim;
}
ncnn::Mat MbnFCN::detect_mbnfcn(JNIEnv *env, jobject image) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
ncnn::Mat in_net = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB, target_size_w,
target_size_h);
float mean[3] = {123.68f, 116.28f, 103.53f};
float norm[3] = {1.0 / 58.40f, 1.0 / 57.12f, 1.0 / 57.38f};
in_net.substract_mean_normalize(mean, norm);
ncnn::Mat maskout;
auto ex = MBNFCNsim->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("input.1", in_net);
ex.extract("581", maskout);
int mask_c = maskout.c;
int mask_w = maskout.w;
int mask_h = maskout.h;
// LOGD("jni fcn mask c:%d w:%d h:%d", mask_c, mask_w, mask_h);
cv::Mat prediction = cv::Mat::zeros(mask_h, mask_w, CV_8UC1);
ncnn::Mat chn[mask_c];
for (int i = 0; i < mask_c; i++) {
chn[i] = maskout.channel(i);
}
for (int i = 0; i < mask_h; i++) {
const float *pChn[mask_c];
for (int c = 0; c < mask_c; c++) {
pChn[c] = chn[c].row(i);
}
auto *pCowMask = prediction.ptr<uchar>(i);
for (int j = 0; j < mask_w; j++) {
int maxindex = -1;
float maxvalue = -100.0f;
for (int n = 0; n < mask_c; n++) {
if (pChn[n][j] > maxvalue) {
maxindex = n;
maxvalue = pChn[n][j];
}
}
pCowMask[j] = maxindex;
}
}
// ncnn::Mat maskMat;
// maskMat = ncnn::Mat::from_pixels(prediction.data, ncnn::Mat::PIXEL_GRAY, prediction.cols, prediction.rows);
cv::Mat pred_resize;
cv::resize(prediction, pred_resize, cv::Size(img_size.width, img_size.height), 0, 0, cv::INTER_NEAREST);
ncnn::Mat maskMat;
maskMat = ncnn::Mat::from_pixels_resize(pred_resize.data, ncnn::Mat::PIXEL_GRAY,
pred_resize.cols, pred_resize.rows,
img_size.width, img_size.height);
// LOGD("jni fcn maskMat 0:%f", maskMat.channel(0).row(0)[0]);
// LOGD("jni fcn maskMat end w:%d h:%d", maskMat.w, maskMat.h);
return maskMat;
}

@ -0,0 +1,37 @@
//
// Created by WZTENG on 2020/09/21 028.
//
#ifndef YOLOV5_MBNFCN_H
#define YOLOV5_MBNFCN_H
#include "ncnn/net.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <vector>
class MbnFCN {
public:
MbnFCN(AAssetManager *mgr, bool useGPU);
~MbnFCN();
ncnn::Mat detect_mbnfcn(JNIEnv *env, jobject image);
private:
ncnn::Net *MBNFCNsim;
int target_size_w = 512;
int target_size_h = 512;
public:
static MbnFCN *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV5_MBNFCN_H

@ -0,0 +1,105 @@
//
// Created by WZTENG on 2020/09/24 028.
//
#include "MobileNetV3Seg.h"
#include "SimplePose.h"
#include <android/log.h>
bool MBNV3Seg::hasGPU = true;
bool MBNV3Seg::toUseGPU = true;
MBNV3Seg *MBNV3Seg::detector = nullptr;
MBNV3Seg::MBNV3Seg(AAssetManager *mgr, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
MBNSegsim = new ncnn::Net();
// opt 需要在加载前设置
MBNSegsim->opt.use_vulkan_compute = toUseGPU; // gpu
MBNSegsim->opt.use_fp16_arithmetic = true; // fp16运算加速
MBNSegsim->load_param(mgr, "mbnv3_small.param");
MBNSegsim->load_model(mgr, "mbnv3_small.bin");
// LOGD("mbnv3seg_detector");
}
MBNV3Seg::~MBNV3Seg() {
MBNSegsim->clear();
delete MBNSegsim;
}
ncnn::Mat MBNV3Seg::detect_mbnseg(JNIEnv *env, jobject image) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
ncnn::Mat in_net = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB, target_size_w,
target_size_h);
// LOGD("info format RGBA ? %d", img_size.format == ANDROID_BITMAP_FORMAT_RGBA_8888);
// float mean[3] = {0.0f, 0.0f, 0.0f};
// float norm[3] = {1.0 / 255.0f, 1.0 / 255.0f, 1.0 / 255.0f};
float mean[3] = {123.68f, 116.28f, 103.53f};
float norm[3] = {1.0 / 58.40f, 1.0 / 57.12f, 1.0 / 57.38f};
in_net.substract_mean_normalize(mean, norm);
ncnn::Mat maskout;
auto ex = MBNSegsim->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("input", in_net);
ex.extract("output", maskout);
int mask_c = maskout.c;
int mask_w = maskout.w;
int mask_h = maskout.h;
// LOGD("jni mbnv3seg mask c:%d w:%d h:%d", mask_c, mask_w, mask_h);
cv::Mat prediction = cv::Mat::zeros(mask_h, mask_w, CV_8UC1);
ncnn::Mat chn[mask_c];
for (int i = 0; i < mask_c; i++) {
chn[i] = maskout.channel(i);
}
for (int i = 0; i < mask_h; i++) {
const float *pChn[mask_c];
for (int c = 0; c < mask_c; c++) {
pChn[c] = chn[c].row(i);
}
auto *pCowMask = prediction.ptr<uchar>(i);
for (int j = 0; j < mask_w; j++) {
int maxindex = 0;
float maxvalue = -1000;
for (int n = 0; n < mask_c; n++) {
if (pChn[n][j] > maxvalue) {
maxindex = n;
maxvalue = pChn[n][j];
}
}
pCowMask[j] = maxindex;
}
}
// ncnn::Mat maskMat;
// maskMat = ncnn::Mat::from_pixels(prediction.data, ncnn::Mat::PIXEL_GRAY, prediction.cols, prediction.rows);
cv::Mat pred_resize;
cv::resize(prediction, pred_resize, cv::Size(img_size.width, img_size.height), 0, 0, cv::INTER_NEAREST);
ncnn::Mat maskMat;
maskMat = ncnn::Mat::from_pixels_resize(pred_resize.data, ncnn::Mat::PIXEL_GRAY,
pred_resize.cols, pred_resize.rows,
img_size.width, img_size.height);
// LOGD("jni mbnv3seg maskMat 0:%f", maskMat.channel(0).row(0)[0]);
// LOGD("jni mbnv3seg maskMat end w:%d h:%d", maskMat.w, maskMat.h);
return maskMat;
}

@ -0,0 +1,37 @@
//
// Created by WZTENG on 2020/09/24 028.
//
#ifndef YOLOV5_MOBILENETV3SEG_H
#define YOLOV5_MOBILENETV3SEG_H
#include "ncnn/net.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <vector>
class MBNV3Seg {
public:
MBNV3Seg(AAssetManager *mgr, bool useGPU);
~MBNV3Seg();
ncnn::Mat detect_mbnseg(JNIEnv *env, jobject image);
private:
ncnn::Net *MBNSegsim;
int target_size_w = 512;
int target_size_h = 512;
public:
static MBNV3Seg *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV5_MOBILENETV3SEG_H

@ -0,0 +1,188 @@
#include "NanoDet.h"
bool NanoDet::hasGPU = true;
bool NanoDet::toUseGPU = true;
NanoDet *NanoDet::detector = nullptr;
inline float fast_exp(float x) {
union {
uint32_t i;
float f;
} v{};
v.i = (1 << 23) * (1.4426950409 * x + 126.93490512f);
return v.f;
}
inline float sigmoid(float x) {
return 1.0f / (1.0f + fast_exp(-x));
}
template<typename _Tp>
int activation_function_softmax(const _Tp *src, _Tp *dst, int length) {
const _Tp alpha = *std::max_element(src, src + length);
_Tp denominator{0};
for (int i = 0; i < length; ++i) {
dst[i] = fast_exp(src[i] - alpha);
denominator += dst[i];
}
for (int i = 0; i < length; ++i) {
dst[i] /= denominator;
}
return 0;
}
NanoDet::NanoDet(AAssetManager *mgr, const char *param, const char *bin, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
Net = new ncnn::Net();
// opt 需要在加载前设置
Net->opt.use_vulkan_compute = toUseGPU; // gpu
Net->opt.use_fp16_arithmetic = true; // fp16运算加速
Net->opt.use_fp16_packed = true;
Net->opt.use_fp16_storage = true;
Net->load_param(mgr, param);
Net->load_model(mgr, bin);
}
NanoDet::~NanoDet() {
Net->clear();
delete Net;
}
void NanoDet::preprocess(JNIEnv *env, jobject image, ncnn::Mat &in) {
in = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2BGR, input_size, input_size);
// in = ncnn::Mat::from_pixels(image.data, ncnn::Mat::PIXEL_BGR, img_w, img_h);
//in = ncnn::Mat::from_pixels_resize(image.data, ncnn::Mat::PIXEL_BGR, img_w, img_h, this->input_width, this->input_height);
const float mean_vals[3] = {103.53f, 116.28f, 123.675f};
const float norm_vals[3] = {0.017429f, 0.017507f, 0.01712475};
in.substract_mean_normalize(mean_vals, norm_vals);
}
std::vector<BoxInfo> NanoDet::detect(JNIEnv *env, jobject image, float score_threshold, float nms_threshold) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
float width_ratio = (float) img_size.width / (float) input_size;
float height_ratio = (float) img_size.height / (float) input_size;
ncnn::Mat input;
preprocess(env, image, input);
auto ex = Net->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("input.1", input);
std::vector<std::vector<BoxInfo>> results;
results.resize(this->num_class);
for (const auto &head_info : this->heads_info) {
ncnn::Mat dis_pred;
ncnn::Mat cls_pred;
ex.extract(head_info.dis_layer.c_str(), dis_pred);
ex.extract(head_info.cls_layer.c_str(), cls_pred);
decode_infer(cls_pred, dis_pred, head_info.stride, score_threshold, results, width_ratio, height_ratio);
}
std::vector<BoxInfo> dets;
for (int i = 0; i < (int) results.size(); i++) {
nms(results[i], nms_threshold);
for (auto box : results[i]) {
dets.push_back(box);
}
}
return dets;
}
void NanoDet::decode_infer(ncnn::Mat &cls_pred, ncnn::Mat &dis_pred, int stride, float threshold,
std::vector<std::vector<BoxInfo>> &results, float width_ratio, float height_ratio) {
int feature_h = input_size / stride;
int feature_w = input_size / stride;
//cv::Mat debug_heatmap = cv::Mat(feature_h, feature_w, CV_8UC3);
for (int idx = 0; idx < feature_h * feature_w; idx++) {
const float *scores = cls_pred.row(idx);
int row = idx / feature_w;
int col = idx % feature_w;
float score = 0;
int cur_label = 0;
for (int label = 0; label < num_class; label++) {
if (scores[label] > score) {
score = scores[label];
cur_label = label;
}
}
if (score > threshold) {
//std::cout << "label:" << cur_label << " score:" << score << std::endl;
const float *bbox_pred = dis_pred.row(idx);
results[cur_label].push_back(
this->disPred2Bbox(bbox_pred, cur_label, score, col, row, stride, width_ratio, height_ratio));
//debug_heatmap.at<cv::Vec3b>(row, col)[0] = 255;
//cv::imshow("debug", debug_heatmap);
}
}
}
BoxInfo NanoDet::disPred2Bbox(const float *&dfl_det, int label, float score, int x, int y, int stride, float width_ratio,
float height_ratio) {
float ct_x = (x + 0.5) * stride;
float ct_y = (y + 0.5) * stride;
std::vector<float> dis_pred;
dis_pred.resize(4);
for (int i = 0; i < 4; i++) {
float dis = 0;
float *dis_after_sm = new float[reg_max + 1];
activation_function_softmax(dfl_det + i * (reg_max + 1), dis_after_sm, reg_max + 1);
for (int j = 0; j < reg_max + 1; j++) {
dis += j * dis_after_sm[j];
}
dis *= stride;
//std::cout << "dis:" << dis << std::endl;
dis_pred[i] = dis;
delete[] dis_after_sm;
}
float xmin = (std::max)(ct_x - dis_pred[0], .0f) * width_ratio;
float ymin = (std::max)(ct_y - dis_pred[1], .0f) * height_ratio;
float xmax = (std::min)(ct_x + dis_pred[2], (float) input_size) * width_ratio;
float ymax = (std::min)(ct_y + dis_pred[3], (float) input_size) * height_ratio;
//std::cout << xmin << "," << ymin << "," << xmax << "," << xmax << "," << std::endl;
return BoxInfo{xmin, ymin, xmax, ymax, score, label};
}
void NanoDet::nms(std::vector<BoxInfo> &input_boxes, float NMS_THRESH) {
std::sort(input_boxes.begin(), input_boxes.end(), [](BoxInfo a, BoxInfo b) { return a.score > b.score; });
std::vector<float> vArea(input_boxes.size());
for (int i = 0; i < int(input_boxes.size()); ++i) {
vArea[i] = (input_boxes.at(i).x2 - input_boxes.at(i).x1 + 1)
* (input_boxes.at(i).y2 - input_boxes.at(i).y1 + 1);
}
for (int i = 0; i < int(input_boxes.size()); ++i) {
for (int j = i + 1; j < int(input_boxes.size());) {
float xx1 = (std::max)(input_boxes[i].x1, input_boxes[j].x1);
float yy1 = (std::max)(input_boxes[i].y1, input_boxes[j].y1);
float xx2 = (std::min)(input_boxes[i].x2, input_boxes[j].x2);
float yy2 = (std::min)(input_boxes[i].y2, input_boxes[j].y2);
float w = (std::max)(float(0), xx2 - xx1 + 1);
float h = (std::max)(float(0), yy2 - yy1 + 1);
float inter = w * h;
float ovr = inter / (vArea[i] + vArea[j] - inter);
if (ovr >= NMS_THRESH) {
input_boxes.erase(input_boxes.begin() + j);
vArea.erase(vArea.begin() + j);
} else {
j++;
}
}
}
}

@ -0,0 +1,60 @@
#ifndef NANODET_H
#define NANODET_H
#include "ncnn/net.h"
#include "YoloV5.h"
typedef struct HeadInfo {
std::string cls_layer;
std::string dis_layer;
int stride;
};
class NanoDet {
public:
NanoDet(AAssetManager *mgr, const char *param, const char *bin, bool useGPU);
~NanoDet();
std::vector<BoxInfo> detect(JNIEnv *env, jobject image, float score_threshold, float nms_threshold);
std::vector<std::string> labels{"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
"microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
"hair drier", "toothbrush"};
private:
void preprocess(JNIEnv *env, jobject image, ncnn::Mat &in);
void decode_infer(ncnn::Mat &cls_pred, ncnn::Mat &dis_pred, int stride, float threshold,
std::vector<std::vector<BoxInfo>> &results, float width_ratio, float height_ratio);
BoxInfo disPred2Bbox(const float *&dfl_det, int label, float score, int x, int y, int stride, float width_ratio,
float height_ratio);
static void nms(std::vector<BoxInfo> &result, float nms_threshold);
ncnn::Net *Net;
int input_size = 320;
int num_class = 80;
int reg_max = 7;
std::vector<HeadInfo> heads_info{
// cls_pred|dis_pred|stride
{"792", "795", 8},
{"814", "817", 16},
{"836", "839", 32},
};
public:
static NanoDet *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //NANODET_H

@ -0,0 +1,198 @@
//
// Created by WZTENG on 2020/08/17 017.
//
#include "SimplePose.h"
#include "YoloV5.h"
bool SimplePose::hasGPU = true;
bool SimplePose::toUseGPU = true;
SimplePose *SimplePose::detector = nullptr;
SimplePose::SimplePose(AAssetManager *mgr, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
PersonNet = new ncnn::Net();
// opt 需要在加载前设置
PersonNet->opt.use_vulkan_compute = toUseGPU; // gpu
PersonNet->opt.use_fp16_arithmetic = true; // fp16运算加速
PersonNet->load_param(mgr, "person_detector.param");
PersonNet->load_model(mgr, "person_detector.bin");
// LOGD("person_detector");
PoseNet = new ncnn::Net();
PoseNet->opt.use_vulkan_compute = toUseGPU; // gpu
PoseNet->opt.use_fp16_arithmetic = true; // fp16运算加速
PoseNet->load_param(mgr, "Ultralight-Nano-SimplePose.param");
PoseNet->load_model(mgr, "Ultralight-Nano-SimplePose.bin");
// LOGD("ultralight-nano-simplepose");
}
SimplePose::~SimplePose() {
PersonNet->clear();
PoseNet->clear();
delete PersonNet;
delete PoseNet;
}
int SimplePose::runpose(cv::Mat &roi, int pose_size_w, int pose_size_h, std::vector<KeyPoint> &keypoints,
float x1, float y1) {
int w = roi.cols;
int h = roi.rows;
ncnn::Mat in = ncnn::Mat::from_pixels_resize(roi.data, ncnn::Mat::PIXEL_BGR2RGB, \
roi.cols, roi.rows, pose_size_w, pose_size_h);
// LOGD("in w:%d h:%d", roi.cols, roi.rows);
//数据预处理
const float mean_vals[3] = {0.485f * 255.f, 0.456f * 255.f, 0.406f * 255.f};
const float norm_vals[3] = {1 / 0.229f / 255.f, 1 / 0.224f / 255.f, 1 / 0.225f / 255.f};
in.substract_mean_normalize(mean_vals, norm_vals);
auto ex = PoseNet->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("data", in);
ncnn::Mat out;
ex.extract("hybridsequential0_conv7_fwd", out);
keypoints.clear();
// LOGD("pose out.c:%d", out.c);
for (int p = 0; p < out.c; p++) {
const ncnn::Mat m = out.channel(p);
float max_prob = 0.f;
int max_x = 0;
int max_y = 0;
for (int y = 0; y < out.h; y++) {
const float *ptr = m.row(y);
for (int x = 0; x < out.w; x++) {
float prob = ptr[x];
if (prob > max_prob) {
max_prob = prob;
max_x = x;
max_y = y;
}
}
}
KeyPoint keypoint;
keypoint.p = cv::Point2f(max_x * w / (float) out.w + x1, max_y * h / (float) out.h + y1);
keypoint.prob = max_prob;
keypoints.push_back(keypoint);
}
return 0;
}
std::vector<PoseResult> SimplePose::detect(JNIEnv *env, jobject image) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
ncnn::Mat src_img = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB,
img_size.width, img_size.height);
int img_w = img_size.width;
int img_h = img_size.height;
/** ncnn::Mat -> cv::Mat **/
// cv::Mat bgr(src_img.h, src_img.w, CV_8UC3);
// for (int c = 0; c < 3; c++) {
// for (int i = 0; i < src_img.h; i++) {
// for (int j = 0; j < src_img.w; j++) {
// float t = ((float *) src_img.data)[j + i * src_img.w + c * src_img.h * src_img.w];
// bgr.data[(2 - c) + j * 3 + i * src_img.w * 3] = t;
// }
// }
// }
// https://github.com/Tencent/ncnn/wiki/use-ncnn-with-opencv#ncnn-to-opencv
// float norm[3] = {1 / 255.f, 1 / 255.f, 1 / 255.f};
// float mean[3] = {0, 0, 0};
// src_img.substract_mean_normalize(mean, norm);
cv::Mat bgr(src_img.h, src_img.w, CV_8UC3);
src_img.to_pixels(bgr.data, ncnn::Mat::PIXEL_RGB2BGR);
// LOGD("bgr w:%d h:%d", bgr.cols, bgr.rows);
ncnn::Mat in = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB,
detector_size_width, detector_size_height);
float norm[3] = {1 / 255.f, 1 / 255.f, 1 / 255.f};
float mean[3] = {0, 0, 0};
in.substract_mean_normalize(mean, norm);
auto ex = PersonNet->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("data", in);
ncnn::Mat out;
ex.extract("output", out);
// LOGD("person out.h:%d", out.h);
std::vector<PoseResult> poseResults;
// std::vector<KeyPoint> keyPointList;
// std::vector<BoxInfo> boxInfoList;
for (int i = 0; i < out.h; i++) {
float x1, y1, x2, y2, score, label;
float pw, ph, cx, cy;
const float *values = out.row(i);
x1 = values[2] * img_w;
y1 = values[3] * img_h;
x2 = values[4] * img_w;
y2 = values[5] * img_h;
pw = x2 - x1;
ph = y2 - y1;
cx = x1 + 0.5 * pw;
cy = y1 + 0.5 * ph;
x1 = cx - 0.7 * pw;
y1 = cy - 0.6 * ph;
x2 = cx + 0.7 * pw;
y2 = cy + 0.6 * ph;
score = values[1];
label = values[0];
//处理坐标越界问题
if (x1 < 0) x1 = 0;
if (y1 < 0) y1 = 0;
if (x2 < 0) x2 = 0;
if (y2 < 0) y2 = 0;
if (x1 > img_w) x1 = img_w;
if (y1 > img_h) y1 = img_h;
if (x2 > img_w) x2 = img_w;
if (y2 > img_h) y2 = img_h;
//截取人体ROI
// LOGD("x1:%f y1:%f x2:%f y2:%f\n", x1, y1, x2, y2);
cv::Mat roi = bgr(cv::Rect(x1, y1, x2 - x1, y2 - y1)).clone();
// LOGD("roi w:%d h:%d", roi.cols, roi.rows);
std::vector<KeyPoint> keypoints;
runpose(roi, pose_size_width, pose_size_height, keypoints, x1, y1);
// draw_pose(image, keypoints);
// keyPointList.insert(keyPointList.begin(), keypoints.begin(), keypoints.end());
BoxInfo box;
box.x1 = x1;
box.x2 = x2;
box.y1 = y1;
box.y2 = y2;
box.label = label;
box.score = score;
// boxInfoList.push_back(box);
PoseResult poseResult;
poseResult.keyPoints = keypoints;
poseResult.boxInfos = box;
poseResults.push_back(poseResult);
}
// result.insert(result.begin(), boxes.begin(), boxes.end());
// return keyPointList;
return poseResults;
}

@ -0,0 +1,70 @@
//
// Created by WZTENG on 2020/08/17 017.
//
#ifndef YOLOV5_SIMPLEPOSE_H
#define YOLOV5_SIMPLEPOSE_H
#include "ncnn/net.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <opencv2/core/types.hpp>
#include "YoloV5.h"
#include <android/log.h>
#ifndef LOG_TAG
#define LOG_TAG "WZT_NCNN"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG ,__VA_ARGS__) // 定义LOGD类型
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG ,__VA_ARGS__) // 定义LOGI类型
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG ,__VA_ARGS__) // 定义LOGW类型
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG ,__VA_ARGS__) // 定义LOGE类型
#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,LOG_TAG ,__VA_ARGS__) // 定义LOGF类型
#endif
struct KeyPoint {
cv::Point2f p;
float prob;
};
struct PoseResult {
std::vector<KeyPoint> keyPoints;
BoxInfo boxInfos;
};
class SimplePose {
public:
SimplePose(AAssetManager *mgr, bool useGPU);
~SimplePose();
std::vector<PoseResult> detect(JNIEnv *env, jobject image);
private:
int runpose(cv::Mat &roi, int pose_size_width, int pose_size_height,
std::vector<KeyPoint> &keypoints,
float x1, float y1);
// static std::vector<KeyPoint> decode_infer(ncnn::Mat &data, const cv::Size& frame_size, int net_size);
ncnn::Net *PersonNet;
ncnn::Net *PoseNet;
int detector_size_width = 320;
int detector_size_height = 320;
int pose_size_width = 192;
int pose_size_height = 256;
public:
static SimplePose *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV5_SIMPLEPOSE_H

@ -0,0 +1,449 @@
//
// Created by WZTENG on 2020/08/19 019.
// from nihui
//
#include "Yolact.h"
#include "SimplePose.h"
#include <android/log.h>
// original model converted from https://github.com/dbolya/yolact
// yolact_resnet50_54_800000.pth
// the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
// 大佬模型分析:https://zhuanlan.zhihu.com/p/128974102
bool Yolact::hasGPU = true;
bool Yolact::toUseGPU = true;
Yolact *Yolact::detector = nullptr;
Yolact::Yolact(AAssetManager *mgr, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
YolactNet = new ncnn::Net();
// opt 需要在加载前设置
YolactNet->opt.use_vulkan_compute = toUseGPU; // gpu
YolactNet->opt.use_fp16_arithmetic = true; // fp16运算加速
YolactNet->load_param(mgr, "yolact.param");
YolactNet->load_model(mgr, "yolact.bin");
// LOGD("yolact_detector");
}
Yolact::~Yolact() {
YolactNet->clear();
delete YolactNet;
}
static inline float intersection_area(const Object &a, const Object &b) {
cv::Rect_<float> inter = a.rect & b.rect;
return inter.area();
}
static void qsort_descent_inplace(std::vector<Object> &objects, int left, int right) {
int i = left;
int j = right;
float p = objects[(left + right) / 2].prob;
while (i <= j) {
while (objects[i].prob > p)
i++;
while (objects[j].prob < p)
j--;
if (i <= j) {
// swap
std::swap(objects[i], objects[j]);
i++;
j--;
}
}
#pragma omp parallel sections
{
#pragma omp section
{
if (left < j) qsort_descent_inplace(objects, left, j);
}
#pragma omp section
{
if (i < right) qsort_descent_inplace(objects, i, right);
}
}
}
static void qsort_descent_inplace(std::vector<Object> &objects) {
if (objects.empty())
return;
qsort_descent_inplace(objects, 0, objects.size() - 1);
}
static void nms_sorted_bboxes(const std::vector<Object> &objects, std::vector<int> &picked, float nms_threshold) {
picked.clear();
const int n = objects.size();
std::vector<float> areas(n);
for (int i = 0; i < n; i++) {
areas[i] = objects[i].rect.area();
}
for (int i = 0; i < n; i++) {
const Object &a = objects[i];
int keep = 1;
for (int j = 0; j < (int) picked.size(); j++) {
const Object &b = objects[picked[j]];
// intersection over union
float inter_area = intersection_area(a, b);
float union_area = areas[i] + areas[picked[j]] - inter_area;
// float IoU = inter_area / union_area
if (inter_area / union_area > nms_threshold)
keep = 0;
}
if (keep)
picked.push_back(i);
}
}
std::vector<Object> Yolact::detect_yolact(JNIEnv *env, jobject image) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
ncnn::Mat src_img = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB,
img_size.width, img_size.height);
int img_w = img_size.width;
int img_h = img_size.height;
cv::Mat bgr(src_img.h, src_img.w, CV_8UC3);
src_img.to_pixels(bgr.data, ncnn::Mat::PIXEL_RGB2BGR);
ncnn::Mat in = ncnn::Mat::from_pixels_resize(bgr.data, ncnn::Mat::PIXEL_BGR2RGB, img_w, img_h, target_size,
target_size);
const float mean_vals[3] = {123.68f, 116.78f, 103.94f};
const float norm_vals[3] = {1.0 / 58.40f, 1.0 / 57.12f, 1.0 / 57.38f};
in.substract_mean_normalize(mean_vals, norm_vals);
ncnn::Mat maskmaps;
ncnn::Mat location;
ncnn::Mat mask;
ncnn::Mat confidence;
ncnn::Extractor ex = YolactNet->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("input.1", in);
ex.extract("619", maskmaps); // 138x138 x 32
ex.extract("816", location); // 4 x 19248
ex.extract("818", mask); // maskdim 32 x 19248
ex.extract("820", confidence); // 81 x 19248
int num_class = confidence.w;
int num_priors = confidence.h;
// make priorbox
ncnn::Mat priorbox(4, num_priors);
{
const int conv_ws[5] = {69, 35, 18, 9, 5};
const int conv_hs[5] = {69, 35, 18, 9, 5};
const float aspect_ratios[3] = {1.f, 0.5f, 2.f};
const float scales[5] = {24.f, 48.f, 96.f, 192.f, 384.f};
float *pb = priorbox;
for (int p = 0; p < 5; p++) {
int conv_w = conv_ws[p];
int conv_h = conv_hs[p];
float scale = scales[p];
for (int i = 0; i < conv_h; i++) {
for (int j = 0; j < conv_w; j++) {
// +0.5 because priors are in center-size notation
float cx = (j + 0.5f) / conv_w;
float cy = (i + 0.5f) / conv_h;
for (int k = 0; k < 3; k++) {
float ar = aspect_ratios[k];
ar = sqrt(ar);
float w = scale * ar / target_size;
float h = scale / ar / target_size;
// This is for backward compatability with a bug where I made everything square by accident
// cfg.backbone.use_square_anchors:
h = w;
pb[0] = cx;
pb[1] = cy;
pb[2] = w;
pb[3] = h;
pb += 4;
}
}
}
}
}
const float confidence_thresh = 0.05f;
const float nms_threshold = 0.5f;
const int keep_top_k = 200;
std::vector<std::vector<Object> > class_candidates;
class_candidates.resize(num_class);
for (int i = 0; i < num_priors; i++) {
const float *conf = confidence.row(i);
const float *loc = location.row(i);
const float *pb = priorbox.row(i);
const float *maskdata = mask.row(i);
// find class id with highest score
// start from 1 to skip background
int label = 0;
float score = 0.f;
for (int j = 1; j < num_class; j++) {
float class_score = conf[j];
if (class_score > score) {
label = j;
score = class_score;
}
}
// ignore background or low score
if (label == 0 || score <= confidence_thresh)
continue;
// CENTER_SIZE
float var[4] = {0.1f, 0.1f, 0.2f, 0.2f};
float pb_cx = pb[0];
float pb_cy = pb[1];
float pb_w = pb[2];
float pb_h = pb[3];
float bbox_cx = var[0] * loc[0] * pb_w + pb_cx;
float bbox_cy = var[1] * loc[1] * pb_h + pb_cy;
float bbox_w = (float) (exp(var[2] * loc[2]) * pb_w);
float bbox_h = (float) (exp(var[3] * loc[3]) * pb_h);
float obj_x1 = bbox_cx - bbox_w * 0.5f;
float obj_y1 = bbox_cy - bbox_h * 0.5f;
float obj_x2 = bbox_cx + bbox_w * 0.5f;
float obj_y2 = bbox_cy + bbox_h * 0.5f;
// clip
obj_x1 = std::max(std::min(obj_x1 * bgr.cols, (float) (bgr.cols - 1)), 0.f);
obj_y1 = std::max(std::min(obj_y1 * bgr.rows, (float) (bgr.rows - 1)), 0.f);
obj_x2 = std::max(std::min(obj_x2 * bgr.cols, (float) (bgr.cols - 1)), 0.f);
obj_y2 = std::max(std::min(obj_y2 * bgr.rows, (float) (bgr.rows - 1)), 0.f);
// append object
Object obj;
obj.rect = cv::Rect_<float>(obj_x1, obj_y1, obj_x2 - obj_x1 + 1, obj_y2 - obj_y1 + 1);
obj.label = label;
obj.prob = score;
obj.maskdata = std::vector<float>(maskdata, maskdata + mask.w);
class_candidates[label].push_back(obj);
}
std::vector<Object> objects;
objects.clear();
for (int i = 0; i < (int) class_candidates.size(); i++) {
std::vector<Object> &candidates = class_candidates[i];
qsort_descent_inplace(candidates);
std::vector<int> picked;
nms_sorted_bboxes(candidates, picked, nms_threshold);
for (int j = 0; j < (int) picked.size(); j++) {
int z = picked[j];
objects.push_back(candidates[z]);
}
}
qsort_descent_inplace(objects);
// keep_top_k
if (keep_top_k < (int) objects.size()) {
objects.resize(keep_top_k);
}
// generate mask
for (int i = 0; i < objects.size(); i++) {
Object &obj = objects[i];
cv::Mat mask(maskmaps.h, maskmaps.w, CV_32FC1);
{
mask = cv::Scalar(0.f);
for (int p = 0; p < maskmaps.c; p++) {
const float *maskmap = maskmaps.channel(p);
float coeff = obj.maskdata[p];
float *mp = (float *) mask.data;
// mask += m * coeff
for (int j = 0; j < maskmaps.w * maskmaps.h; j++) {
mp[j] += maskmap[j] * coeff;
}
}
}
cv::Mat mask2;
cv::resize(mask, mask2, cv::Size(img_w, img_h));
// crop obj box and binarize
obj.mask = cv::Mat(img_h, img_w, CV_8UC1);
{
obj.mask = cv::Scalar(0);
for (int y = 0; y < img_h; y++) {
if (y < obj.rect.y || y > obj.rect.y + obj.rect.height)
continue;
const float *mp2 = mask2.ptr<const float>(y);
uchar *bmp = obj.mask.ptr<uchar>(y);
for (int x = 0; x < img_w; x++) {
if (x < obj.rect.x || x > obj.rect.x + obj.rect.width)
continue;
bmp[x] = mp2[x] > 0.5f ? 255 : 0;
}
}
}
}
return objects;
}
static void draw_objects(const cv::Mat &bgr, const std::vector<Object> &objects) {
static const char *class_names[] = {"background",
"person", "bicycle", "car", "motorcycle", "airplane", "bus",
"train", "truck", "boat", "traffic light", "fire hydrant",
"stop sign", "parking meter", "bench", "bird", "cat", "dog",
"horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe",
"backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat",
"baseball glove", "skateboard", "surfboard", "tennis racket",
"bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl",
"banana", "apple", "sandwich", "orange", "broccoli", "carrot",
"hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop",
"mouse", "remote", "keyboard", "cell phone", "microwave", "oven",
"toaster", "sink", "refrigerator", "book", "clock", "vase",
"scissors", "teddy bear", "hair drier", "toothbrush"
};
static const unsigned char colors[19][3] = {
{244, 67, 54},
{233, 30, 99},
{156, 39, 176},
{103, 58, 183},
{63, 81, 181},
{33, 150, 243},
{3, 169, 244},
{0, 188, 212},
{0, 150, 136},
{76, 175, 80},
{139, 195, 74},
{205, 220, 57},
{255, 235, 59},
{255, 193, 7},
{255, 152, 0},
{255, 87, 34},
{121, 85, 72},
{158, 158, 158},
{96, 125, 139}
};
cv::Mat image = bgr.clone();
int color_index = 0;
for (size_t i = 0; i < objects.size(); i++) {
const Object &obj = objects[i];
if (obj.prob < 0.15)
continue;
fprintf(stderr, "%d = %.5f at %.2f %.2f %.2f x %.2f\n", obj.label, obj.prob,
obj.rect.x, obj.rect.y, obj.rect.width, obj.rect.height);
const unsigned char *color = colors[color_index++];
cv::rectangle(image, obj.rect, cv::Scalar(color[0], color[1], color[2]));
char text[256];
sprintf(text, "%s %.1f%%", class_names[obj.label], obj.prob * 100);
int baseLine = 0;
cv::Size label_size = cv::getTextSize(text, cv::FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
int x = obj.rect.x;
int y = obj.rect.y - label_size.height - baseLine;
if (y < 0)
y = 0;
if (x + label_size.width > image.cols)
x = image.cols - label_size.width;
cv::rectangle(image, cv::Rect(cv::Point(x, y), cv::Size(label_size.width, label_size.height + baseLine)),
cv::Scalar(255, 255, 255), -1);
cv::putText(image, text, cv::Point(x, y + label_size.height),
cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 0));
// draw mask
for (int y = 0; y < image.rows; y++) {
const uchar *mp = obj.mask.ptr(y);
uchar *p = image.ptr(y);
for (int x = 0; x < image.cols; x++) {
if (mp[x] == 255) {
p[0] = cv::saturate_cast<uchar>(p[0] * 0.5 + color[0] * 0.5);
p[1] = cv::saturate_cast<uchar>(p[1] * 0.5 + color[1] * 0.5);
p[2] = cv::saturate_cast<uchar>(p[2] * 0.5 + color[2] * 0.5);
}
p += 3;
}
}
}
cv::imwrite("result.png", image);
cv::imshow("image", image);
cv::waitKey(0);
}
//int main(int argc, char **argv) {
// if (argc != 2) {
// fprintf(stderr, "Usage: %s [imagepath]\n", argv[0]);
// return -1;
// }
//
// const char *imagepath = argv[1];
//
// cv::Mat m = cv::imread(imagepath, 1);
// if (m.empty()) {
// fprintf(stderr, "cv::imread %s failed\n", imagepath);
// return -1;
// }
//
// std::vector<Object> objects;
// detect_yolact(m, objects);
//
// draw_objects(m, objects);
//
// return 0;
//}

@ -0,0 +1,43 @@
//
// Created by WZTENG on 2020/08/19 019.
//
#ifndef YOLOV5_YOLACT_H
#define YOLOV5_YOLACT_H
#include "ncnn/net.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <vector>
struct Object {
cv::Rect_<float> rect;
int label;
float prob;
std::vector<float> maskdata;
cv::Mat mask;
};
class Yolact {
public:
Yolact(AAssetManager *mgr, bool useGPU);
~Yolact();
std::vector<Object> detect_yolact(JNIEnv *env, jobject image);
private:
ncnn::Net *YolactNet;
int target_size = 550;
public:
static Yolact *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV5_YOLACT_H

@ -0,0 +1,77 @@
#include "YoloV4.h"
bool YoloV4::hasGPU = true;
bool YoloV4::toUseGPU = true;
YoloV4 *YoloV4::detector = nullptr;
YoloV4::YoloV4(AAssetManager *mgr, const char *param, const char *bin, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
Net = new ncnn::Net();
// opt 需要在加载前设置
Net->opt.use_vulkan_compute = toUseGPU; // gpu
Net->opt.use_fp16_arithmetic = true; // fp16运算加速
Net->load_param(mgr, param);
Net->load_model(mgr, bin);
}
YoloV4::~YoloV4() {
Net->clear();
delete Net;
}
std::vector<BoxInfo> YoloV4::detect(JNIEnv *env, jobject image, float threshold, float nms_threshold) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
ncnn::Mat in_net = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB, input_size,
input_size);
float norm[3] = {1 / 255.f, 1 / 255.f, 1 / 255.f};
float mean[3] = {0, 0, 0};
in_net.substract_mean_normalize(mean, norm);
auto ex = Net->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input(0, in_net);
std::vector<BoxInfo> result;
ncnn::Mat blob;
ex.extract("output", blob);
auto boxes = decode_infer(blob, {(int) img_size.width, (int) img_size.height}, input_size, num_class, threshold);
result.insert(result.begin(), boxes.begin(), boxes.end());
// nms(result,nms_threshold);
return result;
}
inline float fast_exp(float x) {
union {
uint32_t i;
float f;
} v{};
v.i = (1 << 23) * (1.4426950409 * x + 126.93490512f);
return v.f;
}
inline float sigmoid(float x) {
return 1.0f / (1.0f + fast_exp(-x));
}
std::vector<BoxInfo>
YoloV4::decode_infer(ncnn::Mat &data, const yolocv::YoloSize &frame_size, int net_size, int num_classes, float threshold) {
std::vector<BoxInfo> result;
for (int i = 0; i < data.h; i++) {
BoxInfo box;
const float *values = data.row(i);
box.label = values[0] - 1;
box.score = values[1];
box.x1 = values[2] * (float) frame_size.width;
box.y1 = values[3] * (float) frame_size.height;
box.x2 = values[4] * (float) frame_size.width;
box.y2 = values[5] * (float) frame_size.height;
result.push_back(box);
}
return result;
}

@ -0,0 +1,39 @@
#ifndef YOLOV4_H
#define YOLOV4_H
#include "ncnn/net.h"
#include "YoloV5.h"
class YoloV4 {
public:
YoloV4(AAssetManager *mgr, const char *param, const char *bin, bool useGPU);
~YoloV4();
std::vector<BoxInfo> detect(JNIEnv *env, jobject image, float threshold, float nms_threshold);
std::vector<std::string> labels{"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
"microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
"hair drier", "toothbrush"};
private:
static std::vector<BoxInfo>
decode_infer(ncnn::Mat &data, const yolocv::YoloSize &frame_size, int net_size, int num_classes, float threshold);
// static void nms(std::vector<BoxInfo>& result,float nms_threshold);
ncnn::Net *Net;
int input_size = 640 / 2;
int num_class = 80;
public:
static YoloV4 *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV4_H

@ -0,0 +1,137 @@
//
// Created by 邓昊晴 on 14/6/2020.
//
#include "YoloV5.h"
bool YoloV5::hasGPU = true;
bool YoloV5::toUseGPU = true;
YoloV5 *YoloV5::detector = nullptr;
YoloV5::YoloV5(AAssetManager *mgr, const char *param, const char *bin, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
Net = new ncnn::Net();
// opt 需要在加载前设置
Net->opt.use_vulkan_compute = toUseGPU; // gpu
Net->opt.use_fp16_arithmetic = true; // fp16运算加速
Net->load_param(mgr, param);
Net->load_model(mgr, bin);
}
YoloV5::~YoloV5() {
Net->clear();
delete Net;
}
std::vector<BoxInfo> YoloV5::detect(JNIEnv *env, jobject image, float threshold, float nms_threshold) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
// ncnn::Mat in_net = ncnn::Mat::from_android_bitmap_resize(env,image,ncnn::Mat::PIXEL_BGR2RGB,input_size/2,input_size/2);
ncnn::Mat in_net = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB, input_size / 2,
input_size / 2);
float norm[3] = {1 / 255.f, 1 / 255.f, 1 / 255.f};
float mean[3] = {0, 0, 0};
in_net.substract_mean_normalize(mean, norm);
auto ex = Net->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input(0, in_net);
std::vector<BoxInfo> result;
for (const auto &layer: layers) {
ncnn::Mat blob;
ex.extract(layer.name.c_str(), blob);
auto boxes = decode_infer(blob, layer.stride, {(int) img_size.width, (int) img_size.height}, input_size,
num_class, layer.anchors, threshold);
result.insert(result.begin(), boxes.begin(), boxes.end());
}
nms(result, nms_threshold);
return result;
}
inline float fast_exp(float x) {
union {
uint32_t i;
float f;
} v{};
v.i = (1 << 23) * (1.4426950409 * x + 126.93490512f);
return v.f;
}
inline float sigmoid(float x) {
return 1.0f / (1.0f + fast_exp(-x));
}
std::vector<BoxInfo>
YoloV5::decode_infer(ncnn::Mat &data, int stride, const yolocv::YoloSize &frame_size, int net_size, int num_classes,
const std::vector<yolocv::YoloSize> &anchors, float threshold) {
std::vector<BoxInfo> result;
int grid_size = int(sqrt(data.h));
float *mat_data[data.c];
for (int i = 0; i < data.c; i++) {
mat_data[i] = data.channel(i);
}
float cx, cy, w, h;
for (int shift_y = 0; shift_y < grid_size; shift_y++) {
for (int shift_x = 0; shift_x < grid_size; shift_x++) {
int loc = shift_x + shift_y * grid_size;
for (int i = 0; i < 3; i++) {
float *record = mat_data[i];
float *cls_ptr = record + 5;
for (int cls = 0; cls < num_classes; cls++) {
float score = sigmoid(cls_ptr[cls]) * sigmoid(record[4]);
if (score > threshold) {
cx = (sigmoid(record[0]) * 2.f - 0.5f + (float) shift_x) * (float) stride;
cy = (sigmoid(record[1]) * 2.f - 0.5f + (float) shift_y) * (float) stride;
w = pow(sigmoid(record[2]) * 2.f, 2) * anchors[i].width;
h = pow(sigmoid(record[3]) * 2.f, 2) * anchors[i].height;
//printf("[grid size=%d, stride = %d]x y w h %f %f %f %f\n",grid_size,stride,record[0],record[1],record[2],record[3]);
BoxInfo box;
box.x1 = std::max(0, std::min(frame_size.width, int((cx - w / 2.f) * (float) frame_size.width / (float) net_size)));
box.y1 = std::max(0, std::min(frame_size.height, int((cy - h / 2.f) * (float) frame_size.height / (float) net_size)));
box.x2 = std::max(0, std::min(frame_size.width, int((cx + w / 2.f) * (float) frame_size.width / (float) net_size)));
box.y2 = std::max(0, std::min(frame_size.height, int((cy + h / 2.f) * (float) frame_size.height / (float) net_size)));
box.score = score;
box.label = cls;
result.push_back(box);
}
}
}
for (auto &ptr:mat_data) {
ptr += (num_classes + 5);
}
}
}
return result;
}
void YoloV5::nms(std::vector<BoxInfo> &input_boxes, float NMS_THRESH) {
std::sort(input_boxes.begin(), input_boxes.end(), [](BoxInfo a, BoxInfo b) { return a.score > b.score; });
std::vector<float> vArea(input_boxes.size());
for (int i = 0; i < int(input_boxes.size()); ++i) {
vArea[i] = (input_boxes.at(i).x2 - input_boxes.at(i).x1 + 1)
* (input_boxes.at(i).y2 - input_boxes.at(i).y1 + 1);
}
for (int i = 0; i < int(input_boxes.size()); ++i) {
for (int j = i + 1; j < int(input_boxes.size());) {
float xx1 = std::max(input_boxes[i].x1, input_boxes[j].x1);
float yy1 = std::max(input_boxes[i].y1, input_boxes[j].y1);
float xx2 = std::min(input_boxes[i].x2, input_boxes[j].x2);
float yy2 = std::min(input_boxes[i].y2, input_boxes[j].y2);
float w = std::max(float(0), xx2 - xx1 + 1);
float h = std::max(float(0), yy2 - yy1 + 1);
float inter = w * h;
float ovr = inter / (vArea[i] + vArea[j] - inter);
if (ovr >= NMS_THRESH) {
input_boxes.erase(input_boxes.begin() + j);
vArea.erase(vArea.begin() + j);
} else {
j++;
}
}
}
}

@ -0,0 +1,71 @@
//
// Created by 邓昊晴 on 14/6/2020.
//
#ifndef YOLOV5_H
#define YOLOV5_H
#include "ncnn/net.h"
namespace yolocv {
typedef struct {
int width;
int height;
} YoloSize;
}
typedef struct {
std::string name;
int stride;
std::vector<yolocv::YoloSize> anchors;
} YoloLayerData;
typedef struct BoxInfo {
float x1;
float y1;
float x2;
float y2;
float score;
int label;
} BoxInfo;
class YoloV5 {
public:
YoloV5(AAssetManager *mgr, const char *param, const char *bin, bool useGPU);
~YoloV5();
std::vector<BoxInfo> detect(JNIEnv *env, jobject image, float threshold, float nms_threshold);
std::vector<std::string> labels{"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
"microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
"hair drier", "toothbrush"};
private:
static std::vector<BoxInfo>
decode_infer(ncnn::Mat &data, int stride, const yolocv::YoloSize &frame_size, int net_size, int num_classes,
const std::vector<yolocv::YoloSize> &anchors, float threshold);
static void nms(std::vector<BoxInfo> &result, float nms_threshold);
ncnn::Net *Net;
int input_size = 640;
int num_class = 80;
std::vector<YoloLayerData> layers{
{"394", 32, {{116, 90}, {156, 198}, {373, 326}}},
{"375", 16, {{30, 61}, {62, 45}, {59, 119}}},
{"output", 8, {{10, 13}, {16, 30}, {33, 23}}},
};
public:
static YoloV5 *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV5_H

@ -0,0 +1,389 @@
#include "YoloV5CustomLayer.h"
#include "ncnn/layer.h"
/**
ncnn opencv ncnn opencv opencv
ncnn opencv ncnn ncnn
ncnn CMakeLists.txt 使
opencv ncnn CMakelista.txt opencv
# disable rtti and exceptions
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
opencv ncnn CMakelista.txt ncnn
# enable rtti
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
ncnn rtti -DNCNN_DISABLE_RTTI=OFF -DNCNN_DISABLE_EXCEPTION=OFF
( opencv)ENABLE_CUSTOM_LAYER 1
**/
#if ENABLE_CUSTOM_LAYER
class YoloV5Focus : public ncnn::Layer {
public:
YoloV5Focus();
virtual int forward(const ncnn::Mat &bottom_blob, ncnn::Mat &top_blob, const ncnn::Option &opt) const;
};
DEFINE_LAYER_CREATOR(YoloV5Focus)
YoloV5Focus::YoloV5Focus() {
one_blob_only = true;
}
int YoloV5Focus::forward(const ncnn::Mat &bottom_blob, ncnn::Mat &top_blob, const ncnn::Option &opt) const {
int w = bottom_blob.w;
int h = bottom_blob.h;
int channels = bottom_blob.c;
int outw = w / 2;
int outh = h / 2;
int outc = channels * 4;
top_blob.create(outw, outh, outc, 4u, 1, opt.blob_allocator);
if (top_blob.empty())
return -100;
#pragma omp parallel for num_threads(opt.num_threads)
for (int p = 0; p < outc; p++) {
const float *ptr = bottom_blob.channel(p % channels).row((p / channels) % 2) + ((p / channels) / 2);
float *outptr = top_blob.channel(p);
for (int i = 0; i < outh; i++) {
for (int j = 0; j < outw; j++) {
*outptr = *ptr;
outptr += 1;
ptr += 2;
}
ptr += w;
}
}
return 0;
}
#endif // custom layer
// ===================================================================================================
inline float intersection_area(const YoloObject &a, const YoloObject &b) {
if (a.x > b.x + b.w || a.x + a.w < b.x || a.y > b.y + b.h || a.y + a.h < b.y) {
// no intersection
return 0.f;
}
float inter_width = std::min(a.x + a.w, b.x + b.w) - std::max(a.x, b.x);
float inter_height = std::min(a.y + a.h, b.y + b.h) - std::max(a.y, b.y);
return inter_width * inter_height;
}
void qsort_descent_inplace(std::vector<YoloObject> &faceobjects, int left, int right) {
int i = left;
int j = right;
float p = faceobjects[(left + right) / 2].prob;
while (i <= j) {
while (faceobjects[i].prob > p)
i++;
while (faceobjects[j].prob < p)
j--;
if (i <= j) {
// swap
std::swap(faceobjects[i], faceobjects[j]);
i++;
j--;
}
}
#pragma omp parallel sections
{
#pragma omp section
{
if (left < j) qsort_descent_inplace(faceobjects, left, j);
}
#pragma omp section
{
if (i < right) qsort_descent_inplace(faceobjects, i, right);
}
}
}
void qsort_descent_inplace(std::vector<YoloObject> &faceobjects) {
if (faceobjects.empty()) {
return;
}
qsort_descent_inplace(faceobjects, 0, faceobjects.size() - 1);
}
void nms_sorted_bboxes(const std::vector<YoloObject> &faceobjects, std::vector<int> &picked, float nms_threshold) {
picked.clear();
const int n = faceobjects.size();
std::vector<float> areas(n);
for (int i = 0; i < n; i++) {
areas[i] = faceobjects[i].w * faceobjects[i].h;
}
for (int i = 0; i < n; i++) {
const YoloObject &a = faceobjects[i];
int keep = 1;
for (int j = 0; j < (int) picked.size(); j++) {
const YoloObject &b = faceobjects[picked[j]];
// intersection over union
float inter_area = intersection_area(a, b);
float union_area = areas[i] + areas[picked[j]] - inter_area;
// float IoU = inter_area / union_area
if (inter_area / union_area > nms_threshold) {
keep = 0;
}
}
if (keep) {
picked.push_back(i);
}
}
}
//inline float fast_exp(float x) {
// union {
// uint32_t i;
// float f;
// } v{};
// v.i = (1 << 23) * (1.4426950409 * x + 126.93490512f);
// return v.f;
//}
//
//inline float sigmoid(float x) {
// return 1.0f / (1.0f + fast_exp(-x));
//}
static inline float sigmoid(float x) {
return static_cast<float>(1.f / (1.f + exp(-x)));
}
void generate_proposals(const ncnn::Mat &anchors, int stride,
const ncnn::Mat &in_pad, const ncnn::Mat &feat_blob,
float prob_threshold, std::vector<YoloObject> &objects) {
const int num_grid = feat_blob.h;
int num_grid_x;
int num_grid_y;
if (in_pad.w > in_pad.h) {
num_grid_x = in_pad.w / stride;
num_grid_y = num_grid / num_grid_x;
} else {
num_grid_y = in_pad.h / stride;
num_grid_x = num_grid / num_grid_y;
}
const int num_class = feat_blob.w - 5;
const int num_anchors = anchors.w / 2;
for (int q = 0; q < num_anchors; q++) {
const float anchor_w = anchors[q * 2];
const float anchor_h = anchors[q * 2 + 1];
const ncnn::Mat feat = feat_blob.channel(q);
for (int i = 0; i < num_grid_y; i++) {
for (int j = 0; j < num_grid_x; j++) {
const float *featptr = feat.row(i * num_grid_x + j);
// find class index with max class score
int class_index = 0;
float class_score = -FLT_MAX;
for (int k = 0; k < num_class; k++) {
float score = featptr[5 + k];
if (score > class_score) {
class_index = k;
class_score = score;
}
}
float box_score = featptr[4];
float confidence = sigmoid(box_score) * sigmoid(class_score);
if (confidence >= prob_threshold) {
// yolov5/models/yolo.py Detect forward
// y = x[i].sigmoid()
// y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i].to(x[i].device)) * self.stride[i] # xy
// y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
float dx = sigmoid(featptr[0]);
float dy = sigmoid(featptr[1]);
float dw = sigmoid(featptr[2]);
float dh = sigmoid(featptr[3]);
float pb_cx = (dx * 2.f - 0.5f + j) * stride;
float pb_cy = (dy * 2.f - 0.5f + i) * stride;
float pb_w = pow(dw * 2.f, 2) * anchor_w;
float pb_h = pow(dh * 2.f, 2) * anchor_h;
float x0 = pb_cx - pb_w * 0.5f;
float y0 = pb_cy - pb_h * 0.5f;
float x1 = pb_cx + pb_w * 0.5f;
float y1 = pb_cy + pb_h * 0.5f;
YoloObject obj;
obj.x = x0;
obj.y = y0;
obj.w = x1 - x0;
obj.h = y1 - y0;
obj.label = class_index;
obj.prob = confidence;
objects.push_back(obj);
}
}
}
}
}
bool YoloV5CustomLayer::hasGPU = true;
bool YoloV5CustomLayer::toUseGPU = true;
YoloV5CustomLayer *YoloV5CustomLayer::detector = nullptr;
YoloV5CustomLayer::YoloV5CustomLayer(AAssetManager *mgr, const char *param, const char *bin, bool useGPU) {
hasGPU = ncnn::get_gpu_count() > 0;
toUseGPU = hasGPU && useGPU;
Net = new ncnn::Net();
// opt 需要在加载前设置
Net->opt.use_vulkan_compute = toUseGPU; // gpu
Net->opt.use_fp16_arithmetic = true; // fp16运算加速
#if ENABLE_CUSTOM_LAYER
// 注册自定义层
Net->register_custom_layer("YoloV5Focus", YoloV5Focus_layer_creator);
#endif
Net->load_param(mgr, param);
Net->load_model(mgr, bin);
}
YoloV5CustomLayer::~YoloV5CustomLayer() {
Net->clear();
delete Net;
}
std::vector<BoxInfo> YoloV5CustomLayer::detect(JNIEnv *env, jobject image, float threshold, float nms_threshold) {
AndroidBitmapInfo img_size;
AndroidBitmap_getInfo(env, image, &img_size);
// ncnn::Mat in_net = ncnn::Mat::from_android_bitmap_resize(env,image,ncnn::Mat::PIXEL_BGR2RGB,input_size/2,input_size/2);
// letterbox pad to multiple of 32
int w = img_size.width;
int h = img_size.height;
float scale = 1.f;
if (w > h) {
scale = (float) input_size / w;
w = input_size;
h = h * scale;
} else {
scale = (float) input_size / h;
h = input_size;
w = w * scale;
}
ncnn::Mat in_net = ncnn::Mat::from_android_bitmap_resize(env, image, ncnn::Mat::PIXEL_RGBA2RGB, w, h);
// pad to target_size rectangle
// yolov5/utils/datasets.py letterbox
int wpad = (w + 31) / 32 * 32 - w;
int hpad = (h + 31) / 32 * 32 - h;
ncnn::Mat in_pad;
ncnn::copy_make_border(in_net, in_pad, hpad / 2, hpad - hpad / 2, wpad / 2, wpad - wpad / 2, ncnn::BORDER_CONSTANT,
114.f);
float mean[3] = {0, 0, 0};
float norm[3] = {1 / 255.f, 1 / 255.f, 1 / 255.f};
in_pad.substract_mean_normalize(mean, norm);
auto ex = Net->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(4);
if (toUseGPU) { // 消除提示
ex.set_vulkan_compute(toUseGPU);
}
ex.input("images", in_pad);
std::vector<YoloObject> proposals;
// anchor setting from yolov5/models/yolov5s.yaml
for (const auto &layer: layers) {
ncnn::Mat blob;
ex.extract(layer.name.c_str(), blob);
ncnn::Mat anchors(6);
anchors[0] = layer.anchors[0].width;
anchors[1] = layer.anchors[0].height;
anchors[2] = layer.anchors[1].width;
anchors[3] = layer.anchors[1].height;
anchors[4] = layer.anchors[2].width;
anchors[5] = layer.anchors[2].height;
std::vector<YoloObject> objectsx;
generate_proposals(anchors, layer.stride, in_pad, blob, threshold, objectsx);
proposals.insert(proposals.end(), objectsx.begin(), objectsx.end());
}
// sort all proposals by score from highest to lowest
qsort_descent_inplace(proposals);
// apply nms with nms_threshold
std::vector<int> picked;
nms_sorted_bboxes(proposals, picked, nms_threshold);
int count = picked.size();
std::vector<YoloObject> objects;
objects.resize(count);
for (int i = 0; i < count; i++) {
objects[i] = proposals[picked[i]];
// adjust offset to original unpadded
float x0 = (objects[i].x - (wpad / 2)) / scale;
float y0 = (objects[i].y - (hpad / 2)) / scale;
float x1 = (objects[i].x + objects[i].w - (wpad / 2)) / scale;
float y1 = (objects[i].y + objects[i].h - (hpad / 2)) / scale;
// clip
x0 = std::max(std::min(x0, (float) (img_size.width - 1)), 0.f);
y0 = std::max(std::min(y0, (float) (img_size.height - 1)), 0.f);
x1 = std::max(std::min(x1, (float) (img_size.width - 1)), 0.f);
y1 = std::max(std::min(y1, (float) (img_size.height - 1)), 0.f);
objects[i].x = x0;
objects[i].y = y0;
objects[i].w = x1 - x0;
objects[i].h = y1 - y0;
}
std::vector<BoxInfo> result;
for (int i = 0; i < count; i++) {
BoxInfo box;
box.x1 = objects[i].x;
box.y1 = objects[i].y;
box.x2 = objects[i].x + objects[i].w;
box.y2 = objects[i].y + objects[i].h;
box.label = objects[i].label;
box.score = objects[i].prob;
result.push_back(box);
}
return result;
}

@ -0,0 +1,76 @@
#ifndef YOLOV5_CUSTOMLAYER_H
#define YOLOV5_CUSTOMLAYER_H
#include "ncnn/net.h"
#include "YoloV5.h"
/**
ncnn opencv ncnn opencv opencv
ncnn opencv ncnn ncnn
ncnn CMakeLists.txt 使
opencv ncnn CMakelista.txt opencv
# disable rtti and exceptions
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
opencv ncnn CMakelista.txt ncnn
# enable rtti
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
ncnn rtti -DNCNN_DISABLE_RTTI=OFF -DNCNN_DISABLE_EXCEPTION=OFF
( opencv)ENABLE_CUSTOM_LAYER 1
**/
#define ENABLE_CUSTOM_LAYER 0 // 0:disable 1:enable
struct YoloObject {
// cv::Rect_<float> rect;
float x;
float y;
float w;
float h;
int label;
float prob;
};
class YoloV5CustomLayer {
public:
YoloV5CustomLayer(AAssetManager *mgr, const char *param, const char *bin, bool useGPU);
~YoloV5CustomLayer();
std::vector<BoxInfo> detect(JNIEnv *env, jobject image, float threshold, float nms_threshold);
// std::vector<std::string> labels{"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
// "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
// "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
// "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
// "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
// "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
// "potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
// "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
// "hair drier", "toothbrush"};
private:
ncnn::Net *Net;
int input_size = 640;
int num_class = 80;
std::vector<YoloLayerData> layers{
{"output", 8, {{10, 13}, {16, 30}, {33, 23}}},
{"781", 16, {{30, 61}, {62, 45}, {59, 119}}},
{"801", 32, {{116, 90}, {156, 198}, {373, 326}}},
};
public:
static YoloV5CustomLayer *detector;
static bool hasGPU;
static bool toUseGPU;
};
#endif //YOLOV5_CUSTOMLAYER_H

@ -0,0 +1,658 @@
#include <jni.h>
#include <string>
#include <ncnn/gpu.h>
#include <android/asset_manager_jni.h>
#include <android/log.h>
#include "YoloV5.h"
#include "YoloV4.h"
#include "SimplePose.h"
#include "Yolact.h"
#include "ocr.h"
#include "ENet.h"
#include "FaceLandmark.h"
#include "DBFace.h"
#include "MbnFCN.h"
#include "MobileNetV3Seg.h"
#include "YoloV5CustomLayer.h"
#include "NanoDet.h"
#include "LightOpenPose.h"
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
ncnn::create_gpu_instance();
if (ncnn::get_gpu_count() > 0) {
YoloV5::hasGPU = true;
YoloV4::hasGPU = true;
SimplePose::hasGPU = true;
Yolact::hasGPU = true;
OCR::hasGPU = true;
ENet::hasGPU = true;
FaceLandmark::hasGPU = true;
DBFace::hasGPU = true;
MbnFCN::hasGPU = true;
MBNV3Seg::hasGPU = true;
}
// LOGD("jni onload");
return JNI_VERSION_1_6;
}
JNIEXPORT void JNI_OnUnload(JavaVM *vm, void *reserved) {
ncnn::destroy_gpu_instance();
delete YoloV5::detector;
delete YoloV4::detector;
delete SimplePose::detector;
delete Yolact::detector;
delete OCR::detector;
delete ENet::detector;
delete FaceLandmark::detector;
delete DBFace::detector;
delete MbnFCN::detector;
delete MBNV3Seg::detector;
// LOGD("jni onunload");
}
/*********************************************************************************************
Yolov5
********************************************************************************************/
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_YOLOv5_init(JNIEnv *env, jclass, jobject assetManager, jboolean useGPU) {
if (YoloV5::detector != nullptr) {
delete YoloV5::detector;
YoloV5::detector = nullptr;
}
if (YoloV5::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
YoloV5::detector = new YoloV5(mgr, "yolov5.param", "yolov5.bin", useGPU);
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_YOLOv5_detect(JNIEnv *env, jclass, jobject image, jdouble threshold, jdouble nms_threshold) {
auto result = YoloV5::detector->detect(env, image, threshold, nms_threshold);
auto box_cls = env->FindClass("com/wzt/yolov5/Box");
auto cid = env->GetMethodID(box_cls, "<init>", "(FFFFIF)V");
jobjectArray ret = env->NewObjectArray(result.size(), box_cls, nullptr);
int i = 0;
for (auto &box:result) {
env->PushLocalFrame(1);
jobject obj = env->NewObject(box_cls, cid, box.x1, box.y1, box.x2, box.y2, box.label, box.score);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
return ret;
}
// ***************************************[ Yolov5 Custom Layer ]****************************************
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_YOLOv5_initCustomLayer(JNIEnv *env, jclass, jobject assetManager, jboolean useGPU) {
if (YoloV5CustomLayer::detector != nullptr) {
delete YoloV5CustomLayer::detector;
YoloV5CustomLayer::detector = nullptr;
}
if (YoloV5CustomLayer::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
YoloV5CustomLayer::detector = new YoloV5CustomLayer(mgr, "yolov5s_customlayer.param", "yolov5s_customlayer.bin", useGPU);
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_YOLOv5_detectCustomLayer(JNIEnv *env, jclass, jobject image, jdouble threshold, jdouble nms_threshold) {
auto result = YoloV5CustomLayer::detector->detect(env, image, threshold, nms_threshold);
auto box_cls = env->FindClass("com/wzt/yolov5/Box");
auto cid = env->GetMethodID(box_cls, "<init>", "(FFFFIF)V");
jobjectArray ret = env->NewObjectArray(result.size(), box_cls, nullptr);
int i = 0;
for (auto &box:result) {
env->PushLocalFrame(1);
jobject obj = env->NewObject(box_cls, cid, box.x1, box.y1, box.x2, box.y2, box.label, box.score);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
return ret;
}
/*********************************************************************************************
YOLOv4-tiny
yolov4ncnn
darknet2ncnn:https://drive.google.com/drive/folders/1YzILvh0SKQPS_lrb33dmGNq7aVTKPWS0
********************************************************************************************/
// 20200813 增加 MobileNetV2-YOLOv3-Nano-coco
// 20201124 增加 yolo-fastest-xl
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_YOLOv4_init(JNIEnv *env, jclass, jobject assetManager, jint yoloType, jboolean useGPU) {
if (YoloV4::detector != nullptr) {
delete YoloV4::detector;
YoloV4::detector = nullptr;
}
if (YoloV4::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
if (yoloType == 0) {
YoloV4::detector = new YoloV4(mgr, "yolov4-tiny-opt.param", "yolov4-tiny-opt.bin", useGPU);
} else if (yoloType == 1) {
YoloV4::detector = new YoloV4(mgr, "MobileNetV2-YOLOv3-Nano-coco.param",
"MobileNetV2-YOLOv3-Nano-coco.bin", useGPU);
} else if (yoloType == 2) {
YoloV4::detector = new YoloV4(mgr, "yolo-fastest-opt.param", "yolo-fastest-opt.bin", useGPU);
}
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_YOLOv4_detect(JNIEnv *env, jclass, jobject image, jdouble threshold, jdouble nms_threshold) {
auto result = YoloV4::detector->detect(env, image, threshold, nms_threshold);
auto box_cls = env->FindClass("com/wzt/yolov5/Box");
auto cid = env->GetMethodID(box_cls, "<init>", "(FFFFIF)V");
jobjectArray ret = env->NewObjectArray(result.size(), box_cls, nullptr);
int i = 0;
for (auto &box:result) {
env->PushLocalFrame(1);
jobject obj = env->NewObject(box_cls, cid, box.x1, box.y1, box.x2, box.y2, box.label, box.score);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
return ret;
}
/*********************************************************************************************
NanoDet
********************************************************************************************/
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_NanoDet_init(JNIEnv *env, jclass, jobject assetManager, jboolean useGPU) {
if (NanoDet::detector != nullptr) {
delete NanoDet::detector;
NanoDet::detector = nullptr;
}
if (NanoDet::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
NanoDet::detector = new NanoDet(mgr, "nanodet_m.param", "nanodet_m.bin", useGPU);
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_NanoDet_detect(JNIEnv *env, jclass, jobject image, jdouble threshold, jdouble nms_threshold) {
auto result = NanoDet::detector->detect(env, image, threshold, nms_threshold);
auto box_cls = env->FindClass("com/wzt/yolov5/Box");
auto cid = env->GetMethodID(box_cls, "<init>", "(FFFFIF)V");
jobjectArray ret = env->NewObjectArray(result.size(), box_cls, nullptr);
int i = 0;
for (auto &box:result) {
env->PushLocalFrame(1);
jobject obj = env->NewObject(box_cls, cid, box.x1, box.y1, box.x2, box.y2, box.label, box.score);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
return ret;
}
/*********************************************************************************************
SimplePose
********************************************************************************************/
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_SimplePose_init(JNIEnv *env, jclass clazz, jobject assetManager, jboolean useGPU) {
if (SimplePose::detector != nullptr) {
delete SimplePose::detector;
SimplePose::detector = nullptr;
}
if (SimplePose::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
SimplePose::detector = new SimplePose(mgr, useGPU);
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_SimplePose_detect(JNIEnv *env, jclass clazz, jobject image) {
auto result = SimplePose::detector->detect(env, image);
auto box_cls = env->FindClass("com/wzt/yolov5/KeyPoint");
auto cid = env->GetMethodID(box_cls, "<init>", "([F[FFFFFF)V");
jobjectArray ret = env->NewObjectArray(result.size(), box_cls, nullptr);
int i = 0;
int KEY_NUM = 17;
for (auto &keypoint : result) {
env->PushLocalFrame(1);
float x[KEY_NUM];
float y[KEY_NUM];
for (int j = 0; j < KEY_NUM; j++) {
x[j] = keypoint.keyPoints[j].p.x;
y[j] = keypoint.keyPoints[j].p.y;
}
jfloatArray xs = env->NewFloatArray(KEY_NUM);
env->SetFloatArrayRegion(xs, 0, KEY_NUM, x);
jfloatArray ys = env->NewFloatArray(KEY_NUM);
env->SetFloatArrayRegion(ys, 0, KEY_NUM, y);
jobject obj = env->NewObject(box_cls, cid, xs, ys,
keypoint.boxInfos.x1, keypoint.boxInfos.y1, keypoint.boxInfos.x2, keypoint.boxInfos.y2,
keypoint.boxInfos.score);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
return ret;
}
/*********************************************************************************************
Yolact
********************************************************************************************/
jintArray matToBitmapIntArray(JNIEnv *env, const cv::Mat &image) {
jintArray resultImage = env->NewIntArray(image.total());
auto *_data = new jint[image.total()];
for (int i = 0; i < image.total(); i++) { // =========== 注意这里再确认下要不要除3
char r = image.data[3 * i + 2];
char g = image.data[3 * i + 1];
char b = image.data[3 * i + 0];
char a = (char) 255;
_data[i] = (((jint) a << 24) & 0xFF000000) + (((jint) r << 16) & 0x00FF0000) +
(((jint) g << 8) & 0x0000FF00) + ((jint) b & 0x000000FF);
}
env->SetIntArrayRegion(resultImage, 0, image.total(), _data);
delete[] _data;
return resultImage;
}
jcharArray matToBitmapCharArray(JNIEnv *env, const cv::Mat &image) {
jcharArray resultImage = env->NewCharArray(image.total());
auto *_data = new jchar[image.total()];
for (int i = 0; i < image.total(); i++) {
char m = image.data[i];
_data[i] = (m & 0xFF);
}
env->SetCharArrayRegion(resultImage, 0, image.total(), _data);
delete[] _data;
return resultImage;
}
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_Yolact_init(JNIEnv *env, jclass clazz, jobject assetManager, jboolean useGPU) {
if (Yolact::detector != nullptr) {
delete Yolact::detector;
Yolact::detector = nullptr;
}
if (Yolact::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
Yolact::detector = new Yolact(mgr, useGPU);
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_Yolact_detect(JNIEnv *env, jclass clazz, jobject image) {
auto result = Yolact::detector->detect_yolact(env, image);
auto yolact_mask = env->FindClass("com/wzt/yolov5/YolactMask");
// auto cid = env->GetMethodID(yolact_mask, "<init>", "(FFFFIF[F[I)V");
auto cid = env->GetMethodID(yolact_mask, "<init>", "(FFFFIF[F[C)V");
jobjectArray ret = env->NewObjectArray(result.size(), yolact_mask, nullptr);
int i = 0;
for (auto &mask : result) {
// LOGD("jni yolact mask rect x:%f y:%f", mask.rect.x, mask.rect.y);
// LOGD("jni yolact maskdata size:%d", mask.maskdata.size());
// LOGD("jni yolact mask size:%d", mask.mask.cols * mask.mask.rows);
// jintArray jintmask = matToBitmapIntArray(env, mask.mask);
jcharArray jcharmask = matToBitmapCharArray(env, mask.mask);
env->PushLocalFrame(1);
jfloatArray maskdata = env->NewFloatArray(mask.maskdata.size());
auto *jnum = new jfloat[mask.maskdata.size()];
for (int j = 0; j < mask.maskdata.size(); ++j) {
*(jnum + j) = mask.maskdata[j];
}
env->SetFloatArrayRegion(maskdata, 0, mask.maskdata.size(), jnum);
delete[] jnum;
jobject obj = env->NewObject(yolact_mask, cid,
mask.rect.x, mask.rect.y, mask.rect.x + mask.rect.width,
mask.rect.y + mask.rect.height,
mask.label, mask.prob, maskdata, jcharmask);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
return ret;
}
/*********************************************************************************************
chineseocr-lite
********************************************************************************************/
jstring str2jstring(JNIEnv *env, const char *pat) {
//定义java String类 strClass
jclass strClass = (env)->FindClass("java/lang/String");
//获取String(byte[],String)的构造器,用于将本地byte[]数组转换为一个新String
jmethodID ctorID = (env)->GetMethodID(strClass, "<init>", "([BLjava/lang/String;)V");
//建立byte数组
jbyteArray bytes = (env)->NewByteArray(strlen(pat));
//将char* 转换为byte数组
(env)->SetByteArrayRegion(bytes, 0, strlen(pat), (jbyte *) pat);
// 设置String, 保存语言类型,用于byte数组转换至String时的参数
jstring encoding = (env)->NewStringUTF("UTF-8");
//将byte数组转换为java String,并输出
return (jstring) (env)->NewObject(strClass, ctorID, bytes, encoding);
}
std::string jstring2str(JNIEnv *env, jstring jstr) {
char *rtn = NULL;
jclass clsstring = env->FindClass("java/lang/String");
jstring strencode = env->NewStringUTF("UTF-8");
jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B");
jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, mid, strencode);
jsize alen = env->GetArrayLength(barr);
jbyte *ba = env->GetByteArrayElements(barr, JNI_FALSE);
if (alen > 0) {
rtn = (char *) malloc(alen + 1);
memcpy(rtn, ba, alen);
rtn[alen] = 0;
}
env->ReleaseByteArrayElements(barr, ba, 0);
std::string stemp(rtn);
free(rtn);
return stemp;
}
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_ocr_ChineseOCRLite_init(JNIEnv *env, jclass clazz, jobject assetManager, jboolean useGPU) {
if (OCR::detector != nullptr) {
delete OCR::detector;
OCR::detector = nullptr;
}
if (OCR::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
OCR::detector = new OCR(env, clazz, mgr, useGPU);
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_ocr_ChineseOCRLite_detect(JNIEnv *env, jclass clazz, jobject bitmap, jint short_size) {
auto ocrResult = OCR::detector->detect(env, bitmap, short_size);
// LOGD("jni ocr result size:%ld", ocrResult.size());
// LOGD("jni ocr ocrresult[0].pre_res size:%ld", ocrResult[0].pre_res.size());
// LOGD("jni ocr ocrresult[0][0]:%s", ocrResult[0].pre_res[0].c_str());
auto ocr_result = env->FindClass("com/wzt/yolov5/ocr/OCRResult");
auto cid = env->GetMethodID(ocr_result, "<init>", "([D[DLjava/lang/String;)V");
jobjectArray ret = env->NewObjectArray(ocrResult.size(), ocr_result, nullptr);
int i = 0;
for (auto &info : ocrResult) {
// boxScore
env->PushLocalFrame(1);
jdoubleArray boxScoreData = env->NewDoubleArray(1);
auto *bsnum = new jdouble[1];
for (int j = 0; j < 1; ++j) {
*(bsnum + j) = info.box_score;
}
env->SetDoubleArrayRegion(boxScoreData, 0, 1, bsnum);
delete[] bsnum;
// text
char *cp = new char;
for (auto &pre_re : info.pre_res) {
strcat(cp, pre_re.c_str());
}
jstring text = str2jstring(env, cp);
delete cp;
// boxs
jdoubleArray boxsData = env->NewDoubleArray(info.boxes.size() * 2);
auto *bnum = new jdouble[info.boxes.size() * 2];
for (int j = 0; j < info.boxes.size(); j++) {
*(bnum + j * 2) = info.boxes[j].x;
*(bnum + j * 2 + 1) = info.boxes[j].y;
}
env->SetDoubleArrayRegion(boxsData, 0, info.boxes.size() * 2, bnum);
delete[] bnum;
// 合并一下
jobject obj = env->NewObject(ocr_result, cid, boxScoreData, boxsData, text);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
// LOGD("jni ocr return");
return ret;
}
/*********************************************************************************************
ENet
********************************************************************************************/
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_ENet_init(JNIEnv *env, jclass, jobject assetManager, jboolean useGPU) {
if (ENet::detector != nullptr) {
delete ENet::detector;
ENet::detector = nullptr;
}
if (ENet::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
ENet::detector = new ENet(mgr, useGPU);
}
}
extern "C" JNIEXPORT jfloatArray JNICALL
Java_com_wzt_yolov5_ENet_detect(JNIEnv *env, jclass, jobject image) {
auto result = ENet::detector->detect_enet(env, image);
int output_w = result.w;
int output_h = result.h;
// LOGD("jni enet output w:%d h:%d", output_w, output_h);
auto *output = new jfloat[output_w * output_h];
for (int h = 0; h < output_h; h++) {
for (int w = 0; w < output_w; w++) {
output[h * output_w + w] = result.row(h)[w];
}
}
jfloatArray jfloats = env->NewFloatArray(output_w * output_h);
if (jfloats == nullptr) {
return nullptr;
}
env->SetFloatArrayRegion(jfloats, 0, output_w * output_h, output);
delete[] output;
return jfloats;
}
/*********************************************************************************************
MobileNetv3_Seg
********************************************************************************************/
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_MbnSeg_init(JNIEnv *env, jclass, jobject assetManager, jboolean useGPU) {
if (MBNV3Seg::detector != nullptr) {
delete MBNV3Seg::detector;
MBNV3Seg::detector = nullptr;
}
if (MBNV3Seg::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
MBNV3Seg::detector = new MBNV3Seg(mgr, useGPU);
}
}
extern "C" JNIEXPORT jfloatArray JNICALL
Java_com_wzt_yolov5_MbnSeg_detect(JNIEnv *env, jclass, jobject image) {
auto result = MBNV3Seg::detector->detect_mbnseg(env, image);
int output_w = result.w;
int output_h = result.h;
// LOGD("jni mbnv3seg output w:%d h:%d", output_w, output_h);
auto *output = new jfloat[output_w * output_h];
for (int h = 0; h < output_h; h++) {
for (int w = 0; w < output_w; w++) {
output[h * output_w + w] = result.row(h)[w];
}
}
jfloatArray jfloats = env->NewFloatArray(output_w * output_h);
if (jfloats == nullptr) {
return nullptr;
}
env->SetFloatArrayRegion(jfloats, 0, output_w * output_h, output);
delete[] output;
return jfloats;
}
/*********************************************************************************************
MobileNetv2_FCN
********************************************************************************************/
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_MbnFCN_init(JNIEnv *env, jclass, jobject assetManager, jboolean useGPU) {
if (MbnFCN::detector != nullptr) {
delete MbnFCN::detector;
MbnFCN::detector = nullptr;
}
if (MbnFCN::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
MbnFCN::detector = new MbnFCN(mgr, useGPU);
}
}
extern "C" JNIEXPORT jfloatArray JNICALL
Java_com_wzt_yolov5_MbnFCN_detect(JNIEnv *env, jclass, jobject image) {
auto result = MbnFCN::detector->detect_mbnfcn(env, image);
int output_w = result.w;
int output_h = result.h;
// LOGD("jni mbnfcn output w:%d h:%d", output_w, output_h);
auto *output = new jfloat[output_w * output_h];
for (int h = 0; h < output_h; h++) {
for (int w = 0; w < output_w; w++) {
output[h * output_w + w] = result.row(h)[w];
}
}
jfloatArray jfloats = env->NewFloatArray(output_w * output_h);
if (jfloats == nullptr) {
return nullptr;
}
env->SetFloatArrayRegion(jfloats, 0, output_w * output_h, output);
delete[] output;
return jfloats;
}
/*********************************************************************************************
Face_Landmark
********************************************************************************************/
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_FaceLandmark_init(JNIEnv *env, jclass clazz, jobject assetManager, jboolean useGPU) {
if (FaceLandmark::detector != nullptr) {
delete FaceLandmark::detector;
FaceLandmark::detector = nullptr;
}
if (FaceLandmark::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
FaceLandmark::detector = new FaceLandmark(mgr, useGPU);
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_FaceLandmark_detect(JNIEnv *env, jclass clazz, jobject image) {
auto result = FaceLandmark::detector->detect(env, image);
auto box_cls = env->FindClass("com/wzt/yolov5/FaceKeyPoint");
auto cid = env->GetMethodID(box_cls, "<init>", "(FF)V");
jobjectArray ret = env->NewObjectArray(result.size(), box_cls, nullptr);
int i = 0;
for (auto &keypoint : result) {
env->PushLocalFrame(1);
jobject obj = env->NewObject(box_cls, cid, keypoint.p.x, keypoint.p.y);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
return ret;
}
/*********************************************************************************************
DBFace
********************************************************************************************/
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_DBFace_init(JNIEnv *env, jclass clazz, jobject assetManager, jboolean useGPU) {
if (DBFace::detector != nullptr) {
delete DBFace::detector;
DBFace::detector = nullptr;
}
if (DBFace::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
DBFace::detector = new DBFace(mgr, useGPU);
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_DBFace_detect(JNIEnv *env, jclass clazz, jobject image, jdouble threshold, jdouble nms_threshold) {
auto result = DBFace::detector->detect(env, image, threshold, nms_threshold);
// LOGD("jni dbface size:%d %f %f", result.size(), threshold, nms_threshold);
auto box_cls = env->FindClass("com/wzt/yolov5/KeyPoint");
auto cid = env->GetMethodID(box_cls, "<init>", "([F[FFFFFF)V");
jobjectArray ret = env->NewObjectArray(result.size(), box_cls, nullptr);
int i = 0;
int KEY_NUM = 5;
for (auto &keypoint : result) {
env->PushLocalFrame(1);
float x[KEY_NUM];
float y[KEY_NUM];
for (int j = 0; j < KEY_NUM; j++) {
x[j] = keypoint.landmark.x[j];
y[j] = keypoint.landmark.y[j];
}
jfloatArray xs = env->NewFloatArray(KEY_NUM);
env->SetFloatArrayRegion(xs, 0, KEY_NUM, x);
jfloatArray ys = env->NewFloatArray(KEY_NUM);
env->SetFloatArrayRegion(ys, 0, KEY_NUM, y);
jobject obj = env->NewObject(box_cls, cid, xs, ys,
keypoint.box.x, keypoint.box.y, keypoint.box.r, keypoint.box.b,
(float) keypoint.score);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
return ret;
}
/*********************************************************************************************
Light OpenPose
********************************************************************************************/
extern "C" JNIEXPORT void JNICALL
Java_com_wzt_yolov5_LightOpenPose_init(JNIEnv *env, jclass clazz, jobject assetManager, jboolean useGPU) {
if (LightOpenPose::detector != nullptr) {
delete LightOpenPose::detector;
LightOpenPose::detector = nullptr;
}
if (LightOpenPose::detector == nullptr) {
AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
LightOpenPose::detector = new LightOpenPose(mgr, useGPU);
}
}
extern "C" JNIEXPORT jobjectArray JNICALL
Java_com_wzt_yolov5_LightOpenPose_detect(JNIEnv *env, jclass clazz, jobject image) {
auto poses = LightOpenPose::detector->detect(env, image);
auto box_cls = env->FindClass("com/wzt/yolov5/OpenPoseKeyPoint");
auto cid = env->GetMethodID(box_cls, "<init>", "([F[FF)V");
jobjectArray ret = env->NewObjectArray(poses.size(), box_cls, nullptr);
int i = 0;
int KEY_NUM = 18;
for (auto &pose : poses) {
env->PushLocalFrame(1);
float x[KEY_NUM];
float y[KEY_NUM];
for (int j = 0; j < KEY_NUM; j++) {
x[j] = pose.keypoints[j].x;
y[j] = pose.keypoints[j].y;
}
jfloatArray xs = env->NewFloatArray(KEY_NUM);
env->SetFloatArrayRegion(xs, 0, KEY_NUM, x);
jfloatArray ys = env->NewFloatArray(KEY_NUM);
env->SetFloatArrayRegion(ys, 0, KEY_NUM, y);
jobject obj = env->NewObject(box_cls, cid, xs, ys, pose.score);
obj = env->PopLocalFrame(obj);
env->SetObjectArrayElement(ret, i++, obj);
}
return ret;
}

@ -0,0 +1,577 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _BASICTYPES_INCLUDED_
#define _BASICTYPES_INCLUDED_
namespace glslang {
//
// Basic type. Arrays, vectors, sampler details, etc., are orthogonal to this.
//
enum TBasicType {
EbtVoid,
EbtFloat,
EbtDouble,
EbtFloat16,
EbtInt8,
EbtUint8,
EbtInt16,
EbtUint16,
EbtInt,
EbtUint,
EbtInt64,
EbtUint64,
EbtBool,
EbtAtomicUint,
EbtSampler,
EbtStruct,
EbtBlock,
EbtAccStruct,
EbtReference,
EbtRayQuery,
// HLSL types that live only temporarily.
EbtString,
EbtNumTypes
};
//
// Storage qualifiers. Should align with different kinds of storage or
// resource or GLSL storage qualifier. Expansion is deprecated.
//
// N.B.: You probably DON'T want to add anything here, but rather just add it
// to the built-in variables. See the comment above TBuiltInVariable.
//
// A new built-in variable will normally be an existing qualifier, like 'in', 'out', etc.
// DO NOT follow the design pattern of, say EvqInstanceId, etc.
//
enum TStorageQualifier {
EvqTemporary, // For temporaries (within a function), read/write
EvqGlobal, // For globals read/write
EvqConst, // User-defined constant values, will be semantically constant and constant folded
EvqVaryingIn, // pipeline input, read only, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
EvqVaryingOut, // pipeline output, read/write, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
EvqUniform, // read only, shared with app
EvqBuffer, // read/write, shared with app
EvqShared, // compute shader's read/write 'shared' qualifier
EvqPayload,
EvqPayloadIn,
EvqHitAttr,
EvqCallableData,
EvqCallableDataIn,
// parameters
EvqIn, // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter
EvqOut, // also, for 'out' in the grammar before we know if it's a pipeline output or an 'out' parameter
EvqInOut,
EvqConstReadOnly, // input; also other read-only types having neither a constant value nor constant-value semantics
// built-ins read by vertex shader
EvqVertexId,
EvqInstanceId,
// built-ins written by vertex shader
EvqPosition,
EvqPointSize,
EvqClipVertex,
// built-ins read by fragment shader
EvqFace,
EvqFragCoord,
EvqPointCoord,
// built-ins written by fragment shader
EvqFragColor,
EvqFragDepth,
// end of list
EvqLast
};
//
// Subcategories of the TStorageQualifier, simply to give a direct mapping
// between built-in variable names and an numerical value (the enum).
//
// For backward compatibility, there is some redundancy between the
// TStorageQualifier and these. Existing members should both be maintained accurately.
// However, any new built-in variable (and any existing non-redundant one)
// must follow the pattern that the specific built-in is here, and only its
// general qualifier is in TStorageQualifier.
//
// Something like gl_Position, which is sometimes 'in' and sometimes 'out'
// shows up as two different built-in variables in a single stage, but
// only has a single enum in TBuiltInVariable, so both the
// TStorageQualifier and the TBuitinVariable are needed to distinguish
// between them.
//
enum TBuiltInVariable {
EbvNone,
EbvNumWorkGroups,
EbvWorkGroupSize,
EbvWorkGroupId,
EbvLocalInvocationId,
EbvGlobalInvocationId,
EbvLocalInvocationIndex,
EbvNumSubgroups,
EbvSubgroupID,
EbvSubGroupSize,
EbvSubGroupInvocation,
EbvSubGroupEqMask,
EbvSubGroupGeMask,
EbvSubGroupGtMask,
EbvSubGroupLeMask,
EbvSubGroupLtMask,
EbvSubgroupSize2,
EbvSubgroupInvocation2,
EbvSubgroupEqMask2,
EbvSubgroupGeMask2,
EbvSubgroupGtMask2,
EbvSubgroupLeMask2,
EbvSubgroupLtMask2,
EbvVertexId,
EbvInstanceId,
EbvVertexIndex,
EbvInstanceIndex,
EbvBaseVertex,
EbvBaseInstance,
EbvDrawId,
EbvPosition,
EbvPointSize,
EbvClipVertex,
EbvClipDistance,
EbvCullDistance,
EbvNormal,
EbvVertex,
EbvMultiTexCoord0,
EbvMultiTexCoord1,
EbvMultiTexCoord2,
EbvMultiTexCoord3,
EbvMultiTexCoord4,
EbvMultiTexCoord5,
EbvMultiTexCoord6,
EbvMultiTexCoord7,
EbvFrontColor,
EbvBackColor,
EbvFrontSecondaryColor,
EbvBackSecondaryColor,
EbvTexCoord,
EbvFogFragCoord,
EbvInvocationId,
EbvPrimitiveId,
EbvLayer,
EbvViewportIndex,
EbvPatchVertices,
EbvTessLevelOuter,
EbvTessLevelInner,
EbvBoundingBox,
EbvTessCoord,
EbvColor,
EbvSecondaryColor,
EbvFace,
EbvFragCoord,
EbvPointCoord,
EbvFragColor,
EbvFragData,
EbvFragDepth,
EbvFragStencilRef,
EbvSampleId,
EbvSamplePosition,
EbvSampleMask,
EbvHelperInvocation,
EbvBaryCoordNoPersp,
EbvBaryCoordNoPerspCentroid,
EbvBaryCoordNoPerspSample,
EbvBaryCoordSmooth,
EbvBaryCoordSmoothCentroid,
EbvBaryCoordSmoothSample,
EbvBaryCoordPullModel,
EbvViewIndex,
EbvDeviceIndex,
EbvShadingRateKHR,
EbvPrimitiveShadingRateKHR,
EbvFragSizeEXT,
EbvFragInvocationCountEXT,
EbvSecondaryFragDataEXT,
EbvSecondaryFragColorEXT,
EbvViewportMaskNV,
EbvSecondaryPositionNV,
EbvSecondaryViewportMaskNV,
EbvPositionPerViewNV,
EbvViewportMaskPerViewNV,
EbvFragFullyCoveredNV,
EbvFragmentSizeNV,
EbvInvocationsPerPixelNV,
// ray tracing
EbvLaunchId,
EbvLaunchSize,
EbvInstanceCustomIndex,
EbvGeometryIndex,
EbvWorldRayOrigin,
EbvWorldRayDirection,
EbvObjectRayOrigin,
EbvObjectRayDirection,
EbvRayTmin,
EbvRayTmax,
EbvHitT,
EbvHitKind,
EbvObjectToWorld,
EbvObjectToWorld3x4,
EbvWorldToObject,
EbvWorldToObject3x4,
EbvIncomingRayFlags,
// barycentrics
EbvBaryCoordNV,
EbvBaryCoordNoPerspNV,
// mesh shaders
EbvTaskCountNV,
EbvPrimitiveCountNV,
EbvPrimitiveIndicesNV,
EbvClipDistancePerViewNV,
EbvCullDistancePerViewNV,
EbvLayerPerViewNV,
EbvMeshViewCountNV,
EbvMeshViewIndicesNV,
// sm builtins
EbvWarpsPerSM,
EbvSMCount,
EbvWarpID,
EbvSMID,
// HLSL built-ins that live only temporarily, until they get remapped
// to one of the above.
EbvFragDepthGreater,
EbvFragDepthLesser,
EbvGsOutputStream,
EbvOutputPatch,
EbvInputPatch,
// structbuffer types
EbvAppendConsume, // no need to differentiate append and consume
EbvRWStructuredBuffer,
EbvStructuredBuffer,
EbvByteAddressBuffer,
EbvRWByteAddressBuffer,
EbvLast
};
// In this enum, order matters; users can assume higher precision is a bigger value
// and EpqNone is 0.
enum TPrecisionQualifier {
EpqNone = 0,
EpqLow,
EpqMedium,
EpqHigh
};
#ifdef GLSLANG_WEB
__inline const char* GetStorageQualifierString(TStorageQualifier q) { return ""; }
__inline const char* GetPrecisionQualifierString(TPrecisionQualifier p) { return ""; }
#else
// These will show up in error messages
__inline const char* GetStorageQualifierString(TStorageQualifier q)
{
switch (q) {
case EvqTemporary: return "temp"; break;
case EvqGlobal: return "global"; break;
case EvqConst: return "const"; break;
case EvqConstReadOnly: return "const (read only)"; break;
case EvqVaryingIn: return "in"; break;
case EvqVaryingOut: return "out"; break;
case EvqUniform: return "uniform"; break;
case EvqBuffer: return "buffer"; break;
case EvqShared: return "shared"; break;
case EvqIn: return "in"; break;
case EvqOut: return "out"; break;
case EvqInOut: return "inout"; break;
case EvqVertexId: return "gl_VertexId"; break;
case EvqInstanceId: return "gl_InstanceId"; break;
case EvqPosition: return "gl_Position"; break;
case EvqPointSize: return "gl_PointSize"; break;
case EvqClipVertex: return "gl_ClipVertex"; break;
case EvqFace: return "gl_FrontFacing"; break;
case EvqFragCoord: return "gl_FragCoord"; break;
case EvqPointCoord: return "gl_PointCoord"; break;
case EvqFragColor: return "fragColor"; break;
case EvqFragDepth: return "gl_FragDepth"; break;
case EvqPayload: return "rayPayloadNV"; break;
case EvqPayloadIn: return "rayPayloadInNV"; break;
case EvqHitAttr: return "hitAttributeNV"; break;
case EvqCallableData: return "callableDataNV"; break;
case EvqCallableDataIn: return "callableDataInNV"; break;
default: return "unknown qualifier";
}
}
__inline const char* GetBuiltInVariableString(TBuiltInVariable v)
{
switch (v) {
case EbvNone: return "";
case EbvNumWorkGroups: return "NumWorkGroups";
case EbvWorkGroupSize: return "WorkGroupSize";
case EbvWorkGroupId: return "WorkGroupID";
case EbvLocalInvocationId: return "LocalInvocationID";
case EbvGlobalInvocationId: return "GlobalInvocationID";
case EbvLocalInvocationIndex: return "LocalInvocationIndex";
case EbvNumSubgroups: return "NumSubgroups";
case EbvSubgroupID: return "SubgroupID";
case EbvSubGroupSize: return "SubGroupSize";
case EbvSubGroupInvocation: return "SubGroupInvocation";
case EbvSubGroupEqMask: return "SubGroupEqMask";
case EbvSubGroupGeMask: return "SubGroupGeMask";
case EbvSubGroupGtMask: return "SubGroupGtMask";
case EbvSubGroupLeMask: return "SubGroupLeMask";
case EbvSubGroupLtMask: return "SubGroupLtMask";
case EbvSubgroupSize2: return "SubgroupSize";
case EbvSubgroupInvocation2: return "SubgroupInvocationID";
case EbvSubgroupEqMask2: return "SubgroupEqMask";
case EbvSubgroupGeMask2: return "SubgroupGeMask";
case EbvSubgroupGtMask2: return "SubgroupGtMask";
case EbvSubgroupLeMask2: return "SubgroupLeMask";
case EbvSubgroupLtMask2: return "SubgroupLtMask";
case EbvVertexId: return "VertexId";
case EbvInstanceId: return "InstanceId";
case EbvVertexIndex: return "VertexIndex";
case EbvInstanceIndex: return "InstanceIndex";
case EbvBaseVertex: return "BaseVertex";
case EbvBaseInstance: return "BaseInstance";
case EbvDrawId: return "DrawId";
case EbvPosition: return "Position";
case EbvPointSize: return "PointSize";
case EbvClipVertex: return "ClipVertex";
case EbvClipDistance: return "ClipDistance";
case EbvCullDistance: return "CullDistance";
case EbvNormal: return "Normal";
case EbvVertex: return "Vertex";
case EbvMultiTexCoord0: return "MultiTexCoord0";
case EbvMultiTexCoord1: return "MultiTexCoord1";
case EbvMultiTexCoord2: return "MultiTexCoord2";
case EbvMultiTexCoord3: return "MultiTexCoord3";
case EbvMultiTexCoord4: return "MultiTexCoord4";
case EbvMultiTexCoord5: return "MultiTexCoord5";
case EbvMultiTexCoord6: return "MultiTexCoord6";
case EbvMultiTexCoord7: return "MultiTexCoord7";
case EbvFrontColor: return "FrontColor";
case EbvBackColor: return "BackColor";
case EbvFrontSecondaryColor: return "FrontSecondaryColor";
case EbvBackSecondaryColor: return "BackSecondaryColor";
case EbvTexCoord: return "TexCoord";
case EbvFogFragCoord: return "FogFragCoord";
case EbvInvocationId: return "InvocationID";
case EbvPrimitiveId: return "PrimitiveID";
case EbvLayer: return "Layer";
case EbvViewportIndex: return "ViewportIndex";
case EbvPatchVertices: return "PatchVertices";
case EbvTessLevelOuter: return "TessLevelOuter";
case EbvTessLevelInner: return "TessLevelInner";
case EbvBoundingBox: return "BoundingBox";
case EbvTessCoord: return "TessCoord";
case EbvColor: return "Color";
case EbvSecondaryColor: return "SecondaryColor";
case EbvFace: return "Face";
case EbvFragCoord: return "FragCoord";
case EbvPointCoord: return "PointCoord";
case EbvFragColor: return "FragColor";
case EbvFragData: return "FragData";
case EbvFragDepth: return "FragDepth";
case EbvFragStencilRef: return "FragStencilRef";
case EbvSampleId: return "SampleId";
case EbvSamplePosition: return "SamplePosition";
case EbvSampleMask: return "SampleMaskIn";
case EbvHelperInvocation: return "HelperInvocation";
case EbvBaryCoordNoPersp: return "BaryCoordNoPersp";
case EbvBaryCoordNoPerspCentroid: return "BaryCoordNoPerspCentroid";
case EbvBaryCoordNoPerspSample: return "BaryCoordNoPerspSample";
case EbvBaryCoordSmooth: return "BaryCoordSmooth";
case EbvBaryCoordSmoothCentroid: return "BaryCoordSmoothCentroid";
case EbvBaryCoordSmoothSample: return "BaryCoordSmoothSample";
case EbvBaryCoordPullModel: return "BaryCoordPullModel";
case EbvViewIndex: return "ViewIndex";
case EbvDeviceIndex: return "DeviceIndex";
case EbvFragSizeEXT: return "FragSizeEXT";
case EbvFragInvocationCountEXT: return "FragInvocationCountEXT";
case EbvSecondaryFragDataEXT: return "SecondaryFragDataEXT";
case EbvSecondaryFragColorEXT: return "SecondaryFragColorEXT";
case EbvViewportMaskNV: return "ViewportMaskNV";
case EbvSecondaryPositionNV: return "SecondaryPositionNV";
case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
case EbvPositionPerViewNV: return "PositionPerViewNV";
case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
case EbvFragFullyCoveredNV: return "FragFullyCoveredNV";
case EbvFragmentSizeNV: return "FragmentSizeNV";
case EbvInvocationsPerPixelNV: return "InvocationsPerPixelNV";
case EbvLaunchId: return "LaunchIdNV";
case EbvLaunchSize: return "LaunchSizeNV";
case EbvInstanceCustomIndex: return "InstanceCustomIndexNV";
case EbvGeometryIndex: return "GeometryIndexEXT";
case EbvWorldRayOrigin: return "WorldRayOriginNV";
case EbvWorldRayDirection: return "WorldRayDirectionNV";
case EbvObjectRayOrigin: return "ObjectRayOriginNV";
case EbvObjectRayDirection: return "ObjectRayDirectionNV";
case EbvRayTmin: return "ObjectRayTminNV";
case EbvRayTmax: return "ObjectRayTmaxNV";
case EbvHitT: return "HitTNV";
case EbvHitKind: return "HitKindNV";
case EbvIncomingRayFlags: return "IncomingRayFlagsNV";
case EbvObjectToWorld: return "ObjectToWorldNV";
case EbvWorldToObject: return "WorldToObjectNV";
case EbvBaryCoordNV: return "BaryCoordNV";
case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
case EbvTaskCountNV: return "TaskCountNV";
case EbvPrimitiveCountNV: return "PrimitiveCountNV";
case EbvPrimitiveIndicesNV: return "PrimitiveIndicesNV";
case EbvClipDistancePerViewNV: return "ClipDistancePerViewNV";
case EbvCullDistancePerViewNV: return "CullDistancePerViewNV";
case EbvLayerPerViewNV: return "LayerPerViewNV";
case EbvMeshViewCountNV: return "MeshViewCountNV";
case EbvMeshViewIndicesNV: return "MeshViewIndicesNV";
case EbvWarpsPerSM: return "WarpsPerSMNV";
case EbvSMCount: return "SMCountNV";
case EbvWarpID: return "WarpIDNV";
case EbvSMID: return "SMIDNV";
case EbvShadingRateKHR: return "ShadingRateKHR";
case EbvPrimitiveShadingRateKHR: return "PrimitiveShadingRateKHR";
default: return "unknown built-in variable";
}
}
__inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
{
switch (p) {
case EpqNone: return ""; break;
case EpqLow: return "lowp"; break;
case EpqMedium: return "mediump"; break;
case EpqHigh: return "highp"; break;
default: return "unknown precision qualifier";
}
}
#endif
__inline bool isTypeSignedInt(TBasicType type)
{
switch (type) {
case EbtInt8:
case EbtInt16:
case EbtInt:
case EbtInt64:
return true;
default:
return false;
}
}
__inline bool isTypeUnsignedInt(TBasicType type)
{
switch (type) {
case EbtUint8:
case EbtUint16:
case EbtUint:
case EbtUint64:
return true;
default:
return false;
}
}
__inline bool isTypeInt(TBasicType type)
{
return isTypeSignedInt(type) || isTypeUnsignedInt(type);
}
__inline bool isTypeFloat(TBasicType type)
{
switch (type) {
case EbtFloat:
case EbtDouble:
case EbtFloat16:
return true;
default:
return false;
}
}
__inline int getTypeRank(TBasicType type)
{
int res = -1;
switch(type) {
case EbtInt8:
case EbtUint8:
res = 0;
break;
case EbtInt16:
case EbtUint16:
res = 1;
break;
case EbtInt:
case EbtUint:
res = 2;
break;
case EbtInt64:
case EbtUint64:
res = 3;
break;
default:
assert(false);
break;
}
return res;
}
} // end namespace glslang
#endif // _BASICTYPES_INCLUDED_

@ -0,0 +1,291 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _COMMON_INCLUDED_
#define _COMMON_INCLUDED_
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#if defined(__ANDROID__) || (defined(_MSC_VER) && _MSC_VER < 1700)
#include <sstream>
namespace std {
template<typename T>
std::string to_string(const T& val) {
std::ostringstream os;
os << val;
return os.str();
}
}
#endif
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || defined MINGW_HAS_SECURE_API
#include <basetsd.h>
#ifndef snprintf
#define snprintf sprintf_s
#endif
#define safe_vsprintf(buf,max,format,args) vsnprintf_s((buf), (max), (max), (format), (args))
#elif defined (solaris)
#define safe_vsprintf(buf,max,format,args) vsnprintf((buf), (max), (format), (args))
#include <sys/int_types.h>
#define UINT_PTR uintptr_t
#else
#define safe_vsprintf(buf,max,format,args) vsnprintf((buf), (max), (format), (args))
#include <stdint.h>
#define UINT_PTR uintptr_t
#endif
#if defined(_MSC_VER) && _MSC_VER < 1800
#include <stdlib.h>
inline long long int strtoll (const char* str, char** endptr, int base)
{
return _strtoi64(str, endptr, base);
}
inline unsigned long long int strtoull (const char* str, char** endptr, int base)
{
return _strtoui64(str, endptr, base);
}
inline long long int atoll (const char* str)
{
return strtoll(str, NULL, 10);
}
#endif
#if defined(_MSC_VER)
#define strdup _strdup
#endif
/* windows only pragma */
#ifdef _MSC_VER
#pragma warning(disable : 4786) // Don't warn about too long identifiers
#pragma warning(disable : 4514) // unused inline method
#pragma warning(disable : 4201) // nameless union
#endif
#include "PoolAlloc.h"
//
// Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
//
#define POOL_ALLOCATOR_NEW_DELETE(A) \
void* operator new(size_t s) { return (A).allocate(s); } \
void* operator new(size_t, void *_Where) { return (_Where); } \
void operator delete(void*) { } \
void operator delete(void *, void *) { } \
void* operator new[](size_t s) { return (A).allocate(s); } \
void* operator new[](size_t, void *_Where) { return (_Where); } \
void operator delete[](void*) { } \
void operator delete[](void *, void *) { }
namespace glslang {
//
// Pool version of string.
//
typedef pool_allocator<char> TStringAllocator;
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator> TString;
} // end namespace glslang
// Repackage the std::hash for use by unordered map/set with a TString key.
namespace std {
template<> struct hash<glslang::TString> {
std::size_t operator()(const glslang::TString& s) const
{
const unsigned _FNV_offset_basis = 2166136261U;
const unsigned _FNV_prime = 16777619U;
unsigned _Val = _FNV_offset_basis;
size_t _Count = s.size();
const char* _First = s.c_str();
for (size_t _Next = 0; _Next < _Count; ++_Next)
{
_Val ^= (unsigned)_First[_Next];
_Val *= _FNV_prime;
}
return _Val;
}
};
}
namespace glslang {
inline TString* NewPoolTString(const char* s)
{
void* memory = GetThreadPoolAllocator().allocate(sizeof(TString));
return new(memory) TString(s);
}
template<class T> inline T* NewPoolObject(T*)
{
return new(GetThreadPoolAllocator().allocate(sizeof(T))) T;
}
template<class T> inline T* NewPoolObject(T, int instances)
{
return new(GetThreadPoolAllocator().allocate(instances * sizeof(T))) T[instances];
}
//
// Pool allocator versions of vectors, lists, and maps
//
template <class T> class TVector : public std::vector<T, pool_allocator<T> > {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
typedef typename std::vector<T, pool_allocator<T> >::size_type size_type;
TVector() : std::vector<T, pool_allocator<T> >() {}
TVector(const pool_allocator<T>& a) : std::vector<T, pool_allocator<T> >(a) {}
TVector(size_type i) : std::vector<T, pool_allocator<T> >(i) {}
TVector(size_type i, const T& val) : std::vector<T, pool_allocator<T> >(i, val) {}
};
template <class T> class TList : public std::list<T, pool_allocator<T> > {
};
template <class K, class D, class CMP = std::less<K> >
class TMap : public std::map<K, D, CMP, pool_allocator<std::pair<K const, D> > > {
};
template <class K, class D, class HASH = std::hash<K>, class PRED = std::equal_to<K> >
class TUnorderedMap : public std::unordered_map<K, D, HASH, PRED, pool_allocator<std::pair<K const, D> > > {
};
//
// Persistent string memory. Should only be used for strings that survive
// across compiles/links.
//
typedef std::basic_string<char> TPersistString;
//
// templatized min and max functions.
//
template <class T> T Min(const T a, const T b) { return a < b ? a : b; }
template <class T> T Max(const T a, const T b) { return a > b ? a : b; }
//
// Create a TString object from an integer.
//
#if defined _MSC_VER || defined MINGW_HAS_SECURE_API
inline const TString String(const int i, const int base = 10)
{
char text[16]; // 32 bit ints are at most 10 digits in base 10
_itoa_s(i, text, sizeof(text), base);
return text;
}
#else
inline const TString String(const int i, const int /*base*/ = 10)
{
char text[16]; // 32 bit ints are at most 10 digits in base 10
// we assume base 10 for all cases
snprintf(text, sizeof(text), "%d", i);
return text;
}
#endif
struct TSourceLoc {
void init()
{
name = nullptr; string = 0; line = 0; column = 0;
}
void init(int stringNum) { init(); string = stringNum; }
// Returns the name if it exists. Otherwise, returns the string number.
std::string getStringNameOrNum(bool quoteStringName = true) const
{
if (name != nullptr) {
TString qstr = quoteStringName ? ("\"" + *name + "\"") : *name;
std::string ret_str(qstr.c_str());
return ret_str;
}
return std::to_string((long long)string);
}
const char* getFilename() const
{
if (name == nullptr)
return nullptr;
return name->c_str();
}
const char* getFilenameStr() const { return name == nullptr ? "" : name->c_str(); }
TString* name; // descriptive name for this string, when a textual name is available, otherwise nullptr
int string;
int line;
int column;
};
class TPragmaTable : public TMap<TString, TString> {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
};
const int MaxTokenLength = 1024;
template <class T> bool IsPow2(T powerOf2)
{
if (powerOf2 <= 0)
return false;
return (powerOf2 & (powerOf2 - 1)) == 0;
}
// Round number up to a multiple of the given powerOf2, which is not
// a power, just a number that must be a power of 2.
template <class T> void RoundToPow2(T& number, int powerOf2)
{
assert(IsPow2(powerOf2));
number = (number + powerOf2 - 1) & ~(powerOf2 - 1);
}
template <class T> bool IsMultipleOfPow2(T number, int powerOf2)
{
assert(IsPow2(powerOf2));
return ! (number & (powerOf2 - 1));
}
} // end namespace glslang
#endif // _COMMON_INCLUDED_

@ -0,0 +1,974 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2013 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _CONSTANT_UNION_INCLUDED_
#define _CONSTANT_UNION_INCLUDED_
#include "../Include/Common.h"
#include "../Include/BaseTypes.h"
namespace glslang {
class TConstUnion {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TConstUnion() : iConst(0), type(EbtInt) { }
void setI8Const(signed char i)
{
i8Const = i;
type = EbtInt8;
}
void setU8Const(unsigned char u)
{
u8Const = u;
type = EbtUint8;
}
void setI16Const(signed short i)
{
i16Const = i;
type = EbtInt16;
}
void setU16Const(unsigned short u)
{
u16Const = u;
type = EbtUint16;
}
void setIConst(int i)
{
iConst = i;
type = EbtInt;
}
void setUConst(unsigned int u)
{
uConst = u;
type = EbtUint;
}
void setI64Const(long long i64)
{
i64Const = i64;
type = EbtInt64;
}
void setU64Const(unsigned long long u64)
{
u64Const = u64;
type = EbtUint64;
}
void setDConst(double d)
{
dConst = d;
type = EbtDouble;
}
void setBConst(bool b)
{
bConst = b;
type = EbtBool;
}
void setSConst(const TString* s)
{
sConst = s;
type = EbtString;
}
signed char getI8Const() const { return i8Const; }
unsigned char getU8Const() const { return u8Const; }
signed short getI16Const() const { return i16Const; }
unsigned short getU16Const() const { return u16Const; }
int getIConst() const { return iConst; }
unsigned int getUConst() const { return uConst; }
long long getI64Const() const { return i64Const; }
unsigned long long getU64Const() const { return u64Const; }
double getDConst() const { return dConst; }
bool getBConst() const { return bConst; }
const TString* getSConst() const { return sConst; }
bool operator==(const signed char i) const
{
if (i == i8Const)
return true;
return false;
}
bool operator==(const unsigned char u) const
{
if (u == u8Const)
return true;
return false;
}
bool operator==(const signed short i) const
{
if (i == i16Const)
return true;
return false;
}
bool operator==(const unsigned short u) const
{
if (u == u16Const)
return true;
return false;
}
bool operator==(const int i) const
{
if (i == iConst)
return true;
return false;
}
bool operator==(const unsigned int u) const
{
if (u == uConst)
return true;
return false;
}
bool operator==(const long long i64) const
{
if (i64 == i64Const)
return true;
return false;
}
bool operator==(const unsigned long long u64) const
{
if (u64 == u64Const)
return true;
return false;
}
bool operator==(const double d) const
{
if (d == dConst)
return true;
return false;
}
bool operator==(const bool b) const
{
if (b == bConst)
return true;
return false;
}
bool operator==(const TConstUnion& constant) const
{
if (constant.type != type)
return false;
switch (type) {
case EbtInt:
if (constant.iConst == iConst)
return true;
break;
case EbtUint:
if (constant.uConst == uConst)
return true;
break;
case EbtBool:
if (constant.bConst == bConst)
return true;
break;
case EbtDouble:
if (constant.dConst == dConst)
return true;
break;
#ifndef GLSLANG_WEB
case EbtInt16:
if (constant.i16Const == i16Const)
return true;
break;
case EbtUint16:
if (constant.u16Const == u16Const)
return true;
break;
case EbtInt8:
if (constant.i8Const == i8Const)
return true;
break;
case EbtUint8:
if (constant.u8Const == u8Const)
return true;
break;
case EbtInt64:
if (constant.i64Const == i64Const)
return true;
break;
case EbtUint64:
if (constant.u64Const == u64Const)
return true;
break;
#endif
default:
assert(false && "Default missing");
}
return false;
}
bool operator!=(const signed char i) const
{
return !operator==(i);
}
bool operator!=(const unsigned char u) const
{
return !operator==(u);
}
bool operator!=(const signed short i) const
{
return !operator==(i);
}
bool operator!=(const unsigned short u) const
{
return !operator==(u);
}
bool operator!=(const int i) const
{
return !operator==(i);
}
bool operator!=(const unsigned int u) const
{
return !operator==(u);
}
bool operator!=(const long long i) const
{
return !operator==(i);
}
bool operator!=(const unsigned long long u) const
{
return !operator==(u);
}
bool operator!=(const float f) const
{
return !operator==(f);
}
bool operator!=(const bool b) const
{
return !operator==(b);
}
bool operator!=(const TConstUnion& constant) const
{
return !operator==(constant);
}
bool operator>(const TConstUnion& constant) const
{
assert(type == constant.type);
switch (type) {
case EbtInt:
if (iConst > constant.iConst)
return true;
return false;
case EbtUint:
if (uConst > constant.uConst)
return true;
return false;
case EbtDouble:
if (dConst > constant.dConst)
return true;
return false;
#ifndef GLSLANG_WEB
case EbtInt8:
if (i8Const > constant.i8Const)
return true;
return false;
case EbtUint8:
if (u8Const > constant.u8Const)
return true;
return false;
case EbtInt16:
if (i16Const > constant.i16Const)
return true;
return false;
case EbtUint16:
if (u16Const > constant.u16Const)
return true;
return false;
case EbtInt64:
if (i64Const > constant.i64Const)
return true;
return false;
case EbtUint64:
if (u64Const > constant.u64Const)
return true;
return false;
#endif
default:
assert(false && "Default missing");
return false;
}
}
bool operator<(const TConstUnion& constant) const
{
assert(type == constant.type);
switch (type) {
#ifndef GLSLANG_WEB
case EbtInt8:
if (i8Const < constant.i8Const)
return true;
return false;
case EbtUint8:
if (u8Const < constant.u8Const)
return true;
return false;
case EbtInt16:
if (i16Const < constant.i16Const)
return true;
return false;
case EbtUint16:
if (u16Const < constant.u16Const)
return true;
return false;
case EbtInt64:
if (i64Const < constant.i64Const)
return true;
return false;
case EbtUint64:
if (u64Const < constant.u64Const)
return true;
return false;
#endif
case EbtDouble:
if (dConst < constant.dConst)
return true;
return false;
case EbtInt:
if (iConst < constant.iConst)
return true;
return false;
case EbtUint:
if (uConst < constant.uConst)
return true;
return false;
default:
assert(false && "Default missing");
return false;
}
}
TConstUnion operator+(const TConstUnion& constant) const
{
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst + constant.uConst); break;
case EbtDouble: returnValue.setDConst(dConst + constant.dConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const + constant.i8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const + constant.i16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const + constant.i64Const); break;
case EbtUint8: returnValue.setU8Const(u8Const + constant.u8Const); break;
case EbtUint16: returnValue.setU16Const(u16Const + constant.u16Const); break;
case EbtUint64: returnValue.setU64Const(u64Const + constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator-(const TConstUnion& constant) const
{
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst - constant.uConst); break;
case EbtDouble: returnValue.setDConst(dConst - constant.dConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const - constant.i8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const - constant.i16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const - constant.i64Const); break;
case EbtUint8: returnValue.setU8Const(u8Const - constant.u8Const); break;
case EbtUint16: returnValue.setU16Const(u16Const - constant.u16Const); break;
case EbtUint64: returnValue.setU64Const(u64Const - constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator*(const TConstUnion& constant) const
{
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst * constant.uConst); break;
case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const * constant.i8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const * constant.i16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const * constant.i64Const); break;
case EbtUint8: returnValue.setU8Const(u8Const * constant.u8Const); break;
case EbtUint16: returnValue.setU16Const(u16Const * constant.u16Const); break;
case EbtUint64: returnValue.setU64Const(u64Const * constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator%(const TConstUnion& constant) const
{
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst % constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const % constant.i8Const); break;
case EbtInt16: returnValue.setI8Const(i8Const % constant.i16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const % constant.i64Const); break;
case EbtUint8: returnValue.setU8Const(u8Const % constant.u8Const); break;
case EbtUint16: returnValue.setU16Const(u16Const % constant.u16Const); break;
case EbtUint64: returnValue.setU64Const(u64Const % constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator>>(const TConstUnion& constant) const
{
TConstUnion returnValue;
switch (type) {
#ifndef GLSLANG_WEB
case EbtInt8:
switch (constant.type) {
case EbtInt8: returnValue.setI8Const(i8Const >> constant.i8Const); break;
case EbtUint8: returnValue.setI8Const(i8Const >> constant.u8Const); break;
case EbtInt16: returnValue.setI8Const(i8Const >> constant.i16Const); break;
case EbtUint16: returnValue.setI8Const(i8Const >> constant.u16Const); break;
case EbtInt: returnValue.setI8Const(i8Const >> constant.iConst); break;
case EbtUint: returnValue.setI8Const(i8Const >> constant.uConst); break;
case EbtInt64: returnValue.setI8Const(i8Const >> constant.i64Const); break;
case EbtUint64: returnValue.setI8Const(i8Const >> constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
case EbtUint8:
switch (constant.type) {
case EbtInt8: returnValue.setU8Const(u8Const >> constant.i8Const); break;
case EbtUint8: returnValue.setU8Const(u8Const >> constant.u8Const); break;
case EbtInt16: returnValue.setU8Const(u8Const >> constant.i16Const); break;
case EbtUint16: returnValue.setU8Const(u8Const >> constant.u16Const); break;
case EbtInt: returnValue.setU8Const(u8Const >> constant.iConst); break;
case EbtUint: returnValue.setU8Const(u8Const >> constant.uConst); break;
case EbtInt64: returnValue.setU8Const(u8Const >> constant.i64Const); break;
case EbtUint64: returnValue.setU8Const(u8Const >> constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
case EbtInt16:
switch (constant.type) {
case EbtInt8: returnValue.setI16Const(i16Const >> constant.i8Const); break;
case EbtUint8: returnValue.setI16Const(i16Const >> constant.u8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const >> constant.i16Const); break;
case EbtUint16: returnValue.setI16Const(i16Const >> constant.u16Const); break;
case EbtInt: returnValue.setI16Const(i16Const >> constant.iConst); break;
case EbtUint: returnValue.setI16Const(i16Const >> constant.uConst); break;
case EbtInt64: returnValue.setI16Const(i16Const >> constant.i64Const); break;
case EbtUint64: returnValue.setI16Const(i16Const >> constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
case EbtUint16:
switch (constant.type) {
case EbtInt8: returnValue.setU16Const(u16Const >> constant.i8Const); break;
case EbtUint8: returnValue.setU16Const(u16Const >> constant.u8Const); break;
case EbtInt16: returnValue.setU16Const(u16Const >> constant.i16Const); break;
case EbtUint16: returnValue.setU16Const(u16Const >> constant.u16Const); break;
case EbtInt: returnValue.setU16Const(u16Const >> constant.iConst); break;
case EbtUint: returnValue.setU16Const(u16Const >> constant.uConst); break;
case EbtInt64: returnValue.setU16Const(u16Const >> constant.i64Const); break;
case EbtUint64: returnValue.setU16Const(u16Const >> constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
#endif
case EbtInt:
switch (constant.type) {
case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break;
case EbtUint: returnValue.setIConst(iConst >> constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setIConst(iConst >> constant.i8Const); break;
case EbtUint8: returnValue.setIConst(iConst >> constant.u8Const); break;
case EbtInt16: returnValue.setIConst(iConst >> constant.i16Const); break;
case EbtUint16: returnValue.setIConst(iConst >> constant.u16Const); break;
case EbtInt64: returnValue.setIConst(iConst >> constant.i64Const); break;
case EbtUint64: returnValue.setIConst(iConst >> constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
break;
case EbtUint:
switch (constant.type) {
case EbtInt: returnValue.setUConst(uConst >> constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst >> constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setUConst(uConst >> constant.i8Const); break;
case EbtUint8: returnValue.setUConst(uConst >> constant.u8Const); break;
case EbtInt16: returnValue.setUConst(uConst >> constant.i16Const); break;
case EbtUint16: returnValue.setUConst(uConst >> constant.u16Const); break;
case EbtInt64: returnValue.setUConst(uConst >> constant.i64Const); break;
case EbtUint64: returnValue.setUConst(uConst >> constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
break;
#ifndef GLSLANG_WEB
case EbtInt64:
switch (constant.type) {
case EbtInt8: returnValue.setI64Const(i64Const >> constant.i8Const); break;
case EbtUint8: returnValue.setI64Const(i64Const >> constant.u8Const); break;
case EbtInt16: returnValue.setI64Const(i64Const >> constant.i16Const); break;
case EbtUint16: returnValue.setI64Const(i64Const >> constant.u16Const); break;
case EbtInt: returnValue.setI64Const(i64Const >> constant.iConst); break;
case EbtUint: returnValue.setI64Const(i64Const >> constant.uConst); break;
case EbtInt64: returnValue.setI64Const(i64Const >> constant.i64Const); break;
case EbtUint64: returnValue.setI64Const(i64Const >> constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
case EbtUint64:
switch (constant.type) {
case EbtInt8: returnValue.setU64Const(u64Const >> constant.i8Const); break;
case EbtUint8: returnValue.setU64Const(u64Const >> constant.u8Const); break;
case EbtInt16: returnValue.setU64Const(u64Const >> constant.i16Const); break;
case EbtUint16: returnValue.setU64Const(u64Const >> constant.u16Const); break;
case EbtInt: returnValue.setU64Const(u64Const >> constant.iConst); break;
case EbtUint: returnValue.setU64Const(u64Const >> constant.uConst); break;
case EbtInt64: returnValue.setU64Const(u64Const >> constant.i64Const); break;
case EbtUint64: returnValue.setU64Const(u64Const >> constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
#endif
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator<<(const TConstUnion& constant) const
{
TConstUnion returnValue;
switch (type) {
#ifndef GLSLANG_WEB
case EbtInt8:
switch (constant.type) {
case EbtInt8: returnValue.setI8Const(i8Const << constant.i8Const); break;
case EbtUint8: returnValue.setI8Const(i8Const << constant.u8Const); break;
case EbtInt16: returnValue.setI8Const(i8Const << constant.i16Const); break;
case EbtUint16: returnValue.setI8Const(i8Const << constant.u16Const); break;
case EbtInt: returnValue.setI8Const(i8Const << constant.iConst); break;
case EbtUint: returnValue.setI8Const(i8Const << constant.uConst); break;
case EbtInt64: returnValue.setI8Const(i8Const << constant.i64Const); break;
case EbtUint64: returnValue.setI8Const(i8Const << constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
case EbtUint8:
switch (constant.type) {
case EbtInt8: returnValue.setU8Const(u8Const << constant.i8Const); break;
case EbtUint8: returnValue.setU8Const(u8Const << constant.u8Const); break;
case EbtInt16: returnValue.setU8Const(u8Const << constant.i16Const); break;
case EbtUint16: returnValue.setU8Const(u8Const << constant.u16Const); break;
case EbtInt: returnValue.setU8Const(u8Const << constant.iConst); break;
case EbtUint: returnValue.setU8Const(u8Const << constant.uConst); break;
case EbtInt64: returnValue.setU8Const(u8Const << constant.i64Const); break;
case EbtUint64: returnValue.setU8Const(u8Const << constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
case EbtInt16:
switch (constant.type) {
case EbtInt8: returnValue.setI16Const(i16Const << constant.i8Const); break;
case EbtUint8: returnValue.setI16Const(i16Const << constant.u8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const << constant.i16Const); break;
case EbtUint16: returnValue.setI16Const(i16Const << constant.u16Const); break;
case EbtInt: returnValue.setI16Const(i16Const << constant.iConst); break;
case EbtUint: returnValue.setI16Const(i16Const << constant.uConst); break;
case EbtInt64: returnValue.setI16Const(i16Const << constant.i64Const); break;
case EbtUint64: returnValue.setI16Const(i16Const << constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
case EbtUint16:
switch (constant.type) {
case EbtInt8: returnValue.setU16Const(u16Const << constant.i8Const); break;
case EbtUint8: returnValue.setU16Const(u16Const << constant.u8Const); break;
case EbtInt16: returnValue.setU16Const(u16Const << constant.i16Const); break;
case EbtUint16: returnValue.setU16Const(u16Const << constant.u16Const); break;
case EbtInt: returnValue.setU16Const(u16Const << constant.iConst); break;
case EbtUint: returnValue.setU16Const(u16Const << constant.uConst); break;
case EbtInt64: returnValue.setU16Const(u16Const << constant.i64Const); break;
case EbtUint64: returnValue.setU16Const(u16Const << constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
case EbtInt64:
switch (constant.type) {
case EbtInt8: returnValue.setI64Const(i64Const << constant.i8Const); break;
case EbtUint8: returnValue.setI64Const(i64Const << constant.u8Const); break;
case EbtInt16: returnValue.setI64Const(i64Const << constant.i16Const); break;
case EbtUint16: returnValue.setI64Const(i64Const << constant.u16Const); break;
case EbtInt: returnValue.setI64Const(i64Const << constant.iConst); break;
case EbtUint: returnValue.setI64Const(i64Const << constant.uConst); break;
case EbtInt64: returnValue.setI64Const(i64Const << constant.i64Const); break;
case EbtUint64: returnValue.setI64Const(i64Const << constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
case EbtUint64:
switch (constant.type) {
case EbtInt8: returnValue.setU64Const(u64Const << constant.i8Const); break;
case EbtUint8: returnValue.setU64Const(u64Const << constant.u8Const); break;
case EbtInt16: returnValue.setU64Const(u64Const << constant.i16Const); break;
case EbtUint16: returnValue.setU64Const(u64Const << constant.u16Const); break;
case EbtInt: returnValue.setU64Const(u64Const << constant.iConst); break;
case EbtUint: returnValue.setU64Const(u64Const << constant.uConst); break;
case EbtInt64: returnValue.setU64Const(u64Const << constant.i64Const); break;
case EbtUint64: returnValue.setU64Const(u64Const << constant.u64Const); break;
default: assert(false && "Default missing");
}
break;
#endif
case EbtInt:
switch (constant.type) {
case EbtInt: returnValue.setIConst(iConst << constant.iConst); break;
case EbtUint: returnValue.setIConst(iConst << constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setIConst(iConst << constant.i8Const); break;
case EbtUint8: returnValue.setIConst(iConst << constant.u8Const); break;
case EbtInt16: returnValue.setIConst(iConst << constant.i16Const); break;
case EbtUint16: returnValue.setIConst(iConst << constant.u16Const); break;
case EbtInt64: returnValue.setIConst(iConst << constant.i64Const); break;
case EbtUint64: returnValue.setIConst(iConst << constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
break;
case EbtUint:
switch (constant.type) {
case EbtInt: returnValue.setUConst(uConst << constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst << constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setUConst(uConst << constant.i8Const); break;
case EbtUint8: returnValue.setUConst(uConst << constant.u8Const); break;
case EbtInt16: returnValue.setUConst(uConst << constant.i16Const); break;
case EbtUint16: returnValue.setUConst(uConst << constant.u16Const); break;
case EbtInt64: returnValue.setUConst(uConst << constant.i64Const); break;
case EbtUint64: returnValue.setUConst(uConst << constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
break;
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator&(const TConstUnion& constant) const
{
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst & constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const & constant.i8Const); break;
case EbtUint8: returnValue.setU8Const(u8Const & constant.u8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const & constant.i16Const); break;
case EbtUint16: returnValue.setU16Const(u16Const & constant.u16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const & constant.i64Const); break;
case EbtUint64: returnValue.setU64Const(u64Const & constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator|(const TConstUnion& constant) const
{
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst | constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const | constant.i8Const); break;
case EbtUint8: returnValue.setU8Const(u8Const | constant.u8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const | constant.i16Const); break;
case EbtUint16: returnValue.setU16Const(u16Const | constant.u16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const | constant.i64Const); break;
case EbtUint64: returnValue.setU64Const(u64Const | constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator^(const TConstUnion& constant) const
{
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst ^ constant.uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(i8Const ^ constant.i8Const); break;
case EbtUint8: returnValue.setU8Const(u8Const ^ constant.u8Const); break;
case EbtInt16: returnValue.setI16Const(i16Const ^ constant.i16Const); break;
case EbtUint16: returnValue.setU16Const(u16Const ^ constant.u16Const); break;
case EbtInt64: returnValue.setI64Const(i64Const ^ constant.i64Const); break;
case EbtUint64: returnValue.setU64Const(u64Const ^ constant.u64Const); break;
#endif
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator~() const
{
TConstUnion returnValue;
switch (type) {
case EbtInt: returnValue.setIConst(~iConst); break;
case EbtUint: returnValue.setUConst(~uConst); break;
#ifndef GLSLANG_WEB
case EbtInt8: returnValue.setI8Const(~i8Const); break;
case EbtUint8: returnValue.setU8Const(~u8Const); break;
case EbtInt16: returnValue.setI16Const(~i16Const); break;
case EbtUint16: returnValue.setU16Const(~u16Const); break;
case EbtInt64: returnValue.setI64Const(~i64Const); break;
case EbtUint64: returnValue.setU64Const(~u64Const); break;
#endif
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator&&(const TConstUnion& constant) const
{
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
default: assert(false && "Default missing");
}
return returnValue;
}
TConstUnion operator||(const TConstUnion& constant) const
{
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
default: assert(false && "Default missing");
}
return returnValue;
}
TBasicType getType() const { return type; }
private:
union {
signed char i8Const; // used for i8vec, scalar int8s
unsigned char u8Const; // used for u8vec, scalar uint8s
signed short i16Const; // used for i16vec, scalar int16s
unsigned short u16Const; // used for u16vec, scalar uint16s
int iConst; // used for ivec, scalar ints
unsigned int uConst; // used for uvec, scalar uints
long long i64Const; // used for i64vec, scalar int64s
unsigned long long u64Const; // used for u64vec, scalar uint64s
bool bConst; // used for bvec, scalar bools
double dConst; // used for vec, dvec, mat, dmat, scalar floats and doubles
const TString* sConst; // string constant
};
TBasicType type;
};
// Encapsulate having a pointer to an array of TConstUnion,
// which only needs to be allocated if its size is going to be
// bigger than 0.
//
// One convenience is being able to use [] to go inside the array, instead
// of C++ assuming it as an array of pointers to vectors.
//
// General usage is that the size is known up front, and it is
// created once with the proper size.
//
class TConstUnionArray {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TConstUnionArray() : unionArray(nullptr) { }
virtual ~TConstUnionArray() { }
explicit TConstUnionArray(int size)
{
if (size == 0)
unionArray = nullptr;
else
unionArray = new TConstUnionVector(size);
}
TConstUnionArray(const TConstUnionArray& a) = default;
TConstUnionArray(const TConstUnionArray& a, int start, int size)
{
unionArray = new TConstUnionVector(size);
for (int i = 0; i < size; ++i)
(*unionArray)[i] = a[start + i];
}
// Use this constructor for a smear operation
TConstUnionArray(int size, const TConstUnion& val)
{
unionArray = new TConstUnionVector(size, val);
}
int size() const { return unionArray ? (int)unionArray->size() : 0; }
TConstUnion& operator[](size_t index) { return (*unionArray)[index]; }
const TConstUnion& operator[](size_t index) const { return (*unionArray)[index]; }
bool operator==(const TConstUnionArray& rhs) const
{
// this includes the case that both are unallocated
if (unionArray == rhs.unionArray)
return true;
if (! unionArray || ! rhs.unionArray)
return false;
return *unionArray == *rhs.unionArray;
}
bool operator!=(const TConstUnionArray& rhs) const { return ! operator==(rhs); }
double dot(const TConstUnionArray& rhs)
{
assert(rhs.unionArray->size() == unionArray->size());
double sum = 0.0;
for (size_t comp = 0; comp < unionArray->size(); ++comp)
sum += (*this)[comp].getDConst() * rhs[comp].getDConst();
return sum;
}
bool empty() const { return unionArray == nullptr; }
protected:
typedef TVector<TConstUnion> TConstUnionVector;
TConstUnionVector* unionArray;
};
} // end namespace glslang
#endif // _CONSTANT_UNION_INCLUDED_

@ -0,0 +1,144 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _INFOSINK_INCLUDED_
#define _INFOSINK_INCLUDED_
#include "../Include/Common.h"
#include <cmath>
namespace glslang {
//
// TPrefixType is used to centralize how info log messages start.
// See below.
//
enum TPrefixType {
EPrefixNone,
EPrefixWarning,
EPrefixError,
EPrefixInternalError,
EPrefixUnimplemented,
EPrefixNote
};
enum TOutputStream {
ENull = 0,
EDebugger = 0x01,
EStdOut = 0x02,
EString = 0x04,
};
//
// Encapsulate info logs for all objects that have them.
//
// The methods are a general set of tools for getting a variety of
// messages and types inserted into the log.
//
class TInfoSinkBase {
public:
TInfoSinkBase() : outputStream(4) {}
void erase() { sink.erase(); }
TInfoSinkBase& operator<<(const TPersistString& t) { append(t); return *this; }
TInfoSinkBase& operator<<(char c) { append(1, c); return *this; }
TInfoSinkBase& operator<<(const char* s) { append(s); return *this; }
TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; }
TInfoSinkBase& operator<<(unsigned int n) { append(String(n)); return *this; }
TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size];
snprintf(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? "%f" : "%g", n);
append(buf);
return *this; }
TInfoSinkBase& operator+(const TPersistString& t) { append(t); return *this; }
TInfoSinkBase& operator+(const TString& t) { append(t); return *this; }
TInfoSinkBase& operator<<(const TString& t) { append(t); return *this; }
TInfoSinkBase& operator+(const char* s) { append(s); return *this; }
const char* c_str() const { return sink.c_str(); }
void prefix(TPrefixType message) {
switch(message) {
case EPrefixNone: break;
case EPrefixWarning: append("WARNING: "); break;
case EPrefixError: append("ERROR: "); break;
case EPrefixInternalError: append("INTERNAL ERROR: "); break;
case EPrefixUnimplemented: append("UNIMPLEMENTED: "); break;
case EPrefixNote: append("NOTE: "); break;
default: append("UNKNOWN ERROR: "); break;
}
}
void location(const TSourceLoc& loc) {
const int maxSize = 24;
char locText[maxSize];
snprintf(locText, maxSize, ":%d", loc.line);
append(loc.getStringNameOrNum(false).c_str());
append(locText);
append(": ");
}
void message(TPrefixType message, const char* s) {
prefix(message);
append(s);
append("\n");
}
void message(TPrefixType message, const char* s, const TSourceLoc& loc) {
prefix(message);
location(loc);
append(s);
append("\n");
}
void setOutputStream(int output = 4)
{
outputStream = output;
}
protected:
void append(const char* s);
void append(int count, char c);
void append(const TPersistString& t);
void append(const TString& t);
void checkMem(size_t growth) { if (sink.capacity() < sink.size() + growth + 2)
sink.reserve(sink.capacity() + sink.capacity() / 2); }
void appendToStream(const char* s);
TPersistString sink;
int outputStream;
};
} // end namespace glslang
class TInfoSink {
public:
glslang::TInfoSinkBase info;
glslang::TInfoSinkBase debug;
};
#endif // _INFOSINK_INCLUDED_

@ -0,0 +1,44 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef __INITIALIZE_GLOBALS_INCLUDED_
#define __INITIALIZE_GLOBALS_INCLUDED_
namespace glslang {
bool InitializePoolIndex();
} // end namespace glslang
#endif // __INITIALIZE_GLOBALS_INCLUDED_

@ -0,0 +1,316 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _POOLALLOC_INCLUDED_
#define _POOLALLOC_INCLUDED_
#ifdef _DEBUG
# define GUARD_BLOCKS // define to enable guard block sanity checking
#endif
//
// This header defines an allocator that can be used to efficiently
// allocate a large number of small requests for heap memory, with the
// intention that they are not individually deallocated, but rather
// collectively deallocated at one time.
//
// This simultaneously
//
// * Makes each individual allocation much more efficient; the
// typical allocation is trivial.
// * Completely avoids the cost of doing individual deallocation.
// * Saves the trouble of tracking down and plugging a large class of leaks.
//
// Individual classes can use this allocator by supplying their own
// new and delete methods.
//
// STL containers can use this allocator by using the pool_allocator
// class as the allocator (second) template argument.
//
#include <cstddef>
#include <cstring>
#include <vector>
namespace glslang {
// If we are using guard blocks, we must track each individual
// allocation. If we aren't using guard blocks, these
// never get instantiated, so won't have any impact.
//
class TAllocation {
public:
TAllocation(size_t size, unsigned char* mem, TAllocation* prev = 0) :
size(size), mem(mem), prevAlloc(prev) {
// Allocations are bracketed:
// [allocationHeader][initialGuardBlock][userData][finalGuardBlock]
// This would be cleaner with if (guardBlockSize)..., but that
// makes the compiler print warnings about 0 length memsets,
// even with the if() protecting them.
# ifdef GUARD_BLOCKS
memset(preGuard(), guardBlockBeginVal, guardBlockSize);
memset(data(), userDataFill, size);
memset(postGuard(), guardBlockEndVal, guardBlockSize);
# endif
}
void check() const {
checkGuardBlock(preGuard(), guardBlockBeginVal, "before");
checkGuardBlock(postGuard(), guardBlockEndVal, "after");
}
void checkAllocList() const;
// Return total size needed to accommodate user buffer of 'size',
// plus our tracking data.
inline static size_t allocationSize(size_t size) {
return size + 2 * guardBlockSize + headerSize();
}
// Offset from surrounding buffer to get to user data buffer.
inline static unsigned char* offsetAllocation(unsigned char* m) {
return m + guardBlockSize + headerSize();
}
private:
void checkGuardBlock(unsigned char* blockMem, unsigned char val, const char* locText) const;
// Find offsets to pre and post guard blocks, and user data buffer
unsigned char* preGuard() const { return mem + headerSize(); }
unsigned char* data() const { return preGuard() + guardBlockSize; }
unsigned char* postGuard() const { return data() + size; }
size_t size; // size of the user data area
unsigned char* mem; // beginning of our allocation (pts to header)
TAllocation* prevAlloc; // prior allocation in the chain
const static unsigned char guardBlockBeginVal;
const static unsigned char guardBlockEndVal;
const static unsigned char userDataFill;
const static size_t guardBlockSize;
# ifdef GUARD_BLOCKS
inline static size_t headerSize() { return sizeof(TAllocation); }
# else
inline static size_t headerSize() { return 0; }
# endif
};
//
// There are several stacks. One is to track the pushing and popping
// of the user, and not yet implemented. The others are simply a
// repositories of free pages or used pages.
//
// Page stacks are linked together with a simple header at the beginning
// of each allocation obtained from the underlying OS. Multi-page allocations
// are returned to the OS. Individual page allocations are kept for future
// re-use.
//
// The "page size" used is not, nor must it match, the underlying OS
// page size. But, having it be about that size or equal to a set of
// pages is likely most optimal.
//
class TPoolAllocator {
public:
TPoolAllocator(int growthIncrement = 8*1024, int allocationAlignment = 16);
//
// Don't call the destructor just to free up the memory, call pop()
//
~TPoolAllocator();
//
// Call push() to establish a new place to pop memory too. Does not
// have to be called to get things started.
//
void push();
//
// Call pop() to free all memory allocated since the last call to push(),
// or if no last call to push, frees all memory since first allocation.
//
void pop();
//
// Call popAll() to free all memory allocated.
//
void popAll();
//
// Call allocate() to actually acquire memory. Returns 0 if no memory
// available, otherwise a properly aligned pointer to 'numBytes' of memory.
//
void* allocate(size_t numBytes);
//
// There is no deallocate. The point of this class is that
// deallocation can be skipped by the user of it, as the model
// of use is to simultaneously deallocate everything at once
// by calling pop(), and to not have to solve memory leak problems.
//
protected:
friend struct tHeader;
struct tHeader {
tHeader(tHeader* nextPage, size_t pageCount) :
#ifdef GUARD_BLOCKS
lastAllocation(0),
#endif
nextPage(nextPage), pageCount(pageCount) { }
~tHeader() {
#ifdef GUARD_BLOCKS
if (lastAllocation)
lastAllocation->checkAllocList();
#endif
}
#ifdef GUARD_BLOCKS
TAllocation* lastAllocation;
#endif
tHeader* nextPage;
size_t pageCount;
};
struct tAllocState {
size_t offset;
tHeader* page;
};
typedef std::vector<tAllocState> tAllocStack;
// Track allocations if and only if we're using guard blocks
#ifndef GUARD_BLOCKS
void* initializeAllocation(tHeader*, unsigned char* memory, size_t) {
#else
void* initializeAllocation(tHeader* block, unsigned char* memory, size_t numBytes) {
new(memory) TAllocation(numBytes, memory, block->lastAllocation);
block->lastAllocation = reinterpret_cast<TAllocation*>(memory);
#endif
// This is optimized entirely away if GUARD_BLOCKS is not defined.
return TAllocation::offsetAllocation(memory);
}
size_t pageSize; // granularity of allocation from the OS
size_t alignment; // all returned allocations will be aligned at
// this granularity, which will be a power of 2
size_t alignmentMask;
size_t headerSkip; // amount of memory to skip to make room for the
// header (basically, size of header, rounded
// up to make it aligned
size_t currentPageOffset; // next offset in top of inUseList to allocate from
tHeader* freeList; // list of popped memory
tHeader* inUseList; // list of all memory currently being used
tAllocStack stack; // stack of where to allocate from, to partition pool
int numCalls; // just an interesting statistic
size_t totalBytes; // just an interesting statistic
private:
TPoolAllocator& operator=(const TPoolAllocator&); // don't allow assignment operator
TPoolAllocator(const TPoolAllocator&); // don't allow default copy constructor
};
//
// There could potentially be many pools with pops happening at
// different times. But a simple use is to have a global pop
// with everyone using the same global allocator.
//
extern TPoolAllocator& GetThreadPoolAllocator();
void SetThreadPoolAllocator(TPoolAllocator* poolAllocator);
//
// This STL compatible allocator is intended to be used as the allocator
// parameter to templatized STL containers, like vector and map.
//
// It will use the pools for allocation, and not
// do any deallocation, but will still do destruction.
//
template<class T>
class pool_allocator {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T *pointer;
typedef const T *const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;
template<class Other>
struct rebind {
typedef pool_allocator<Other> other;
};
pointer address(reference x) const { return &x; }
const_pointer address(const_reference x) const { return &x; }
pool_allocator() : allocator(GetThreadPoolAllocator()) { }
pool_allocator(TPoolAllocator& a) : allocator(a) { }
pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }
template<class Other>
pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
pointer allocate(size_type n) {
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); }
pointer allocate(size_type n, const void*) {
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); }
void deallocate(void*, size_type) { }
void deallocate(pointer, size_type) { }
pointer _Charalloc(size_t n) {
return reinterpret_cast<pointer>(getAllocator().allocate(n)); }
void construct(pointer p, const T& val) { new ((void *)p) T(val); }
void destroy(pointer p) { p->T::~T(); }
bool operator==(const pool_allocator& rhs) const { return &getAllocator() == &rhs.getAllocator(); }
bool operator!=(const pool_allocator& rhs) const { return &getAllocator() != &rhs.getAllocator(); }
size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }
size_type max_size(int size) const { return static_cast<size_type>(-1) / size; }
TPoolAllocator& getAllocator() const { return allocator; }
protected:
pool_allocator& operator=(const pool_allocator&) { return *this; }
TPoolAllocator& allocator;
};
} // end namespace glslang
#endif // _POOLALLOC_INCLUDED_

@ -0,0 +1,150 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2013 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _RESOURCE_LIMITS_INCLUDED_
#define _RESOURCE_LIMITS_INCLUDED_
struct TLimits {
bool nonInductiveForLoops;
bool whileLoops;
bool doWhileLoops;
bool generalUniformIndexing;
bool generalAttributeMatrixVectorIndexing;
bool generalVaryingIndexing;
bool generalSamplerIndexing;
bool generalVariableIndexing;
bool generalConstantMatrixVectorIndexing;
};
struct TBuiltInResource {
int maxLights;
int maxClipPlanes;
int maxTextureUnits;
int maxTextureCoords;
int maxVertexAttribs;
int maxVertexUniformComponents;
int maxVaryingFloats;
int maxVertexTextureImageUnits;
int maxCombinedTextureImageUnits;
int maxTextureImageUnits;
int maxFragmentUniformComponents;
int maxDrawBuffers;
int maxVertexUniformVectors;
int maxVaryingVectors;
int maxFragmentUniformVectors;
int maxVertexOutputVectors;
int maxFragmentInputVectors;
int minProgramTexelOffset;
int maxProgramTexelOffset;
int maxClipDistances;
int maxComputeWorkGroupCountX;
int maxComputeWorkGroupCountY;
int maxComputeWorkGroupCountZ;
int maxComputeWorkGroupSizeX;
int maxComputeWorkGroupSizeY;
int maxComputeWorkGroupSizeZ;
int maxComputeUniformComponents;
int maxComputeTextureImageUnits;
int maxComputeImageUniforms;
int maxComputeAtomicCounters;
int maxComputeAtomicCounterBuffers;
int maxVaryingComponents;
int maxVertexOutputComponents;
int maxGeometryInputComponents;
int maxGeometryOutputComponents;
int maxFragmentInputComponents;
int maxImageUnits;
int maxCombinedImageUnitsAndFragmentOutputs;
int maxCombinedShaderOutputResources;
int maxImageSamples;
int maxVertexImageUniforms;
int maxTessControlImageUniforms;
int maxTessEvaluationImageUniforms;
int maxGeometryImageUniforms;
int maxFragmentImageUniforms;
int maxCombinedImageUniforms;
int maxGeometryTextureImageUnits;
int maxGeometryOutputVertices;
int maxGeometryTotalOutputComponents;
int maxGeometryUniformComponents;
int maxGeometryVaryingComponents;
int maxTessControlInputComponents;
int maxTessControlOutputComponents;
int maxTessControlTextureImageUnits;
int maxTessControlUniformComponents;
int maxTessControlTotalOutputComponents;
int maxTessEvaluationInputComponents;
int maxTessEvaluationOutputComponents;
int maxTessEvaluationTextureImageUnits;
int maxTessEvaluationUniformComponents;
int maxTessPatchComponents;
int maxPatchVertices;
int maxTessGenLevel;
int maxViewports;
int maxVertexAtomicCounters;
int maxTessControlAtomicCounters;
int maxTessEvaluationAtomicCounters;
int maxGeometryAtomicCounters;
int maxFragmentAtomicCounters;
int maxCombinedAtomicCounters;
int maxAtomicCounterBindings;
int maxVertexAtomicCounterBuffers;
int maxTessControlAtomicCounterBuffers;
int maxTessEvaluationAtomicCounterBuffers;
int maxGeometryAtomicCounterBuffers;
int maxFragmentAtomicCounterBuffers;
int maxCombinedAtomicCounterBuffers;
int maxAtomicCounterBufferSize;
int maxTransformFeedbackBuffers;
int maxTransformFeedbackInterleavedComponents;
int maxCullDistances;
int maxCombinedClipAndCullDistances;
int maxSamples;
int maxMeshOutputVerticesNV;
int maxMeshOutputPrimitivesNV;
int maxMeshWorkGroupSizeX_NV;
int maxMeshWorkGroupSizeY_NV;
int maxMeshWorkGroupSizeZ_NV;
int maxTaskWorkGroupSizeX_NV;
int maxTaskWorkGroupSizeY_NV;
int maxTaskWorkGroupSizeZ_NV;
int maxMeshViewCountNV;
int maxDualSourceDrawBuffersEXT;
TLimits limits;
};
#endif // _RESOURCE_LIMITS_INCLUDED_

@ -0,0 +1,176 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _SHHANDLE_INCLUDED_
#define _SHHANDLE_INCLUDED_
//
// Machine independent part of the compiler private objects
// sent as ShHandle to the driver.
//
// This should not be included by driver code.
//
#define SH_EXPORTING
#include "../Public/ShaderLang.h"
#include "../MachineIndependent/Versions.h"
#include "InfoSink.h"
class TCompiler;
class TLinker;
class TUniformMap;
//
// The base class used to back handles returned to the driver.
//
class TShHandleBase {
public:
TShHandleBase() { pool = new glslang::TPoolAllocator; }
virtual ~TShHandleBase() { delete pool; }
virtual TCompiler* getAsCompiler() { return 0; }
virtual TLinker* getAsLinker() { return 0; }
virtual TUniformMap* getAsUniformMap() { return 0; }
virtual glslang::TPoolAllocator* getPool() const { return pool; }
private:
glslang::TPoolAllocator* pool;
};
//
// The base class for the machine dependent linker to derive from
// for managing where uniforms live.
//
class TUniformMap : public TShHandleBase {
public:
TUniformMap() { }
virtual ~TUniformMap() { }
virtual TUniformMap* getAsUniformMap() { return this; }
virtual int getLocation(const char* name) = 0;
virtual TInfoSink& getInfoSink() { return infoSink; }
TInfoSink infoSink;
};
class TIntermNode;
//
// The base class for the machine dependent compiler to derive from
// for managing object code from the compile.
//
class TCompiler : public TShHandleBase {
public:
TCompiler(EShLanguage l, TInfoSink& sink) : infoSink(sink) , language(l), haveValidObjectCode(false) { }
virtual ~TCompiler() { }
EShLanguage getLanguage() { return language; }
virtual TInfoSink& getInfoSink() { return infoSink; }
virtual bool compile(TIntermNode* root, int version = 0, EProfile profile = ENoProfile) = 0;
virtual TCompiler* getAsCompiler() { return this; }
virtual bool linkable() { return haveValidObjectCode; }
TInfoSink& infoSink;
protected:
TCompiler& operator=(TCompiler&);
EShLanguage language;
bool haveValidObjectCode;
};
//
// Link operations are based on a list of compile results...
//
typedef glslang::TVector<TCompiler*> TCompilerList;
typedef glslang::TVector<TShHandleBase*> THandleList;
//
// The base class for the machine dependent linker to derive from
// to manage the resulting executable.
//
class TLinker : public TShHandleBase {
public:
TLinker(EShExecutable e, TInfoSink& iSink) :
infoSink(iSink),
executable(e),
haveReturnableObjectCode(false),
appAttributeBindings(0),
fixedAttributeBindings(0),
excludedAttributes(0),
excludedCount(0),
uniformBindings(0) { }
virtual TLinker* getAsLinker() { return this; }
virtual ~TLinker() { }
virtual bool link(TCompilerList&, TUniformMap*) = 0;
virtual bool link(THandleList&) { return false; }
virtual void setAppAttributeBindings(const ShBindingTable* t) { appAttributeBindings = t; }
virtual void setFixedAttributeBindings(const ShBindingTable* t) { fixedAttributeBindings = t; }
virtual void getAttributeBindings(ShBindingTable const **t) const = 0;
virtual void setExcludedAttributes(const int* attributes, int count) { excludedAttributes = attributes; excludedCount = count; }
virtual ShBindingTable* getUniformBindings() const { return uniformBindings; }
virtual const void* getObjectCode() const { return 0; } // a real compiler would be returning object code here
virtual TInfoSink& getInfoSink() { return infoSink; }
TInfoSink& infoSink;
protected:
TLinker& operator=(TLinker&);
EShExecutable executable;
bool haveReturnableObjectCode; // true when objectCode is acceptable to send to driver
const ShBindingTable* appAttributeBindings;
const ShBindingTable* fixedAttributeBindings;
const int* excludedAttributes;
int excludedCount;
ShBindingTable* uniformBindings; // created by the linker
};
//
// This is the interface between the machine independent code
// and the machine dependent code.
//
// The machine dependent code should derive from the classes
// above. Then Construct*() and Delete*() will create and
// destroy the machine dependent objects, which contain the
// above machine independent information.
//
TCompiler* ConstructCompiler(EShLanguage, int);
TShHandleBase* ConstructLinker(EShExecutable, int);
TShHandleBase* ConstructBindings();
void DeleteLinker(TShHandleBase*);
void DeleteBindingList(TShHandleBase* bindingList);
TUniformMap* ConstructUniformMap();
void DeleteCompiler(TCompiler*);
void DeleteUniformMap(TUniformMap*);
#endif // _SHHANDLE_INCLUDED_

@ -0,0 +1,341 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//
// Implement types for tracking GLSL arrays, arrays of arrays, etc.
//
#ifndef _ARRAYS_INCLUDED
#define _ARRAYS_INCLUDED
#include <algorithm>
namespace glslang {
// This is used to mean there is no size yet (unsized), it is waiting to get a size from somewhere else.
const int UnsizedArraySize = 0;
class TIntermTyped;
extern bool SameSpecializationConstants(TIntermTyped*, TIntermTyped*);
// Specialization constants need both a nominal size and a node that defines
// the specialization constant being used. Array types are the same when their
// size and specialization constant nodes are the same.
struct TArraySize {
unsigned int size;
TIntermTyped* node; // nullptr means no specialization constant node
bool operator==(const TArraySize& rhs) const
{
if (size != rhs.size)
return false;
if (node == nullptr || rhs.node == nullptr)
return node == rhs.node;
return SameSpecializationConstants(node, rhs.node);
}
};
//
// TSmallArrayVector is used as the container for the set of sizes in TArraySizes.
// It has generic-container semantics, while TArraySizes has array-of-array semantics.
// That is, TSmallArrayVector should be more focused on mechanism and TArraySizes on policy.
//
struct TSmallArrayVector {
//
// TODO: memory: TSmallArrayVector is intended to be smaller.
// Almost all arrays could be handled by two sizes each fitting
// in 16 bits, needing a real vector only in the cases where there
// are more than 3 sizes or a size needing more than 16 bits.
//
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TSmallArrayVector() : sizes(nullptr) { }
virtual ~TSmallArrayVector() { dealloc(); }
// For breaking into two non-shared copies, independently modifiable.
TSmallArrayVector& operator=(const TSmallArrayVector& from)
{
if (from.sizes == nullptr)
sizes = nullptr;
else {
alloc();
*sizes = *from.sizes;
}
return *this;
}
int size() const
{
if (sizes == nullptr)
return 0;
return (int)sizes->size();
}
unsigned int frontSize() const
{
assert(sizes != nullptr && sizes->size() > 0);
return sizes->front().size;
}
TIntermTyped* frontNode() const
{
assert(sizes != nullptr && sizes->size() > 0);
return sizes->front().node;
}
void changeFront(unsigned int s)
{
assert(sizes != nullptr);
// this should only happen for implicitly sized arrays, not specialization constants
assert(sizes->front().node == nullptr);
sizes->front().size = s;
}
void push_back(unsigned int e, TIntermTyped* n)
{
alloc();
TArraySize pair = { e, n };
sizes->push_back(pair);
}
void push_back(const TSmallArrayVector& newDims)
{
alloc();
sizes->insert(sizes->end(), newDims.sizes->begin(), newDims.sizes->end());
}
void pop_front()
{
assert(sizes != nullptr && sizes->size() > 0);
if (sizes->size() == 1)
dealloc();
else
sizes->erase(sizes->begin());
}
// 'this' should currently not be holding anything, and copyNonFront
// will make it hold a copy of all but the first element of rhs.
// (This would be useful for making a type that is dereferenced by
// one dimension.)
void copyNonFront(const TSmallArrayVector& rhs)
{
assert(sizes == nullptr);
if (rhs.size() > 1) {
alloc();
sizes->insert(sizes->begin(), rhs.sizes->begin() + 1, rhs.sizes->end());
}
}
unsigned int getDimSize(int i) const
{
assert(sizes != nullptr && (int)sizes->size() > i);
return (*sizes)[i].size;
}
void setDimSize(int i, unsigned int size) const
{
assert(sizes != nullptr && (int)sizes->size() > i);
assert((*sizes)[i].node == nullptr);
(*sizes)[i].size = size;
}
TIntermTyped* getDimNode(int i) const
{
assert(sizes != nullptr && (int)sizes->size() > i);
return (*sizes)[i].node;
}
bool operator==(const TSmallArrayVector& rhs) const
{
if (sizes == nullptr && rhs.sizes == nullptr)
return true;
if (sizes == nullptr || rhs.sizes == nullptr)
return false;
return *sizes == *rhs.sizes;
}
bool operator!=(const TSmallArrayVector& rhs) const { return ! operator==(rhs); }
protected:
TSmallArrayVector(const TSmallArrayVector&);
void alloc()
{
if (sizes == nullptr)
sizes = new TVector<TArraySize>;
}
void dealloc()
{
delete sizes;
sizes = nullptr;
}
TVector<TArraySize>* sizes; // will either hold such a pointer, or in the future, hold the two array sizes
};
//
// Represent an array, or array of arrays, to arbitrary depth. This is not
// done through a hierarchy of types in a type tree, rather all contiguous arrayness
// in the type hierarchy is localized into this single cumulative object.
//
// The arrayness in TTtype is a pointer, so that it can be non-allocated and zero
// for the vast majority of types that are non-array types.
//
// Order Policy: these are all identical:
// - left to right order within a contiguous set of ...[..][..][..]... in the source language
// - index order 0, 1, 2, ... within the 'sizes' member below
// - outer-most to inner-most
//
struct TArraySizes {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TArraySizes() : implicitArraySize(1), variablyIndexed(false) { }
// For breaking into two non-shared copies, independently modifiable.
TArraySizes& operator=(const TArraySizes& from)
{
implicitArraySize = from.implicitArraySize;
variablyIndexed = from.variablyIndexed;
sizes = from.sizes;
return *this;
}
// translate from array-of-array semantics to container semantics
int getNumDims() const { return sizes.size(); }
int getDimSize(int dim) const { return sizes.getDimSize(dim); }
TIntermTyped* getDimNode(int dim) const { return sizes.getDimNode(dim); }
void setDimSize(int dim, int size) { sizes.setDimSize(dim, size); }
int getOuterSize() const { return sizes.frontSize(); }
TIntermTyped* getOuterNode() const { return sizes.frontNode(); }
int getCumulativeSize() const
{
int size = 1;
for (int d = 0; d < sizes.size(); ++d) {
// this only makes sense in paths that have a known array size
assert(sizes.getDimSize(d) != UnsizedArraySize);
size *= sizes.getDimSize(d);
}
return size;
}
void addInnerSize() { addInnerSize((unsigned)UnsizedArraySize); }
void addInnerSize(int s) { addInnerSize((unsigned)s, nullptr); }
void addInnerSize(int s, TIntermTyped* n) { sizes.push_back((unsigned)s, n); }
void addInnerSize(TArraySize pair) {
sizes.push_back(pair.size, pair.node);
}
void addInnerSizes(const TArraySizes& s) { sizes.push_back(s.sizes); }
void changeOuterSize(int s) { sizes.changeFront((unsigned)s); }
int getImplicitSize() const { return implicitArraySize; }
void updateImplicitSize(int s) { implicitArraySize = std::max(implicitArraySize, s); }
bool isInnerUnsized() const
{
for (int d = 1; d < sizes.size(); ++d) {
if (sizes.getDimSize(d) == (unsigned)UnsizedArraySize)
return true;
}
return false;
}
bool clearInnerUnsized()
{
for (int d = 1; d < sizes.size(); ++d) {
if (sizes.getDimSize(d) == (unsigned)UnsizedArraySize)
setDimSize(d, 1);
}
return false;
}
bool isInnerSpecialization() const
{
for (int d = 1; d < sizes.size(); ++d) {
if (sizes.getDimNode(d) != nullptr)
return true;
}
return false;
}
bool isOuterSpecialization()
{
return sizes.getDimNode(0) != nullptr;
}
bool hasUnsized() const { return getOuterSize() == UnsizedArraySize || isInnerUnsized(); }
bool isSized() const { return getOuterSize() != UnsizedArraySize; }
void dereference() { sizes.pop_front(); }
void copyDereferenced(const TArraySizes& rhs)
{
assert(sizes.size() == 0);
if (rhs.sizes.size() > 1)
sizes.copyNonFront(rhs.sizes);
}
bool sameInnerArrayness(const TArraySizes& rhs) const
{
if (sizes.size() != rhs.sizes.size())
return false;
for (int d = 1; d < sizes.size(); ++d) {
if (sizes.getDimSize(d) != rhs.sizes.getDimSize(d) ||
sizes.getDimNode(d) != rhs.sizes.getDimNode(d))
return false;
}
return true;
}
void setVariablyIndexed() { variablyIndexed = true; }
bool isVariablyIndexed() const { return variablyIndexed; }
bool operator==(const TArraySizes& rhs) const { return sizes == rhs.sizes; }
bool operator!=(const TArraySizes& rhs) const { return sizes != rhs.sizes; }
protected:
TSmallArrayVector sizes;
TArraySizes(const TArraySizes&);
// For tracking maximum referenced compile-time constant index.
// Applies only to the outer-most dimension. Potentially becomes
// the implicit size of the array, if not variably indexed and
// otherwise legal.
int implicitArraySize;
bool variablyIndexed; // true if array is indexed with a non compile-time constant
};
} // end namespace glslang
#endif // _ARRAYS_INCLUDED_

@ -0,0 +1,249 @@
/**
This code is based on the glslang_c_interface implementation by Viktor Latypov
**/
/**
BSD 2-Clause License
Copyright (c) 2019, Viktor Latypov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#ifndef GLSLANG_C_IFACE_H_INCLUDED
#define GLSLANG_C_IFACE_H_INCLUDED
#include <stdbool.h>
#include <stdlib.h>
#include "glslang_c_shader_types.h"
typedef struct glslang_shader_s glslang_shader_t;
typedef struct glslang_program_s glslang_program_t;
/* TLimits counterpart */
typedef struct glslang_limits_s {
bool non_inductive_for_loops;
bool while_loops;
bool do_while_loops;
bool general_uniform_indexing;
bool general_attribute_matrix_vector_indexing;
bool general_varying_indexing;
bool general_sampler_indexing;
bool general_variable_indexing;
bool general_constant_matrix_vector_indexing;
} glslang_limits_t;
/* TBuiltInResource counterpart */
typedef struct glslang_resource_s {
int max_lights;
int max_clip_planes;
int max_texture_units;
int max_texture_coords;
int max_vertex_attribs;
int max_vertex_uniform_components;
int max_varying_floats;
int max_vertex_texture_image_units;
int max_combined_texture_image_units;
int max_texture_image_units;
int max_fragment_uniform_components;
int max_draw_buffers;
int max_vertex_uniform_vectors;
int max_varying_vectors;
int max_fragment_uniform_vectors;
int max_vertex_output_vectors;
int max_fragment_input_vectors;
int min_program_texel_offset;
int max_program_texel_offset;
int max_clip_distances;
int max_compute_work_group_count_x;
int max_compute_work_group_count_y;
int max_compute_work_group_count_z;
int max_compute_work_group_size_x;
int max_compute_work_group_size_y;
int max_compute_work_group_size_z;
int max_compute_uniform_components;
int max_compute_texture_image_units;
int max_compute_image_uniforms;
int max_compute_atomic_counters;
int max_compute_atomic_counter_buffers;
int max_varying_components;
int max_vertex_output_components;
int max_geometry_input_components;
int max_geometry_output_components;
int max_fragment_input_components;
int max_image_units;
int max_combined_image_units_and_fragment_outputs;
int max_combined_shader_output_resources;
int max_image_samples;
int max_vertex_image_uniforms;
int max_tess_control_image_uniforms;
int max_tess_evaluation_image_uniforms;
int max_geometry_image_uniforms;
int max_fragment_image_uniforms;
int max_combined_image_uniforms;
int max_geometry_texture_image_units;
int max_geometry_output_vertices;
int max_geometry_total_output_components;
int max_geometry_uniform_components;
int max_geometry_varying_components;
int max_tess_control_input_components;
int max_tess_control_output_components;
int max_tess_control_texture_image_units;
int max_tess_control_uniform_components;
int max_tess_control_total_output_components;
int max_tess_evaluation_input_components;
int max_tess_evaluation_output_components;
int max_tess_evaluation_texture_image_units;
int max_tess_evaluation_uniform_components;
int max_tess_patch_components;
int max_patch_vertices;
int max_tess_gen_level;
int max_viewports;
int max_vertex_atomic_counters;
int max_tess_control_atomic_counters;
int max_tess_evaluation_atomic_counters;
int max_geometry_atomic_counters;
int max_fragment_atomic_counters;
int max_combined_atomic_counters;
int max_atomic_counter_bindings;
int max_vertex_atomic_counter_buffers;
int max_tess_control_atomic_counter_buffers;
int max_tess_evaluation_atomic_counter_buffers;
int max_geometry_atomic_counter_buffers;
int max_fragment_atomic_counter_buffers;
int max_combined_atomic_counter_buffers;
int max_atomic_counter_buffer_size;
int max_transform_feedback_buffers;
int max_transform_feedback_interleaved_components;
int max_cull_distances;
int max_combined_clip_and_cull_distances;
int max_samples;
int max_mesh_output_vertices_nv;
int max_mesh_output_primitives_nv;
int max_mesh_work_group_size_x_nv;
int max_mesh_work_group_size_y_nv;
int max_mesh_work_group_size_z_nv;
int max_task_work_group_size_x_nv;
int max_task_work_group_size_y_nv;
int max_task_work_group_size_z_nv;
int max_mesh_view_count_nv;
int maxDualSourceDrawBuffersEXT;
glslang_limits_t limits;
} glslang_resource_t;
typedef struct glslang_input_s {
glslang_source_t language;
glslang_stage_t stage;
glslang_client_t client;
glslang_target_client_version_t client_version;
glslang_target_language_t target_language;
glslang_target_language_version_t target_language_version;
/** Shader source code */
const char* code;
int default_version;
glslang_profile_t default_profile;
int force_default_version_and_profile;
int forward_compatible;
glslang_messages_t messages;
const glslang_resource_t* resource;
} glslang_input_t;
/* Inclusion result structure allocated by C include_local/include_system callbacks */
typedef struct glsl_include_result_s {
/* Header file name or NULL if inclusion failed */
const char* header_name;
/* Header contents or NULL */
const char* header_data;
size_t header_length;
} glsl_include_result_t;
/* Callback for local file inclusion */
typedef glsl_include_result_t* (*glsl_include_local_func)(void* ctx, const char* header_name, const char* includer_name,
size_t include_depth);
/* Callback for system file inclusion */
typedef glsl_include_result_t* (*glsl_include_system_func)(void* ctx, const char* header_name,
const char* includer_name, size_t include_depth);
/* Callback for include result destruction */
typedef int (*glsl_free_include_result_func)(void* ctx, glsl_include_result_t* result);
/* Collection of callbacks for GLSL preprocessor */
typedef struct glsl_include_callbacks_s {
glsl_include_system_func include_system;
glsl_include_local_func include_local;
glsl_free_include_result_func free_include_result;
} glsl_include_callbacks_t;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef GLSLANG_IS_SHARED_LIBRARY
#ifdef _WIN32
#ifdef GLSLANG_EXPORTING
#define GLSLANG_EXPORT __declspec(dllexport)
#else
#define GLSLANG_EXPORT __declspec(dllimport)
#endif
#elif __GNUC__ >= 4
#define GLSLANG_EXPORT __attribute__((visibility("default")))
#endif
#endif // GLSLANG_IS_SHARED_LIBRARY
#ifndef GLSLANG_EXPORT
#define GLSLANG_EXPORT
#endif
GLSLANG_EXPORT int glslang_initialize_process();
GLSLANG_EXPORT void glslang_finalize_process();
GLSLANG_EXPORT glslang_shader_t* glslang_shader_create(const glslang_input_t* input);
GLSLANG_EXPORT void glslang_shader_delete(glslang_shader_t* shader);
GLSLANG_EXPORT int glslang_shader_preprocess(glslang_shader_t* shader, const glslang_input_t* input);
GLSLANG_EXPORT int glslang_shader_parse(glslang_shader_t* shader, const glslang_input_t* input);
GLSLANG_EXPORT const char* glslang_shader_get_preprocessed_code(glslang_shader_t* shader);
GLSLANG_EXPORT const char* glslang_shader_get_info_log(glslang_shader_t* shader);
GLSLANG_EXPORT const char* glslang_shader_get_info_debug_log(glslang_shader_t* shader);
GLSLANG_EXPORT glslang_program_t* glslang_program_create();
GLSLANG_EXPORT void glslang_program_delete(glslang_program_t* program);
GLSLANG_EXPORT void glslang_program_add_shader(glslang_program_t* program, glslang_shader_t* shader);
GLSLANG_EXPORT int glslang_program_link(glslang_program_t* program, int messages); // glslang_messages_t
GLSLANG_EXPORT void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage);
GLSLANG_EXPORT size_t glslang_program_SPIRV_get_size(glslang_program_t* program);
GLSLANG_EXPORT void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int*);
GLSLANG_EXPORT unsigned int* glslang_program_SPIRV_get_ptr(glslang_program_t* program);
GLSLANG_EXPORT const char* glslang_program_SPIRV_get_messages(glslang_program_t* program);
GLSLANG_EXPORT const char* glslang_program_get_info_log(glslang_program_t* program);
GLSLANG_EXPORT const char* glslang_program_get_info_debug_log(glslang_program_t* program);
#ifdef __cplusplus
}
#endif
#endif /* #ifdef GLSLANG_C_IFACE_INCLUDED */

@ -0,0 +1,186 @@
/**
This code is based on the glslang_c_interface implementation by Viktor Latypov
**/
/**
BSD 2-Clause License
Copyright (c) 2019, Viktor Latypov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#ifndef C_SHADER_TYPES_H_INCLUDED
#define C_SHADER_TYPES_H_INCLUDED
#define LAST_ELEMENT_MARKER(x) x
/* EShLanguage counterpart */
typedef enum {
GLSLANG_STAGE_VERTEX,
GLSLANG_STAGE_TESSCONTROL,
GLSLANG_STAGE_TESSEVALUATION,
GLSLANG_STAGE_GEOMETRY,
GLSLANG_STAGE_FRAGMENT,
GLSLANG_STAGE_COMPUTE,
GLSLANG_STAGE_RAYGEN_NV,
GLSLANG_STAGE_INTERSECT_NV,
GLSLANG_STAGE_ANYHIT_NV,
GLSLANG_STAGE_CLOSESTHIT_NV,
GLSLANG_STAGE_MISS_NV,
GLSLANG_STAGE_CALLABLE_NV,
GLSLANG_STAGE_TASK_NV,
GLSLANG_STAGE_MESH_NV,
LAST_ELEMENT_MARKER(GLSLANG_STAGE_COUNT),
} glslang_stage_t; // would be better as stage, but this is ancient now
/* EShLanguageMask counterpart */
typedef enum {
GLSLANG_STAGE_VERTEX_MASK = (1 << GLSLANG_STAGE_VERTEX),
GLSLANG_STAGE_TESSCONTROL_MASK = (1 << GLSLANG_STAGE_TESSCONTROL),
GLSLANG_STAGE_TESSEVALUATION_MASK = (1 << GLSLANG_STAGE_TESSEVALUATION),
GLSLANG_STAGE_GEOMETRY_MASK = (1 << GLSLANG_STAGE_GEOMETRY),
GLSLANG_STAGE_FRAGMENT_MASK = (1 << GLSLANG_STAGE_FRAGMENT),
GLSLANG_STAGE_COMPUTE_MASK = (1 << GLSLANG_STAGE_COMPUTE),
GLSLANG_STAGE_RAYGEN_NV_MASK = (1 << GLSLANG_STAGE_RAYGEN_NV),
GLSLANG_STAGE_INTERSECT_NV_MASK = (1 << GLSLANG_STAGE_INTERSECT_NV),
GLSLANG_STAGE_ANYHIT_NV_MASK = (1 << GLSLANG_STAGE_ANYHIT_NV),
GLSLANG_STAGE_CLOSESTHIT_NV_MASK = (1 << GLSLANG_STAGE_CLOSESTHIT_NV),
GLSLANG_STAGE_MISS_NV_MASK = (1 << GLSLANG_STAGE_MISS_NV),
GLSLANG_STAGE_CALLABLE_NV_MASK = (1 << GLSLANG_STAGE_CALLABLE_NV),
GLSLANG_STAGE_TASK_NV_MASK = (1 << GLSLANG_STAGE_TASK_NV),
GLSLANG_STAGE_MESH_NV_MASK = (1 << GLSLANG_STAGE_MESH_NV),
LAST_ELEMENT_MARKER(GLSLANG_STAGE_MASK_COUNT),
} glslang_stage_mask_t;
/* EShSource counterpart */
typedef enum {
GLSLANG_SOURCE_NONE,
GLSLANG_SOURCE_GLSL,
GLSLANG_SOURCE_HLSL,
LAST_ELEMENT_MARKER(GLSLANG_SOURCE_COUNT),
} glslang_source_t;
/* EShClient counterpart */
typedef enum {
GLSLANG_CLIENT_NONE,
GLSLANG_CLIENT_VULKAN,
GLSLANG_CLIENT_OPENGL,
LAST_ELEMENT_MARKER(GLSLANG_CLIENT_COUNT),
} glslang_client_t;
/* EShTargetLanguage counterpart */
typedef enum {
GLSLANG_TARGET_NONE,
GLSLANG_TARGET_SPV,
LAST_ELEMENT_MARKER(GLSLANG_TARGET_COUNT),
} glslang_target_language_t;
/* SH_TARGET_ClientVersion counterpart */
typedef enum {
GLSLANG_TARGET_VULKAN_1_0 = (1 << 22),
GLSLANG_TARGET_VULKAN_1_1 = (1 << 22) | (1 << 12),
GLSLANG_TARGET_VULKAN_1_2 = (1 << 22) | (2 << 12),
GLSLANG_TARGET_OPENGL_450 = 450,
LAST_ELEMENT_MARKER(GLSLANG_TARGET_CLIENT_VERSION_COUNT = 4),
} glslang_target_client_version_t;
/* SH_TARGET_LanguageVersion counterpart */
typedef enum {
GLSLANG_TARGET_SPV_1_0 = (1 << 16),
GLSLANG_TARGET_SPV_1_1 = (1 << 16) | (1 << 8),
GLSLANG_TARGET_SPV_1_2 = (1 << 16) | (2 << 8),
GLSLANG_TARGET_SPV_1_3 = (1 << 16) | (3 << 8),
GLSLANG_TARGET_SPV_1_4 = (1 << 16) | (4 << 8),
GLSLANG_TARGET_SPV_1_5 = (1 << 16) | (5 << 8),
LAST_ELEMENT_MARKER(GLSLANG_TARGET_LANGUAGE_VERSION_COUNT = 6),
} glslang_target_language_version_t;
/* EShExecutable counterpart */
typedef enum { GLSLANG_EX_VERTEX_FRAGMENT, GLSLANG_EX_FRAGMENT } glslang_executable_t;
/* EShOptimizationLevel counterpart */
typedef enum {
GLSLANG_OPT_NO_GENERATION,
GLSLANG_OPT_NONE,
GLSLANG_OPT_SIMPLE,
GLSLANG_OPT_FULL,
LAST_ELEMENT_MARKER(GLSLANG_OPT_LEVEL_COUNT),
} glslang_optimization_level_t;
/* EShTextureSamplerTransformMode counterpart */
typedef enum {
GLSLANG_TEX_SAMP_TRANS_KEEP,
GLSLANG_TEX_SAMP_TRANS_UPGRADE_TEXTURE_REMOVE_SAMPLER,
LAST_ELEMENT_MARKER(GLSLANG_TEX_SAMP_TRANS_COUNT),
} glslang_texture_sampler_transform_mode_t;
/* EShMessages counterpart */
typedef enum {
GLSLANG_MSG_DEFAULT_BIT = 0,
GLSLANG_MSG_RELAXED_ERRORS_BIT = (1 << 0),
GLSLANG_MSG_SUPPRESS_WARNINGS_BIT = (1 << 1),
GLSLANG_MSG_AST_BIT = (1 << 2),
GLSLANG_MSG_SPV_RULES_BIT = (1 << 3),
GLSLANG_MSG_VULKAN_RULES_BIT = (1 << 4),
GLSLANG_MSG_ONLY_PREPROCESSOR_BIT = (1 << 5),
GLSLANG_MSG_READ_HLSL_BIT = (1 << 6),
GLSLANG_MSG_CASCADING_ERRORS_BIT = (1 << 7),
GLSLANG_MSG_KEEP_UNCALLED_BIT = (1 << 8),
GLSLANG_MSG_HLSL_OFFSETS_BIT = (1 << 9),
GLSLANG_MSG_DEBUG_INFO_BIT = (1 << 10),
GLSLANG_MSG_HLSL_ENABLE_16BIT_TYPES_BIT = (1 << 11),
GLSLANG_MSG_HLSL_LEGALIZATION_BIT = (1 << 12),
GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT = (1 << 13),
GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT = (1 << 14),
LAST_ELEMENT_MARKER(GLSLANG_MSG_COUNT),
} glslang_messages_t;
/* EShReflectionOptions counterpart */
typedef enum {
GLSLANG_REFLECTION_DEFAULT_BIT = 0,
GLSLANG_REFLECTION_STRICT_ARRAY_SUFFIX_BIT = (1 << 0),
GLSLANG_REFLECTION_BASIC_ARRAY_SUFFIX_BIT = (1 << 1),
GLSLANG_REFLECTION_INTERMEDIATE_IOO_BIT = (1 << 2),
GLSLANG_REFLECTION_SEPARATE_BUFFERS_BIT = (1 << 3),
GLSLANG_REFLECTION_ALL_BLOCK_VARIABLES_BIT = (1 << 4),
GLSLANG_REFLECTION_UNWRAP_IO_BLOCKS_BIT = (1 << 5),
GLSLANG_REFLECTION_ALL_IO_VARIABLES_BIT = (1 << 6),
GLSLANG_REFLECTION_SHARED_STD140_SSBO_BIT = (1 << 7),
GLSLANG_REFLECTION_SHARED_STD140_UBO_BIT = (1 << 8),
LAST_ELEMENT_MARKER(GLSLANG_REFLECTION_COUNT),
} glslang_reflection_options_t;
/* EProfile counterpart (from Versions.h) */
typedef enum {
GLSLANG_BAD_PROFILE = 0,
GLSLANG_NO_PROFILE = (1 << 0),
GLSLANG_CORE_PROFILE = (1 << 1),
GLSLANG_COMPATIBILITY_PROFILE = (1 << 2),
GLSLANG_ES_PROFILE = (1 << 3),
LAST_ELEMENT_MARKER(GLSLANG_PROFILE_COUNT),
} glslang_profile_t;
#undef LAST_ELEMENT_MARKER
#endif

@ -0,0 +1,112 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2013-2016 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _INITIALIZE_INCLUDED_
#define _INITIALIZE_INCLUDED_
#include "../Include/ResourceLimits.h"
#include "../Include/Common.h"
#include "../Include/ShHandle.h"
#include "SymbolTable.h"
#include "Versions.h"
namespace glslang {
//
// This is made to hold parseable strings for almost all the built-in
// functions and variables for one specific combination of version
// and profile. (Some still need to be added programmatically.)
// This is a base class for language-specific derivations, which
// can be used for language independent builtins.
//
// The strings are organized by
// commonBuiltins: intersection of all stages' built-ins, processed just once
// stageBuiltins[]: anything a stage needs that's not in commonBuiltins
//
class TBuiltInParseables {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TBuiltInParseables();
virtual ~TBuiltInParseables();
virtual void initialize(int version, EProfile, const SpvVersion& spvVersion) = 0;
virtual void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage) = 0;
virtual const TString& getCommonString() const { return commonBuiltins; }
virtual const TString& getStageString(EShLanguage language) const { return stageBuiltins[language]; }
virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable) = 0;
virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources) = 0;
protected:
TString commonBuiltins;
TString stageBuiltins[EShLangCount];
};
//
// This is a GLSL specific derivation of TBuiltInParseables. To present a stable
// interface and match other similar code, it is called TBuiltIns, rather
// than TBuiltInParseablesGlsl.
//
class TBuiltIns : public TBuiltInParseables {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TBuiltIns();
virtual ~TBuiltIns();
void initialize(int version, EProfile, const SpvVersion& spvVersion);
void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage);
void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable);
void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources);
protected:
void addTabledBuiltins(int version, EProfile profile, const SpvVersion& spvVersion);
void relateTabledBuiltins(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage, TSymbolTable&);
void add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion);
void addSubpassSampling(TSampler, const TString& typeName, int version, EProfile profile);
void addQueryFunctions(TSampler, const TString& typeName, int version, EProfile profile);
void addImageFunctions(TSampler, const TString& typeName, int version, EProfile profile);
void addSamplingFunctions(TSampler, const TString& typeName, int version, EProfile profile);
void addGatherFunctions(TSampler, const TString& typeName, int version, EProfile profile);
// Helpers for making textual representations of the permutations
// of texturing/imaging functions.
const char* postfixes[5];
const char* prefixes[EbtNumTypes];
int dimMap[EsdNumDims];
};
} // end namespace glslang
#endif // _INITIALIZE_INCLUDED_

@ -0,0 +1,168 @@
//
// Copyright (C) 2016 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#pragma once
#include "../Include/Common.h"
#include "reflection.h"
#include "localintermediate.h"
#include "gl_types.h"
#include <list>
#include <unordered_set>
namespace glslang {
//
// The traverser: mostly pass through, except
// - processing function-call nodes to push live functions onto the stack of functions to process
// - processing selection nodes to trim semantically dead code
//
// This is in the glslang namespace directly so it can be a friend of TReflection.
// This can be derived from to implement reflection database traversers or
// binding mappers: anything that wants to traverse the live subset of the tree.
//
class TLiveTraverser : public TIntermTraverser {
public:
TLiveTraverser(const TIntermediate& i, bool traverseAll = false,
bool preVisit = true, bool inVisit = false, bool postVisit = false) :
TIntermTraverser(preVisit, inVisit, postVisit),
intermediate(i), traverseAll(traverseAll)
{ }
//
// Given a function name, find its subroot in the tree, and push it onto the stack of
// functions left to process.
//
void pushFunction(const TString& name)
{
TIntermSequence& globals = intermediate.getTreeRoot()->getAsAggregate()->getSequence();
for (unsigned int f = 0; f < globals.size(); ++f) {
TIntermAggregate* candidate = globals[f]->getAsAggregate();
if (candidate && candidate->getOp() == EOpFunction && candidate->getName() == name) {
destinations.push_back(candidate);
break;
}
}
}
void pushGlobalReference(const TString& name)
{
TIntermSequence& globals = intermediate.getTreeRoot()->getAsAggregate()->getSequence();
for (unsigned int f = 0; f < globals.size(); ++f) {
TIntermAggregate* candidate = globals[f]->getAsAggregate();
if (candidate && candidate->getOp() == EOpSequence &&
candidate->getSequence().size() == 1 &&
candidate->getSequence()[0]->getAsBinaryNode()) {
TIntermBinary* binary = candidate->getSequence()[0]->getAsBinaryNode();
TIntermSymbol* symbol = binary->getLeft()->getAsSymbolNode();
if (symbol && symbol->getQualifier().storage == EvqGlobal &&
symbol->getName() == name) {
destinations.push_back(candidate);
break;
}
}
}
}
typedef std::list<TIntermAggregate*> TDestinationStack;
TDestinationStack destinations;
protected:
// To catch which function calls are not dead, and hence which functions must be visited.
virtual bool visitAggregate(TVisit, TIntermAggregate* node)
{
if (!traverseAll)
if (node->getOp() == EOpFunctionCall)
addFunctionCall(node);
return true; // traverse this subtree
}
// To prune semantically dead paths.
virtual bool visitSelection(TVisit /* visit */, TIntermSelection* node)
{
if (traverseAll)
return true; // traverse all code
TIntermConstantUnion* constant = node->getCondition()->getAsConstantUnion();
if (constant) {
// cull the path that is dead
if (constant->getConstArray()[0].getBConst() == true && node->getTrueBlock())
node->getTrueBlock()->traverse(this);
if (constant->getConstArray()[0].getBConst() == false && node->getFalseBlock())
node->getFalseBlock()->traverse(this);
return false; // don't traverse any more, we did it all above
} else
return true; // traverse the whole subtree
}
// Track live functions as well as uniforms, so that we don't visit dead functions
// and only visit each function once.
void addFunctionCall(TIntermAggregate* call)
{
// just use the map to ensure we process each function at most once
if (liveFunctions.find(call->getName()) == liveFunctions.end()) {
liveFunctions.insert(call->getName());
pushFunction(call->getName());
}
}
void addGlobalReference(const TString& name)
{
// just use the map to ensure we process each global at most once
if (liveGlobals.find(name) == liveGlobals.end()) {
liveGlobals.insert(name);
pushGlobalReference(name);
}
}
const TIntermediate& intermediate;
typedef std::unordered_set<TString> TLiveFunctions;
TLiveFunctions liveFunctions;
typedef std::unordered_set<TString> TLiveGlobals;
TLiveGlobals liveGlobals;
bool traverseAll;
private:
// prevent copy & copy construct
TLiveTraverser(TLiveTraverser&);
TLiveTraverser& operator=(TLiveTraverser&);
};
} // namespace glslang

@ -0,0 +1,536 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc.
// Copyright (C) 2015-2018 Google, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//
// This header defines a two-level parse-helper hierarchy, derived from
// TParseVersions:
// - TParseContextBase: sharable across multiple parsers
// - TParseContext: GLSL specific helper
//
#ifndef _PARSER_HELPER_INCLUDED_
#define _PARSER_HELPER_INCLUDED_
#include <cstdarg>
#include <functional>
#include "parseVersions.h"
#include "../Include/ShHandle.h"
#include "SymbolTable.h"
#include "localintermediate.h"
#include "Scan.h"
#include "attribute.h"
namespace glslang {
struct TPragma {
TPragma(bool o, bool d) : optimize(o), debug(d) { }
bool optimize;
bool debug;
TPragmaTable pragmaTable;
};
class TScanContext;
class TPpContext;
typedef std::set<int> TIdSetType;
typedef std::map<const TTypeList*, std::map<size_t, const TTypeList*>> TStructRecord;
//
// Sharable code (as well as what's in TParseVersions) across
// parse helpers.
//
class TParseContextBase : public TParseVersions {
public:
TParseContextBase(TSymbolTable& symbolTable, TIntermediate& interm, bool parsingBuiltins, int version,
EProfile profile, const SpvVersion& spvVersion, EShLanguage language,
TInfoSink& infoSink, bool forwardCompatible, EShMessages messages,
const TString* entryPoint = nullptr)
: TParseVersions(interm, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
scopeMangler("::"),
symbolTable(symbolTable),
statementNestingLevel(0), loopNestingLevel(0), structNestingLevel(0), blockNestingLevel(0), controlFlowNestingLevel(0),
currentFunctionType(nullptr),
postEntryPointReturn(false),
contextPragma(true, false),
beginInvocationInterlockCount(0), endInvocationInterlockCount(0),
parsingBuiltins(parsingBuiltins), scanContext(nullptr), ppContext(nullptr),
limits(resources.limits),
globalUniformBlock(nullptr),
globalUniformBinding(TQualifier::layoutBindingEnd),
globalUniformSet(TQualifier::layoutSetEnd)
{
if (entryPoint != nullptr)
sourceEntryPointName = *entryPoint;
}
virtual ~TParseContextBase() { }
#if !defined(GLSLANG_WEB) || defined(GLSLANG_WEB_DEVEL)
virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
virtual void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
virtual void C_DECL ppError(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
virtual void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
#endif
virtual void setLimits(const TBuiltInResource&) = 0;
void checkIndex(const TSourceLoc&, const TType&, int& index);
EShLanguage getLanguage() const { return language; }
void setScanContext(TScanContext* c) { scanContext = c; }
TScanContext* getScanContext() const { return scanContext; }
void setPpContext(TPpContext* c) { ppContext = c; }
TPpContext* getPpContext() const { return ppContext; }
virtual void setLineCallback(const std::function<void(int, int, bool, int, const char*)>& func) { lineCallback = func; }
virtual void setExtensionCallback(const std::function<void(int, const char*, const char*)>& func) { extensionCallback = func; }
virtual void setVersionCallback(const std::function<void(int, int, const char*)>& func) { versionCallback = func; }
virtual void setPragmaCallback(const std::function<void(int, const TVector<TString>&)>& func) { pragmaCallback = func; }
virtual void setErrorCallback(const std::function<void(int, const char*)>& func) { errorCallback = func; }
virtual void reservedPpErrorCheck(const TSourceLoc&, const char* name, const char* op) = 0;
virtual bool lineContinuationCheck(const TSourceLoc&, bool endOfComment) = 0;
virtual bool lineDirectiveShouldSetNextLine() const = 0;
virtual void handlePragma(const TSourceLoc&, const TVector<TString>&) = 0;
virtual bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false) = 0;
virtual void notifyVersion(int line, int version, const char* type_string)
{
if (versionCallback)
versionCallback(line, version, type_string);
}
virtual void notifyErrorDirective(int line, const char* error_message)
{
if (errorCallback)
errorCallback(line, error_message);
}
virtual void notifyLineDirective(int curLineNo, int newLineNo, bool hasSource, int sourceNum, const char* sourceName)
{
if (lineCallback)
lineCallback(curLineNo, newLineNo, hasSource, sourceNum, sourceName);
}
virtual void notifyExtensionDirective(int line, const char* extension, const char* behavior)
{
if (extensionCallback)
extensionCallback(line, extension, behavior);
}
#ifdef ENABLE_HLSL
// Manage the global uniform block (default uniforms in GLSL, $Global in HLSL)
virtual void growGlobalUniformBlock(const TSourceLoc&, TType&, const TString& memberName, TTypeList* typeList = nullptr);
#endif
// Potentially rename shader entry point function
void renameShaderFunction(TString*& name) const
{
// Replace the entry point name given in the shader with the real entry point name,
// if there is a substitution.
if (name != nullptr && *name == sourceEntryPointName && intermediate.getEntryPointName().size() > 0)
name = NewPoolTString(intermediate.getEntryPointName().c_str());
}
virtual bool lValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*);
virtual void rValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*);
const char* const scopeMangler;
// Basic parsing state, easily accessible to the grammar
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
int statementNestingLevel; // 0 if outside all flow control or compound statements
int loopNestingLevel; // 0 if outside all loops
int structNestingLevel; // 0 if outside structures
int blockNestingLevel; // 0 if outside blocks
int controlFlowNestingLevel; // 0 if outside all flow control
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // true if a non-void function has a return
// if inside a function, true if the function is the entry point and this is after a return statement
bool postEntryPointReturn;
// case, node, case, case, node, ...; ensure only one node between cases; stack of them for nesting
TList<TIntermSequence*> switchSequenceStack;
// the statementNestingLevel the current switch statement is at, which must match the level of its case statements
TList<int> switchLevel;
struct TPragma contextPragma;
int beginInvocationInterlockCount;
int endInvocationInterlockCount;
protected:
TParseContextBase(TParseContextBase&);
TParseContextBase& operator=(TParseContextBase&);
const bool parsingBuiltins; // true if parsing built-in symbols/functions
TVector<TSymbol*> linkageSymbols; // will be transferred to 'linkage', after all editing is done, order preserving
TScanContext* scanContext;
TPpContext* ppContext;
TBuiltInResource resources;
TLimits& limits;
TString sourceEntryPointName;
// These, if set, will be called when a line, pragma ... is preprocessed.
// They will be called with any parameters to the original directive.
std::function<void(int, int, bool, int, const char*)> lineCallback;
std::function<void(int, const TVector<TString>&)> pragmaCallback;
std::function<void(int, int, const char*)> versionCallback;
std::function<void(int, const char*, const char*)> extensionCallback;
std::function<void(int, const char*)> errorCallback;
// see implementation for detail
const TFunction* selectFunction(const TVector<const TFunction*>, const TFunction&,
std::function<bool(const TType&, const TType&, TOperator, int arg)>,
std::function<bool(const TType&, const TType&, const TType&)>,
/* output */ bool& tie);
virtual void parseSwizzleSelector(const TSourceLoc&, const TString&, int size,
TSwizzleSelectors<TVectorSelector>&);
// Manage the global uniform block (default uniforms in GLSL, $Global in HLSL)
TVariable* globalUniformBlock; // the actual block, inserted into the symbol table
unsigned int globalUniformBinding; // the block's binding number
unsigned int globalUniformSet; // the block's set number
int firstNewMember; // the index of the first member not yet inserted into the symbol table
// override this to set the language-specific name
virtual const char* getGlobalUniformBlockName() const { return ""; }
virtual void setUniformBlockDefaults(TType&) const { }
virtual void finalizeGlobalUniformBlockLayout(TVariable&) { }
virtual void outputMessage(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, TPrefixType prefix,
va_list args);
virtual void trackLinkage(TSymbol& symbol);
virtual void makeEditable(TSymbol*&);
virtual TVariable* getEditableVariable(const char* name);
virtual void finish();
};
//
// Manage the state for when to respect precision qualifiers and when to warn about
// the defaults being different than might be expected.
//
class TPrecisionManager {
public:
TPrecisionManager() : obey(false), warn(false), explicitIntDefault(false), explicitFloatDefault(false){ }
virtual ~TPrecisionManager() {}
void respectPrecisionQualifiers() { obey = true; }
bool respectingPrecisionQualifiers() const { return obey; }
bool shouldWarnAboutDefaults() const { return warn; }
void defaultWarningGiven() { warn = false; }
void warnAboutDefaults() { warn = true; }
void explicitIntDefaultSeen()
{
explicitIntDefault = true;
if (explicitFloatDefault)
warn = false;
}
void explicitFloatDefaultSeen()
{
explicitFloatDefault = true;
if (explicitIntDefault)
warn = false;
}
protected:
bool obey; // respect precision qualifiers
bool warn; // need to give a warning about the defaults
bool explicitIntDefault; // user set the default for int/uint
bool explicitFloatDefault; // user set the default for float
};
//
// GLSL-specific parse helper. Should have GLSL in the name, but that's
// too big of a change for comparing branches at the moment, and perhaps
// impacts downstream consumers as well.
//
class TParseContext : public TParseContextBase {
public:
TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, const SpvVersion& spvVersion, EShLanguage, TInfoSink&,
bool forwardCompatible = false, EShMessages messages = EShMsgDefault,
const TString* entryPoint = nullptr);
virtual ~TParseContext();
bool obeyPrecisionQualifiers() const { return precisionManager.respectingPrecisionQualifiers(); }
void setPrecisionDefaults();
void setLimits(const TBuiltInResource&) override;
bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false) override;
void parserError(const char* s); // for bison's yyerror
void reservedErrorCheck(const TSourceLoc&, const TString&);
void reservedPpErrorCheck(const TSourceLoc&, const char* name, const char* op) override;
bool lineContinuationCheck(const TSourceLoc&, bool endOfComment) override;
bool lineDirectiveShouldSetNextLine() const override;
bool builtInName(const TString&);
void handlePragma(const TSourceLoc&, const TVector<TString>&) override;
TIntermTyped* handleVariable(const TSourceLoc&, TSymbol* symbol, const TString* string);
TIntermTyped* handleBracketDereference(const TSourceLoc&, TIntermTyped* base, TIntermTyped* index);
void handleIndexLimits(const TSourceLoc&, TIntermTyped* base, TIntermTyped* index);
#ifndef GLSLANG_WEB
void makeEditable(TSymbol*&) override;
void ioArrayCheck(const TSourceLoc&, const TType&, const TString& identifier);
#endif
bool isIoResizeArray(const TType&) const;
void fixIoArraySize(const TSourceLoc&, TType&);
void handleIoResizeArrayAccess(const TSourceLoc&, TIntermTyped* base);
void checkIoArraysConsistency(const TSourceLoc&, bool tailOnly = false);
int getIoArrayImplicitSize(const TQualifier&, TString* featureString = nullptr) const;
void checkIoArrayConsistency(const TSourceLoc&, int requiredSize, const char* feature, TType&, const TString&);
TIntermTyped* handleBinaryMath(const TSourceLoc&, const char* str, TOperator op, TIntermTyped* left, TIntermTyped* right);
TIntermTyped* handleUnaryMath(const TSourceLoc&, const char* str, TOperator op, TIntermTyped* childNode);
TIntermTyped* handleDotDereference(const TSourceLoc&, TIntermTyped* base, const TString& field);
TIntermTyped* handleDotSwizzle(const TSourceLoc&, TIntermTyped* base, const TString& field);
void blockMemberExtensionCheck(const TSourceLoc&, const TIntermTyped* base, int member, const TString& memberName);
TFunction* handleFunctionDeclarator(const TSourceLoc&, TFunction& function, bool prototype);
TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&);
TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermNode*);
TIntermTyped* handleBuiltInFunctionCall(TSourceLoc, TIntermNode* arguments, const TFunction& function);
void computeBuiltinPrecisions(TIntermTyped&, const TFunction&);
TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
void checkLocation(const TSourceLoc&, TOperator);
TIntermTyped* handleLengthMethod(const TSourceLoc&, TFunction*, TIntermNode*);
void addInputArgumentConversions(const TFunction&, TIntermNode*&) const;
TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermAggregate&) const;
TIntermTyped* addAssign(const TSourceLoc&, TOperator op, TIntermTyped* left, TIntermTyped* right);
void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
void nonOpBuiltInCheck(const TSourceLoc&, const TFunction&, TIntermAggregate&);
void userFunctionCallCheck(const TSourceLoc&, TIntermAggregate&);
void samplerConstructorLocationCheck(const TSourceLoc&, const char* token, TIntermNode*);
TFunction* handleConstructorCall(const TSourceLoc&, const TPublicType&);
void handlePrecisionQualifier(const TSourceLoc&, TQualifier&, TPrecisionQualifier);
void checkPrecisionQualifier(const TSourceLoc&, TPrecisionQualifier);
void memorySemanticsCheck(const TSourceLoc&, const TFunction&, const TIntermOperator& callNode);
void assignError(const TSourceLoc&, const char* op, TString left, TString right);
void unaryOpError(const TSourceLoc&, const char* op, TString operand);
void binaryOpError(const TSourceLoc&, const char* op, TString left, TString right);
void variableCheck(TIntermTyped*& nodePtr);
bool lValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*) override;
void rValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*) override;
void constantValueCheck(TIntermTyped* node, const char* token);
void integerCheck(const TIntermTyped* node, const char* token);
void globalCheck(const TSourceLoc&, const char* token);
bool constructorError(const TSourceLoc&, TIntermNode*, TFunction&, TOperator, TType&);
bool constructorTextureSamplerError(const TSourceLoc&, const TFunction&);
void arraySizeCheck(const TSourceLoc&, TIntermTyped* expr, TArraySize&, const char *sizeType);
bool arrayQualifierError(const TSourceLoc&, const TQualifier&);
bool arrayError(const TSourceLoc&, const TType&);
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
void structArrayCheck(const TSourceLoc&, const TType& structure);
void arraySizesCheck(const TSourceLoc&, const TQualifier&, TArraySizes*, const TIntermTyped* initializer, bool lastMember);
void arrayOfArrayVersionCheck(const TSourceLoc&, const TArraySizes*);
bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
void boolCheck(const TSourceLoc&, const TIntermTyped*);
void boolCheck(const TSourceLoc&, const TPublicType&);
void samplerCheck(const TSourceLoc&, const TType&, const TString& identifier, TIntermTyped* initializer);
void atomicUintCheck(const TSourceLoc&, const TType&, const TString& identifier);
void accStructCheck(const TSourceLoc & loc, const TType & type, const TString & identifier);
void transparentOpaqueCheck(const TSourceLoc&, const TType&, const TString& identifier);
void memberQualifierCheck(glslang::TPublicType&);
void globalQualifierFixCheck(const TSourceLoc&, TQualifier&, bool isMemberCheck = false);
void globalQualifierTypeCheck(const TSourceLoc&, const TQualifier&, const TPublicType&);
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);
void mergeQualifiers(const TSourceLoc&, TQualifier& dst, const TQualifier& src, bool force);
void setDefaultPrecision(const TSourceLoc&, TPublicType&, TPrecisionQualifier);
int computeSamplerTypeIndex(TSampler&);
TPrecisionQualifier getDefaultPrecision(TPublicType&);
void precisionQualifierCheck(const TSourceLoc&, TBasicType, TQualifier&);
void parameterTypeCheck(const TSourceLoc&, TStorageQualifier qualifier, const TType& type);
bool containsFieldWithBasicType(const TType& type ,TBasicType basicType);
TSymbol* redeclareBuiltinVariable(const TSourceLoc&, const TString&, const TQualifier&, const TShaderQualifiers&);
void redeclareBuiltinBlock(const TSourceLoc&, TTypeList& typeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes);
void paramCheckFixStorage(const TSourceLoc&, const TStorageQualifier&, TType& type);
void paramCheckFix(const TSourceLoc&, const TQualifier&, TType& type);
void nestedBlockCheck(const TSourceLoc&);
void nestedStructCheck(const TSourceLoc&);
void arrayObjectCheck(const TSourceLoc&, const TType&, const char* op);
void opaqueCheck(const TSourceLoc&, const TType&, const char* op);
void referenceCheck(const TSourceLoc&, const TType&, const char* op);
void storage16BitAssignmentCheck(const TSourceLoc&, const TType&, const char* op);
void specializationCheck(const TSourceLoc&, const TType&, const char* op);
void structTypeCheck(const TSourceLoc&, TPublicType&);
void inductiveLoopCheck(const TSourceLoc&, TIntermNode* init, TIntermLoop* loop);
void arrayLimitCheck(const TSourceLoc&, const TString&, int size);
void limitCheck(const TSourceLoc&, int value, const char* limit, const char* feature);
void inductiveLoopBodyCheck(TIntermNode*, int loopIndexId, TSymbolTable&);
void constantIndexExpressionCheck(TIntermNode*);
void setLayoutQualifier(const TSourceLoc&, TPublicType&, TString&);
void setLayoutQualifier(const TSourceLoc&, TPublicType&, TString&, const TIntermTyped*);
void mergeObjectLayoutQualifiers(TQualifier& dest, const TQualifier& src, bool inheritOnly);
void layoutObjectCheck(const TSourceLoc&, const TSymbol&);
void layoutMemberLocationArrayCheck(const TSourceLoc&, bool memberWithLocation, TArraySizes* arraySizes);
void layoutTypeCheck(const TSourceLoc&, const TType&);
void layoutQualifierCheck(const TSourceLoc&, const TQualifier&);
void checkNoShaderLayouts(const TSourceLoc&, const TShaderQualifiers&);
void fixOffset(const TSourceLoc&, TSymbol&);
const TFunction* findFunction(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
const TFunction* findFunctionExact(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
const TFunction* findFunction120(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
const TFunction* findFunction400(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
const TFunction* findFunctionExplicitTypes(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
void declareTypeDefaults(const TSourceLoc&, const TPublicType&);
TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, const TPublicType&, TArraySizes* typeArray = 0, TIntermTyped* initializer = 0);
TIntermTyped* addConstructor(const TSourceLoc&, TIntermNode*, const TType&);
TIntermTyped* constructAggregate(TIntermNode*, const TType&, int, const TSourceLoc&);
TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, const TSourceLoc&, bool subset);
void inheritMemoryQualifiers(const TQualifier& from, TQualifier& to);
void declareBlock(const TSourceLoc&, TTypeList& typeList, const TString* instanceName = 0, TArraySizes* arraySizes = 0);
void blockStageIoCheck(const TSourceLoc&, const TQualifier&);
void blockQualifierCheck(const TSourceLoc&, const TQualifier&, bool instanceName);
void fixBlockLocations(const TSourceLoc&, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
void fixXfbOffsets(TQualifier&, TTypeList&);
void fixBlockUniformOffsets(TQualifier&, TTypeList&);
void fixBlockUniformLayoutMatrix(TQualifier&, TTypeList*, TTypeList*);
void fixBlockUniformLayoutPacking(TQualifier&, TTypeList*, TTypeList*);
void addQualifierToExisting(const TSourceLoc&, TQualifier, const TString& identifier);
void addQualifierToExisting(const TSourceLoc&, TQualifier, TIdentifierList&);
void invariantCheck(const TSourceLoc&, const TQualifier&);
void updateStandaloneQualifierDefaults(const TSourceLoc&, const TPublicType&);
void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode);
TIntermNode* addSwitch(const TSourceLoc&, TIntermTyped* expression, TIntermAggregate* body);
const TTypeList* recordStructCopy(TStructRecord&, const TType*, const TType*);
#ifndef GLSLANG_WEB
TAttributeType attributeFromName(const TString& name) const;
TAttributes* makeAttributes(const TString& identifier) const;
TAttributes* makeAttributes(const TString& identifier, TIntermNode* node) const;
TAttributes* mergeAttributes(TAttributes*, TAttributes*) const;
// Determine selection control from attributes
void handleSelectionAttributes(const TAttributes& attributes, TIntermNode*);
void handleSwitchAttributes(const TAttributes& attributes, TIntermNode*);
// Determine loop control from attributes
void handleLoopAttributes(const TAttributes& attributes, TIntermNode*);
#endif
void checkAndResizeMeshViewDim(const TSourceLoc&, TType&, bool isBlockMember);
protected:
void nonInitConstCheck(const TSourceLoc&, TString& identifier, TType& type);
void inheritGlobalDefaults(TQualifier& dst) const;
TVariable* makeInternalVariable(const char* name, const TType&) const;
TVariable* declareNonArray(const TSourceLoc&, const TString& identifier, const TType&);
void declareArray(const TSourceLoc&, const TString& identifier, const TType&, TSymbol*&);
void checkRuntimeSizable(const TSourceLoc&, const TIntermTyped&);
bool isRuntimeLength(const TIntermTyped&) const;
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer);
#ifndef GLSLANG_WEB
void finish() override;
#endif
public:
//
// Generally, bison productions, the scanner, and the PP need read/write access to these; just give them direct access
//
// Current state of parsing
bool inMain; // if inside a function, true if the function is main
const TString* blockName;
TQualifier currentBlockQualifier;
TPrecisionQualifier defaultPrecision[EbtNumTypes];
TBuiltInResource resources;
TLimits& limits;
protected:
TParseContext(TParseContext&);
TParseContext& operator=(TParseContext&);
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2 * 2 * 2 * 2)); // see computeSamplerTypeIndex()
TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex];
TPrecisionManager precisionManager;
TQualifier globalBufferDefaults;
TQualifier globalUniformDefaults;
TQualifier globalInputDefaults;
TQualifier globalOutputDefaults;
TQualifier globalSharedDefaults;
TString currentCaller; // name of last function body entered (not valid when at global scope)
#ifndef GLSLANG_WEB
int* atomicUintOffsets; // to become an array of the right size to hold an offset per binding point
bool anyIndexLimits;
TIdSetType inductiveLoopIds;
TVector<TIntermTyped*> needsIndexLimitationChecking;
TStructRecord matrixFixRecord;
TStructRecord packingFixRecord;
//
// Geometry shader input arrays:
// - array sizing is based on input primitive and/or explicit size
//
// Tessellation control output arrays:
// - array sizing is based on output layout(vertices=...) and/or explicit size
//
// Both:
// - array sizing is retroactive
// - built-in block redeclarations interact with this
//
// Design:
// - use a per-context "resize-list", a list of symbols whose array sizes
// can be fixed
//
// - the resize-list starts empty at beginning of user-shader compilation, it does
// not have built-ins in it
//
// - on built-in array use: copyUp() symbol and add it to the resize-list
//
// - on user array declaration: add it to the resize-list
//
// - on block redeclaration: copyUp() symbol and add it to the resize-list
// * note, that appropriately gives an error if redeclaring a block that
// was already used and hence already copied-up
//
// - on seeing a layout declaration that sizes the array, fix everything in the
// resize-list, giving errors for mismatch
//
// - on seeing an array size declaration, give errors on mismatch between it and previous
// array-sizing declarations
//
TVector<TSymbol*> ioArraySymbolResizeList;
#endif
};
} // end namespace glslang
#endif // _PARSER_HELPER_INCLUDED_

@ -0,0 +1,41 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#pragma once
namespace glslang {
void RemoveAllTreeNodes(TIntermNode*);
} // end namespace glslang

@ -0,0 +1,276 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2013 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _GLSLANG_SCAN_INCLUDED_
#define _GLSLANG_SCAN_INCLUDED_
#include "Versions.h"
namespace glslang {
// Use a global end-of-input character, so no translation is needed across
// layers of encapsulation. Characters are all 8 bit, and positive, so there is
// no aliasing of character 255 onto -1, for example.
const int EndOfInput = -1;
//
// A character scanner that seamlessly, on read-only strings, reads across an
// array of strings without assuming null termination.
//
class TInputScanner {
public:
TInputScanner(int n, const char* const s[], size_t L[], const char* const* names = nullptr,
int b = 0, int f = 0, bool single = false) :
numSources(n),
// up to this point, common usage is "char*", but now we need positive 8-bit characters
sources(reinterpret_cast<const unsigned char* const *>(s)),
lengths(L), currentSource(0), currentChar(0), stringBias(b), finale(f), singleLogical(single),
endOfFileReached(false)
{
loc = new TSourceLoc[numSources];
for (int i = 0; i < numSources; ++i) {
loc[i].init(i - stringBias);
}
if (names != nullptr) {
for (int i = 0; i < numSources; ++i)
loc[i].name = names[i] != nullptr ? NewPoolTString(names[i]) : nullptr;
}
loc[currentSource].line = 1;
logicalSourceLoc.init(1);
logicalSourceLoc.name = loc[0].name;
}
virtual ~TInputScanner()
{
delete [] loc;
}
// retrieve the next character and advance one character
int get()
{
int ret = peek();
if (ret == EndOfInput)
return ret;
++loc[currentSource].column;
++logicalSourceLoc.column;
if (ret == '\n') {
++loc[currentSource].line;
++logicalSourceLoc.line;
logicalSourceLoc.column = 0;
loc[currentSource].column = 0;
}
advance();
return ret;
}
// retrieve the next character, no advance
int peek()
{
if (currentSource >= numSources) {
endOfFileReached = true;
return EndOfInput;
}
// Make sure we do not read off the end of a string.
// N.B. Sources can have a length of 0.
int sourceToRead = currentSource;
size_t charToRead = currentChar;
while(charToRead >= lengths[sourceToRead]) {
charToRead = 0;
sourceToRead += 1;
if (sourceToRead >= numSources) {
return EndOfInput;
}
}
// Here, we care about making negative valued characters positive
return sources[sourceToRead][charToRead];
}
// go back one character
void unget()
{
// Do not roll back once we've reached the end of the file.
if (endOfFileReached)
return;
if (currentChar > 0) {
--currentChar;
--loc[currentSource].column;
--logicalSourceLoc.column;
if (loc[currentSource].column < 0) {
// We've moved back past a new line. Find the
// previous newline (or start of the file) to compute
// the column count on the now current line.
size_t chIndex = currentChar;
while (chIndex > 0) {
if (sources[currentSource][chIndex] == '\n') {
break;
}
--chIndex;
}
logicalSourceLoc.column = (int)(currentChar - chIndex);
loc[currentSource].column = (int)(currentChar - chIndex);
}
} else {
do {
--currentSource;
} while (currentSource > 0 && lengths[currentSource] == 0);
if (lengths[currentSource] == 0) {
// set to 0 if we've backed up to the start of an empty string
currentChar = 0;
} else
currentChar = lengths[currentSource] - 1;
}
if (peek() == '\n') {
--loc[currentSource].line;
--logicalSourceLoc.line;
}
}
// for #line override
void setLine(int newLine)
{
logicalSourceLoc.line = newLine;
loc[getLastValidSourceIndex()].line = newLine;
}
// for #line override in filename based parsing
void setFile(const char* filename)
{
TString* fn_tstr = NewPoolTString(filename);
logicalSourceLoc.name = fn_tstr;
loc[getLastValidSourceIndex()].name = fn_tstr;
}
void setFile(const char* filename, int i)
{
TString* fn_tstr = NewPoolTString(filename);
if (i == getLastValidSourceIndex()) {
logicalSourceLoc.name = fn_tstr;
}
loc[i].name = fn_tstr;
}
void setString(int newString)
{
logicalSourceLoc.string = newString;
loc[getLastValidSourceIndex()].string = newString;
logicalSourceLoc.name = nullptr;
loc[getLastValidSourceIndex()].name = nullptr;
}
// for #include content indentation
void setColumn(int col)
{
logicalSourceLoc.column = col;
loc[getLastValidSourceIndex()].column = col;
}
void setEndOfInput()
{
endOfFileReached = true;
currentSource = numSources;
}
bool atEndOfInput() const { return endOfFileReached; }
const TSourceLoc& getSourceLoc() const
{
if (singleLogical) {
return logicalSourceLoc;
} else {
return loc[std::max(0, std::min(currentSource, numSources - finale - 1))];
}
}
// Returns the index (starting from 0) of the most recent valid source string we are reading from.
int getLastValidSourceIndex() const { return std::min(currentSource, numSources - 1); }
void consumeWhiteSpace(bool& foundNonSpaceTab);
bool consumeComment();
void consumeWhitespaceComment(bool& foundNonSpaceTab);
bool scanVersion(int& version, EProfile& profile, bool& notFirstToken);
protected:
// advance one character
void advance()
{
++currentChar;
if (currentChar >= lengths[currentSource]) {
++currentSource;
if (currentSource < numSources) {
loc[currentSource].string = loc[currentSource - 1].string + 1;
loc[currentSource].line = 1;
loc[currentSource].column = 0;
}
while (currentSource < numSources && lengths[currentSource] == 0) {
++currentSource;
if (currentSource < numSources) {
loc[currentSource].string = loc[currentSource - 1].string + 1;
loc[currentSource].line = 1;
loc[currentSource].column = 0;
}
}
currentChar = 0;
}
}
int numSources; // number of strings in source
const unsigned char* const *sources; // array of strings; must be converted to positive values on use, to avoid aliasing with -1 as EndOfInput
const size_t *lengths; // length of each string
int currentSource;
size_t currentChar;
// This is for reporting what string/line an error occurred on, and can be overridden by #line.
// It remembers the last state of each source string as it is left for the next one, so unget()
// can restore that state.
TSourceLoc* loc; // an array
int stringBias; // the first string that is the user's string number 0
int finale; // number of internal strings after user's last string
TSourceLoc logicalSourceLoc;
bool singleLogical; // treats the strings as a single logical string.
// locations will be reported from the first string.
// Set to true once peek() returns EndOfFile, so that we won't roll back
// once we've reached EndOfFile.
bool endOfFileReached;
};
} // end namespace glslang
#endif // _GLSLANG_SCAN_INCLUDED_

@ -0,0 +1,93 @@
//
// Copyright (C) 2013 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//
// This holds context specific to the GLSL scanner, which
// sits between the preprocessor scanner and parser.
//
#pragma once
#include "ParseHelper.h"
namespace glslang {
class TPpContext;
class TPpToken;
class TParserToken;
class TScanContext {
public:
explicit TScanContext(TParseContextBase& pc) :
parseContext(pc),
afterType(false), afterStruct(false),
field(false), afterBuffer(false) { }
virtual ~TScanContext() { }
static void fillInKeywordMap();
static void deleteKeywordMap();
int tokenize(TPpContext*, TParserToken&);
protected:
TScanContext(TScanContext&);
TScanContext& operator=(TScanContext&);
int tokenizeIdentifier();
int identifierOrType();
int reservedWord();
int identifierOrReserved(bool reserved);
int es30ReservedFromGLSL(int version);
int nonreservedKeyword(int esVersion, int nonEsVersion);
int precisionKeyword();
int matNxM();
int dMat();
int firstGenerationImage(bool inEs310);
int secondGenerationImage();
TParseContextBase& parseContext;
bool afterType; // true if we've recognized a type, so can only be looking for an identifier
bool afterStruct; // true if we've recognized the STRUCT keyword, so can only be looking for an identifier
bool field; // true if we're on a field, right after a '.'
bool afterBuffer; // true if we've recognized the BUFFER keyword
TSourceLoc loc;
TParserToken* parserToken;
TPpToken* ppToken;
const char* tokenText;
int keyword;
};
} // end namespace glslang

@ -0,0 +1,899 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2013 LunarG, Inc.
// Copyright (C) 2015-2018 Google, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _SYMBOL_TABLE_INCLUDED_
#define _SYMBOL_TABLE_INCLUDED_
//
// Symbol table for parsing. Has these design characteristics:
//
// * Same symbol table can be used to compile many shaders, to preserve
// effort of creating and loading with the large numbers of built-in
// symbols.
//
// --> This requires a copy mechanism, so initial pools used to create
// the shared information can be popped. Done through "clone"
// methods.
//
// * Name mangling will be used to give each function a unique name
// so that symbol table lookups are never ambiguous. This allows
// a simpler symbol table structure.
//
// * Pushing and popping of scope, so symbol table will really be a stack
// of symbol tables. Searched from the top, with new inserts going into
// the top.
//
// * Constants: Compile time constant symbols will keep their values
// in the symbol table. The parser can substitute constants at parse
// time, including doing constant folding and constant propagation.
//
// * No temporaries: Temporaries made from operations (+, --, .xy, etc.)
// are tracked in the intermediate representation, not the symbol table.
//
#include "../Include/Common.h"
#include "../Include/intermediate.h"
#include "../Include/InfoSink.h"
namespace glslang {
//
// Symbol base class. (Can build functions or variables out of these...)
//
class TVariable;
class TFunction;
class TAnonMember;
typedef TVector<const char*> TExtensionList;
class TSymbol {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
explicit TSymbol(const TString *n) : name(n), extensions(0), writable(true) { }
virtual TSymbol* clone() const = 0;
virtual ~TSymbol() { } // rely on all symbol owned memory coming from the pool
virtual const TString& getName() const { return *name; }
virtual void changeName(const TString* newName) { name = newName; }
virtual void addPrefix(const char* prefix)
{
TString newName(prefix);
newName.append(*name);
changeName(NewPoolTString(newName.c_str()));
}
virtual const TString& getMangledName() const { return getName(); }
virtual TFunction* getAsFunction() { return 0; }
virtual const TFunction* getAsFunction() const { return 0; }
virtual TVariable* getAsVariable() { return 0; }
virtual const TVariable* getAsVariable() const { return 0; }
virtual const TAnonMember* getAsAnonMember() const { return 0; }
virtual const TType& getType() const = 0;
virtual TType& getWritableType() = 0;
virtual void setUniqueId(int id) { uniqueId = id; }
virtual int getUniqueId() const { return uniqueId; }
virtual void setExtensions(int numExts, const char* const exts[])
{
assert(extensions == 0);
assert(numExts > 0);
extensions = NewPoolObject(extensions);
for (int e = 0; e < numExts; ++e)
extensions->push_back(exts[e]);
}
virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); }
virtual const char** getExtensions() const { return extensions->data(); }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const = 0;
void dumpExtensions(TInfoSink& infoSink) const;
#endif
virtual bool isReadOnly() const { return ! writable; }
virtual void makeReadOnly() { writable = false; }
protected:
explicit TSymbol(const TSymbol&);
TSymbol& operator=(const TSymbol&);
const TString *name;
unsigned int uniqueId; // For cross-scope comparing during code generation
// For tracking what extensions must be present
// (don't use if correct version/profile is present).
TExtensionList* extensions; // an array of pointers to existing constant char strings
//
// N.B.: Non-const functions that will be generally used should assert on this,
// to avoid overwriting shared symbol-table information.
//
bool writable;
};
//
// Variable class, meaning a symbol that's not a function.
//
// There could be a separate class hierarchy for Constant variables;
// Only one of int, bool, or float, (or none) is correct for
// any particular use, but it's easy to do this way, and doesn't
// seem worth having separate classes, and "getConst" can't simply return
// different values for different types polymorphically, so this is
// just simple and pragmatic.
//
class TVariable : public TSymbol {
public:
TVariable(const TString *name, const TType& t, bool uT = false )
: TSymbol(name),
userType(uT),
constSubtree(nullptr),
memberExtensions(nullptr),
anonId(-1)
{ type.shallowCopy(t); }
virtual TVariable* clone() const;
virtual ~TVariable() { }
virtual TVariable* getAsVariable() { return this; }
virtual const TVariable* getAsVariable() const { return this; }
virtual const TType& getType() const { return type; }
virtual TType& getWritableType() { assert(writable); return type; }
virtual bool isUserType() const { return userType; }
virtual const TConstUnionArray& getConstArray() const { return constArray; }
virtual TConstUnionArray& getWritableConstArray() { assert(writable); return constArray; }
virtual void setConstArray(const TConstUnionArray& array) { constArray = array; }
virtual void setConstSubtree(TIntermTyped* subtree) { constSubtree = subtree; }
virtual TIntermTyped* getConstSubtree() const { return constSubtree; }
virtual void setAnonId(int i) { anonId = i; }
virtual int getAnonId() const { return anonId; }
virtual void setMemberExtensions(int member, int numExts, const char* const exts[])
{
assert(type.isStruct());
assert(numExts > 0);
if (memberExtensions == nullptr) {
memberExtensions = NewPoolObject(memberExtensions);
memberExtensions->resize(type.getStruct()->size());
}
for (int e = 0; e < numExts; ++e)
(*memberExtensions)[member].push_back(exts[e]);
}
virtual bool hasMemberExtensions() const { return memberExtensions != nullptr; }
virtual int getNumMemberExtensions(int member) const
{
return memberExtensions == nullptr ? 0 : (int)(*memberExtensions)[member].size();
}
virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const;
#endif
protected:
explicit TVariable(const TVariable&);
TVariable& operator=(const TVariable&);
TType type;
bool userType;
// we are assuming that Pool Allocator will free the memory allocated to unionArray
// when this object is destroyed
TConstUnionArray constArray; // for compile-time constant value
TIntermTyped* constSubtree; // for specialization constant computation
TVector<TExtensionList>* memberExtensions; // per-member extension list, allocated only when needed
int anonId; // the ID used for anonymous blocks: TODO: see if uniqueId could serve a dual purpose
};
//
// The function sub-class of symbols and the parser will need to
// share this definition of a function parameter.
//
struct TParameter {
TString *name;
TType* type;
TIntermTyped* defaultValue;
void copyParam(const TParameter& param)
{
if (param.name)
name = NewPoolTString(param.name->c_str());
else
name = 0;
type = param.type->clone();
defaultValue = param.defaultValue;
}
TBuiltInVariable getDeclaredBuiltIn() const { return type->getQualifier().declaredBuiltIn; }
};
//
// The function sub-class of a symbol.
//
class TFunction : public TSymbol {
public:
explicit TFunction(TOperator o) :
TSymbol(0),
op(o),
defined(false), prototyped(false), implicitThis(false), illegalImplicitThis(false), defaultParamCount(0) { }
TFunction(const TString *name, const TType& retType, TOperator tOp = EOpNull) :
TSymbol(name),
mangledName(*name + '('),
op(tOp),
defined(false), prototyped(false), implicitThis(false), illegalImplicitThis(false), defaultParamCount(0)
{
returnType.shallowCopy(retType);
declaredBuiltIn = retType.getQualifier().builtIn;
}
virtual TFunction* clone() const override;
virtual ~TFunction();
virtual TFunction* getAsFunction() override { return this; }
virtual const TFunction* getAsFunction() const override { return this; }
// Install 'p' as the (non-'this') last parameter.
// Non-'this' parameters are reflected in both the list of parameters and the
// mangled name.
virtual void addParameter(TParameter& p)
{
assert(writable);
parameters.push_back(p);
p.type->appendMangledName(mangledName);
if (p.defaultValue != nullptr)
defaultParamCount++;
}
// Install 'this' as the first parameter.
// 'this' is reflected in the list of parameters, but not the mangled name.
virtual void addThisParameter(TType& type, const char* name)
{
TParameter p = { NewPoolTString(name), new TType, nullptr };
p.type->shallowCopy(type);
parameters.insert(parameters.begin(), p);
}
virtual void addPrefix(const char* prefix) override
{
TSymbol::addPrefix(prefix);
mangledName.insert(0, prefix);
}
virtual void removePrefix(const TString& prefix)
{
assert(mangledName.compare(0, prefix.size(), prefix) == 0);
mangledName.erase(0, prefix.size());
}
virtual const TString& getMangledName() const override { return mangledName; }
virtual const TType& getType() const override { return returnType; }
virtual TBuiltInVariable getDeclaredBuiltInType() const { return declaredBuiltIn; }
virtual TType& getWritableType() override { return returnType; }
virtual void relateToOperator(TOperator o) { assert(writable); op = o; }
virtual TOperator getBuiltInOp() const { return op; }
virtual void setDefined() { assert(writable); defined = true; }
virtual bool isDefined() const { return defined; }
virtual void setPrototyped() { assert(writable); prototyped = true; }
virtual bool isPrototyped() const { return prototyped; }
virtual void setImplicitThis() { assert(writable); implicitThis = true; }
virtual bool hasImplicitThis() const { return implicitThis; }
virtual void setIllegalImplicitThis() { assert(writable); illegalImplicitThis = true; }
virtual bool hasIllegalImplicitThis() const { return illegalImplicitThis; }
// Return total number of parameters
virtual int getParamCount() const { return static_cast<int>(parameters.size()); }
// Return number of parameters with default values.
virtual int getDefaultParamCount() const { return defaultParamCount; }
// Return number of fixed parameters (without default values)
virtual int getFixedParamCount() const { return getParamCount() - getDefaultParamCount(); }
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
virtual const TParameter& operator[](int i) const { return parameters[i]; }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
#endif
protected:
explicit TFunction(const TFunction&);
TFunction& operator=(const TFunction&);
typedef TVector<TParameter> TParamList;
TParamList parameters;
TType returnType;
TBuiltInVariable declaredBuiltIn;
TString mangledName;
TOperator op;
bool defined;
bool prototyped;
bool implicitThis; // True if this function is allowed to see all members of 'this'
bool illegalImplicitThis; // True if this function is not supposed to have access to dynamic members of 'this',
// even if it finds member variables in the symbol table.
// This is important for a static member function that has member variables in scope,
// but is not allowed to use them, or see hidden symbols instead.
int defaultParamCount;
};
//
// Members of anonymous blocks are a kind of TSymbol. They are not hidden in
// the symbol table behind a container; rather they are visible and point to
// their anonymous container. (The anonymous container is found through the
// member, not the other way around.)
//
class TAnonMember : public TSymbol {
public:
TAnonMember(const TString* n, unsigned int m, TVariable& a, int an) : TSymbol(n), anonContainer(a), memberNumber(m), anonId(an) { }
virtual TAnonMember* clone() const override;
virtual ~TAnonMember() { }
virtual const TAnonMember* getAsAnonMember() const override { return this; }
virtual const TVariable& getAnonContainer() const { return anonContainer; }
virtual unsigned int getMemberNumber() const { return memberNumber; }
virtual const TType& getType() const override
{
const TTypeList& types = *anonContainer.getType().getStruct();
return *types[memberNumber].type;
}
virtual TType& getWritableType() override
{
assert(writable);
const TTypeList& types = *anonContainer.getType().getStruct();
return *types[memberNumber].type;
}
virtual void setExtensions(int numExts, const char* const exts[]) override
{
anonContainer.setMemberExtensions(memberNumber, numExts, exts);
}
virtual int getNumExtensions() const override { return anonContainer.getNumMemberExtensions(memberNumber); }
virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); }
virtual int getAnonId() const { return anonId; }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
#endif
protected:
explicit TAnonMember(const TAnonMember&);
TAnonMember& operator=(const TAnonMember&);
TVariable& anonContainer;
unsigned int memberNumber;
int anonId;
};
class TSymbolTableLevel {
public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TSymbolTableLevel() : defaultPrecision(0), anonId(0), thisLevel(false) { }
~TSymbolTableLevel();
bool insert(TSymbol& symbol, bool separateNameSpaces)
{
//
// returning true means symbol was added to the table with no semantic errors
//
const TString& name = symbol.getName();
if (name == "") {
symbol.getAsVariable()->setAnonId(anonId++);
// An empty name means an anonymous container, exposing its members to the external scope.
// Give it a name and insert its members in the symbol table, pointing to the container.
char buf[20];
snprintf(buf, 20, "%s%d", AnonymousPrefix, symbol.getAsVariable()->getAnonId());
symbol.changeName(NewPoolTString(buf));
return insertAnonymousMembers(symbol, 0);
} else {
// Check for redefinition errors:
// - STL itself will tell us if there is a direct name collision, with name mangling, at this level
// - additionally, check for function-redefining-variable name collisions
const TString& insertName = symbol.getMangledName();
if (symbol.getAsFunction()) {
// make sure there isn't a variable of this name
if (! separateNameSpaces && level.find(name) != level.end())
return false;
// insert, and whatever happens is okay
level.insert(tLevelPair(insertName, &symbol));
return true;
} else
return level.insert(tLevelPair(insertName, &symbol)).second;
}
}
// Add more members to an already inserted aggregate object
bool amend(TSymbol& symbol, int firstNewMember)
{
// See insert() for comments on basic explanation of insert.
// This operates similarly, but more simply.
// Only supporting amend of anonymous blocks so far.
if (IsAnonymous(symbol.getName()))
return insertAnonymousMembers(symbol, firstNewMember);
else
return false;
}
bool insertAnonymousMembers(TSymbol& symbol, int firstMember)
{
const TTypeList& types = *symbol.getAsVariable()->getType().getStruct();
for (unsigned int m = firstMember; m < types.size(); ++m) {
TAnonMember* member = new TAnonMember(&types[m].type->getFieldName(), m, *symbol.getAsVariable(), symbol.getAsVariable()->getAnonId());
if (! level.insert(tLevelPair(member->getMangledName(), member)).second)
return false;
}
return true;
}
TSymbol* find(const TString& name) const
{
tLevel::const_iterator it = level.find(name);
if (it == level.end())
return 0;
else
return (*it).second;
}
void findFunctionNameList(const TString& name, TVector<const TFunction*>& list)
{
size_t parenAt = name.find_first_of('(');
TString base(name, 0, parenAt + 1);
tLevel::const_iterator begin = level.lower_bound(base);
base[parenAt] = ')'; // assume ')' is lexically after '('
tLevel::const_iterator end = level.upper_bound(base);
for (tLevel::const_iterator it = begin; it != end; ++it)
list.push_back(it->second->getAsFunction());
}
// See if there is already a function in the table having the given non-function-style name.
bool hasFunctionName(const TString& name) const
{
tLevel::const_iterator candidate = level.lower_bound(name);
if (candidate != level.end()) {
const TString& candidateName = (*candidate).first;
TString::size_type parenAt = candidateName.find_first_of('(');
if (parenAt != candidateName.npos && candidateName.compare(0, parenAt, name) == 0)
return true;
}
return false;
}
// See if there is a variable at this level having the given non-function-style name.
// Return true if name is found, and set variable to true if the name was a variable.
bool findFunctionVariableName(const TString& name, bool& variable) const
{
tLevel::const_iterator candidate = level.lower_bound(name);
if (candidate != level.end()) {
const TString& candidateName = (*candidate).first;
TString::size_type parenAt = candidateName.find_first_of('(');
if (parenAt == candidateName.npos) {
// not a mangled name
if (candidateName == name) {
// found a variable name match
variable = true;
return true;
}
} else {
// a mangled name
if (candidateName.compare(0, parenAt, name) == 0) {
// found a function name match
variable = false;
return true;
}
}
}
return false;
}
// Use this to do a lazy 'push' of precision defaults the first time
// a precision statement is seen in a new scope. Leave it at 0 for
// when no push was needed. Thus, it is not the current defaults,
// it is what to restore the defaults to when popping a level.
void setPreviousDefaultPrecisions(const TPrecisionQualifier *p)
{
// can call multiple times at one scope, will only latch on first call,
// as we're tracking the previous scope's values, not the current values
if (defaultPrecision != 0)
return;
defaultPrecision = new TPrecisionQualifier[EbtNumTypes];
for (int t = 0; t < EbtNumTypes; ++t)
defaultPrecision[t] = p[t];
}
void getPreviousDefaultPrecisions(TPrecisionQualifier *p)
{
// can be called for table level pops that didn't set the
// defaults
if (defaultPrecision == 0 || p == 0)
return;
for (int t = 0; t < EbtNumTypes; ++t)
p[t] = defaultPrecision[t];
}
void relateToOperator(const char* name, TOperator op);
void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
void dump(TInfoSink& infoSink, bool complete = false) const;
#endif
TSymbolTableLevel* clone() const;
void readOnly();
void setThisLevel() { thisLevel = true; }
bool isThisLevel() const { return thisLevel; }
protected:
explicit TSymbolTableLevel(TSymbolTableLevel&);
TSymbolTableLevel& operator=(TSymbolTableLevel&);
typedef std::map<TString, TSymbol*, std::less<TString>, pool_allocator<std::pair<const TString, TSymbol*> > > tLevel;
typedef const tLevel::value_type tLevelPair;
typedef std::pair<tLevel::iterator, bool> tInsertResult;
tLevel level; // named mappings
TPrecisionQualifier *defaultPrecision;
int anonId;
bool thisLevel; // True if this level of the symbol table is a structure scope containing member function
// that are supposed to see anonymous access to member variables.
};
class TSymbolTable {
public:
TSymbolTable() : uniqueId(0), noBuiltInRedeclarations(false), separateNameSpaces(false), adoptedLevels(0)
{
//
// This symbol table cannot be used until push() is called.
//
}
~TSymbolTable()
{
// this can be called explicitly; safest to code it so it can be called multiple times
// don't deallocate levels passed in from elsewhere
while (table.size() > adoptedLevels)
pop(0);
}
void adoptLevels(TSymbolTable& symTable)
{
for (unsigned int level = 0; level < symTable.table.size(); ++level) {
table.push_back(symTable.table[level]);
++adoptedLevels;
}
uniqueId = symTable.uniqueId;
noBuiltInRedeclarations = symTable.noBuiltInRedeclarations;
separateNameSpaces = symTable.separateNameSpaces;
}
//
// While level adopting is generic, the methods below enact a the following
// convention for levels:
// 0: common built-ins shared across all stages, all compiles, only one copy for all symbol tables
// 1: per-stage built-ins, shared across all compiles, but a different copy per stage
// 2: built-ins specific to a compile, like resources that are context-dependent, or redeclared built-ins
// 3: user-shader globals
//
protected:
static const int globalLevel = 3;
static bool isSharedLevel(int level) { return level <= 1; } // exclude all per-compile levels
static bool isBuiltInLevel(int level) { return level <= 2; } // exclude user globals
static bool isGlobalLevel(int level) { return level <= globalLevel; } // include user globals
public:
bool isEmpty() { return table.size() == 0; }
bool atBuiltInLevel() { return isBuiltInLevel(currentLevel()); }
bool atGlobalLevel() { return isGlobalLevel(currentLevel()); }
static bool isBuiltInSymbol(int uniqueId) {
int level = uniqueId >> LevelFlagBitOffset;
return isBuiltInLevel(level);
}
void setNoBuiltInRedeclarations() { noBuiltInRedeclarations = true; }
void setSeparateNameSpaces() { separateNameSpaces = true; }
void push()
{
table.push_back(new TSymbolTableLevel);
updateUniqueIdLevelFlag();
}
// Make a new symbol-table level to represent the scope introduced by a structure
// containing member functions, such that the member functions can find anonymous
// references to member variables.
//
// 'thisSymbol' should have a name of "" to trigger anonymous structure-member
// symbol finds.
void pushThis(TSymbol& thisSymbol)
{
assert(thisSymbol.getName().size() == 0);
table.push_back(new TSymbolTableLevel);
updateUniqueIdLevelFlag();
table.back()->setThisLevel();
insert(thisSymbol);
}
void pop(TPrecisionQualifier *p)
{
table[currentLevel()]->getPreviousDefaultPrecisions(p);
delete table.back();
table.pop_back();
updateUniqueIdLevelFlag();
}
//
// Insert a visible symbol into the symbol table so it can
// be found later by name.
//
// Returns false if the was a name collision.
//
bool insert(TSymbol& symbol)
{
symbol.setUniqueId(++uniqueId);
// make sure there isn't a function of this variable name
if (! separateNameSpaces && ! symbol.getAsFunction() && table[currentLevel()]->hasFunctionName(symbol.getName()))
return false;
// check for not overloading or redefining a built-in function
if (noBuiltInRedeclarations) {
if (atGlobalLevel() && currentLevel() > 0) {
if (table[0]->hasFunctionName(symbol.getName()))
return false;
if (currentLevel() > 1 && table[1]->hasFunctionName(symbol.getName()))
return false;
}
}
return table[currentLevel()]->insert(symbol, separateNameSpaces);
}
// Add more members to an already inserted aggregate object
bool amend(TSymbol& symbol, int firstNewMember)
{
// See insert() for comments on basic explanation of insert.
// This operates similarly, but more simply.
return table[currentLevel()]->amend(symbol, firstNewMember);
}
//
// To allocate an internal temporary, which will need to be uniquely
// identified by the consumer of the AST, but never need to
// found by doing a symbol table search by name, hence allowed an
// arbitrary name in the symbol with no worry of collision.
//
void makeInternalVariable(TSymbol& symbol)
{
symbol.setUniqueId(++uniqueId);
}
//
// Copy a variable or anonymous member's structure from a shared level so that
// it can be added (soon after return) to the symbol table where it can be
// modified without impacting other users of the shared table.
//
TSymbol* copyUpDeferredInsert(TSymbol* shared)
{
if (shared->getAsVariable()) {
TSymbol* copy = shared->clone();
copy->setUniqueId(shared->getUniqueId());
return copy;
} else {
const TAnonMember* anon = shared->getAsAnonMember();
assert(anon);
TVariable* container = anon->getAnonContainer().clone();
container->changeName(NewPoolTString(""));
container->setUniqueId(anon->getAnonContainer().getUniqueId());
return container;
}
}
TSymbol* copyUp(TSymbol* shared)
{
TSymbol* copy = copyUpDeferredInsert(shared);
table[globalLevel]->insert(*copy, separateNameSpaces);
if (shared->getAsVariable())
return copy;
else {
// return the copy of the anonymous member
return table[globalLevel]->find(shared->getName());
}
}
// Normal find of a symbol, that can optionally say whether the symbol was found
// at a built-in level or the current top-scope level.
TSymbol* find(const TString& name, bool* builtIn = 0, bool* currentScope = 0, int* thisDepthP = 0)
{
int level = currentLevel();
TSymbol* symbol;
int thisDepth = 0;
do {
if (table[level]->isThisLevel())
++thisDepth;
symbol = table[level]->find(name);
--level;
} while (symbol == nullptr && level >= 0);
level++;
if (builtIn)
*builtIn = isBuiltInLevel(level);
if (currentScope)
*currentScope = isGlobalLevel(currentLevel()) || level == currentLevel(); // consider shared levels as "current scope" WRT user globals
if (thisDepthP != nullptr) {
if (! table[level]->isThisLevel())
thisDepth = 0;
*thisDepthP = thisDepth;
}
return symbol;
}
// Find of a symbol that returns how many layers deep of nested
// structures-with-member-functions ('this' scopes) deep the symbol was
// found in.
TSymbol* find(const TString& name, int& thisDepth)
{
int level = currentLevel();
TSymbol* symbol;
thisDepth = 0;
do {
if (table[level]->isThisLevel())
++thisDepth;
symbol = table[level]->find(name);
--level;
} while (symbol == 0 && level >= 0);
if (! table[level + 1]->isThisLevel())
thisDepth = 0;
return symbol;
}
bool isFunctionNameVariable(const TString& name) const
{
if (separateNameSpaces)
return false;
int level = currentLevel();
do {
bool variable;
bool found = table[level]->findFunctionVariableName(name, variable);
if (found)
return variable;
--level;
} while (level >= 0);
return false;
}
void findFunctionNameList(const TString& name, TVector<const TFunction*>& list, bool& builtIn)
{
// For user levels, return the set found in the first scope with a match
builtIn = false;
int level = currentLevel();
do {
table[level]->findFunctionNameList(name, list);
--level;
} while (list.empty() && level >= globalLevel);
if (! list.empty())
return;
// Gather across all built-in levels; they don't hide each other
builtIn = true;
do {
table[level]->findFunctionNameList(name, list);
--level;
} while (level >= 0);
}
void relateToOperator(const char* name, TOperator op)
{
for (unsigned int level = 0; level < table.size(); ++level)
table[level]->relateToOperator(name, op);
}
void setFunctionExtensions(const char* name, int num, const char* const extensions[])
{
for (unsigned int level = 0; level < table.size(); ++level)
table[level]->setFunctionExtensions(name, num, extensions);
}
void setVariableExtensions(const char* name, int numExts, const char* const extensions[])
{
TSymbol* symbol = find(TString(name));
if (symbol == nullptr)
return;
symbol->setExtensions(numExts, extensions);
}
void setVariableExtensions(const char* blockName, const char* name, int numExts, const char* const extensions[])
{
TSymbol* symbol = find(TString(blockName));
if (symbol == nullptr)
return;
TVariable* variable = symbol->getAsVariable();
assert(variable != nullptr);
const TTypeList& structure = *variable->getAsVariable()->getType().getStruct();
for (int member = 0; member < (int)structure.size(); ++member) {
if (structure[member].type->getFieldName().compare(name) == 0) {
variable->setMemberExtensions(member, numExts, extensions);
return;
}
}
}
int getMaxSymbolId() { return uniqueId; }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
void dump(TInfoSink& infoSink, bool complete = false) const;
#endif
void copyTable(const TSymbolTable& copyOf);
void setPreviousDefaultPrecisions(TPrecisionQualifier *p) { table[currentLevel()]->setPreviousDefaultPrecisions(p); }
void readOnly()
{
for (unsigned int level = 0; level < table.size(); ++level)
table[level]->readOnly();
}
// Add current level in the high-bits of unique id
void updateUniqueIdLevelFlag() {
// clamp level to avoid overflow
uint32_t level = currentLevel() > 7 ? 7 : currentLevel();
uniqueId &= ((1 << LevelFlagBitOffset) - 1);
uniqueId |= (level << LevelFlagBitOffset);
}
protected:
TSymbolTable(TSymbolTable&);
TSymbolTable& operator=(TSymbolTableLevel&);
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
static const uint32_t LevelFlagBitOffset = 28;
std::vector<TSymbolTableLevel*> table;
int uniqueId; // for unique identification in code generation
bool noBuiltInRedeclarations;
bool separateNameSpaces;
unsigned int adoptedLevels;
};
} // end namespace glslang
#endif // _SYMBOL_TABLE_INCLUDED_

@ -0,0 +1,339 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// Copyright (C) 2015-2018 Google, Inc.
// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _VERSIONS_INCLUDED_
#define _VERSIONS_INCLUDED_
#define LAST_ELEMENT_MARKER(x) x
//
// Help manage multiple profiles, versions, extensions etc.
//
//
// Profiles are set up for masking operations, so queries can be done on multiple
// profiles at the same time.
//
// Don't maintain an ordinal set of enums (0,1,2,3...) to avoid all possible
// defects from mixing the two different forms.
//
typedef enum : unsigned {
EBadProfile = 0,
ENoProfile = (1 << 0), // only for desktop, before profiles showed up
ECoreProfile = (1 << 1),
ECompatibilityProfile = (1 << 2),
EEsProfile = (1 << 3),
LAST_ELEMENT_MARKER(EProfileCount),
} EProfile;
namespace glslang {
//
// Map from profile enum to externally readable text name.
//
inline const char* ProfileName(EProfile profile)
{
switch (profile) {
case ENoProfile: return "none";
case ECoreProfile: return "core";
case ECompatibilityProfile: return "compatibility";
case EEsProfile: return "es";
default: return "unknown profile";
}
}
//
// What source rules, validation rules, target language, etc. are needed or
// desired for SPIR-V?
//
// 0 means a target or rule set is not enabled (ignore rules from that entity).
// Non-0 means to apply semantic rules arising from that version of its rule set.
// The union of all requested rule sets will be applied.
//
struct SpvVersion {
SpvVersion() : spv(0), vulkanGlsl(0), vulkan(0), openGl(0) {}
unsigned int spv; // the version of SPIR-V to target, as defined by "word 1" of the SPIR-V binary header
int vulkanGlsl; // the version of GLSL semantics for Vulkan, from GL_KHR_vulkan_glsl, for "#define VULKAN XXX"
int vulkan; // the version of Vulkan, for which SPIR-V execution environment rules to use
int openGl; // the version of GLSL semantics for OpenGL, from GL_ARB_gl_spirv, for "#define GL_SPIRV XXX"
};
//
// The behaviors from the GLSL "#extension extension_name : behavior"
//
typedef enum {
EBhMissing = 0,
EBhRequire,
EBhEnable,
EBhWarn,
EBhDisable,
EBhDisablePartial // use as initial state of an extension that is only partially implemented
} TExtensionBehavior;
//
// Symbolic names for extensions. Strings may be directly used when calling the
// functions, but better to have the compiler do spelling checks.
//
const char* const E_GL_OES_texture_3D = "GL_OES_texture_3D";
const char* const E_GL_OES_standard_derivatives = "GL_OES_standard_derivatives";
const char* const E_GL_EXT_frag_depth = "GL_EXT_frag_depth";
const char* const E_GL_OES_EGL_image_external = "GL_OES_EGL_image_external";
const char* const E_GL_OES_EGL_image_external_essl3 = "GL_OES_EGL_image_external_essl3";
const char* const E_GL_EXT_YUV_target = "GL_EXT_YUV_target";
const char* const E_GL_EXT_shader_texture_lod = "GL_EXT_shader_texture_lod";
const char* const E_GL_EXT_shadow_samplers = "GL_EXT_shadow_samplers";
const char* const E_GL_ARB_texture_rectangle = "GL_ARB_texture_rectangle";
const char* const E_GL_3DL_array_objects = "GL_3DL_array_objects";
const char* const E_GL_ARB_shading_language_420pack = "GL_ARB_shading_language_420pack";
const char* const E_GL_ARB_texture_gather = "GL_ARB_texture_gather";
const char* const E_GL_ARB_gpu_shader5 = "GL_ARB_gpu_shader5";
const char* const E_GL_ARB_separate_shader_objects = "GL_ARB_separate_shader_objects";
const char* const E_GL_ARB_compute_shader = "GL_ARB_compute_shader";
const char* const E_GL_ARB_tessellation_shader = "GL_ARB_tessellation_shader";
const char* const E_GL_ARB_enhanced_layouts = "GL_ARB_enhanced_layouts";
const char* const E_GL_ARB_texture_cube_map_array = "GL_ARB_texture_cube_map_array";
const char* const E_GL_ARB_texture_multisample = "GL_ARB_texture_multisample";
const char* const E_GL_ARB_shader_texture_lod = "GL_ARB_shader_texture_lod";
const char* const E_GL_ARB_explicit_attrib_location = "GL_ARB_explicit_attrib_location";
const char* const E_GL_ARB_explicit_uniform_location = "GL_ARB_explicit_uniform_location";
const char* const E_GL_ARB_shader_image_load_store = "GL_ARB_shader_image_load_store";
const char* const E_GL_ARB_shader_atomic_counters = "GL_ARB_shader_atomic_counters";
const char* const E_GL_ARB_shader_draw_parameters = "GL_ARB_shader_draw_parameters";
const char* const E_GL_ARB_shader_group_vote = "GL_ARB_shader_group_vote";
const char* const E_GL_ARB_derivative_control = "GL_ARB_derivative_control";
const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture_image_samples";
const char* const E_GL_ARB_viewport_array = "GL_ARB_viewport_array";
const char* const E_GL_ARB_gpu_shader_int64 = "GL_ARB_gpu_shader_int64";
const char* const E_GL_ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64";
const char* const E_GL_ARB_shader_ballot = "GL_ARB_shader_ballot";
const char* const E_GL_ARB_sparse_texture2 = "GL_ARB_sparse_texture2";
const char* const E_GL_ARB_sparse_texture_clamp = "GL_ARB_sparse_texture_clamp";
const char* const E_GL_ARB_shader_stencil_export = "GL_ARB_shader_stencil_export";
// const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
const char* const E_GL_ARB_post_depth_coverage = "GL_ARB_post_depth_coverage";
const char* const E_GL_ARB_shader_viewport_layer_array = "GL_ARB_shader_viewport_layer_array";
const char* const E_GL_ARB_fragment_shader_interlock = "GL_ARB_fragment_shader_interlock";
const char* const E_GL_ARB_shader_clock = "GL_ARB_shader_clock";
const char* const E_GL_ARB_uniform_buffer_object = "GL_ARB_uniform_buffer_object";
const char* const E_GL_ARB_sample_shading = "GL_ARB_sample_shading";
const char* const E_GL_ARB_shader_bit_encoding = "GL_ARB_shader_bit_encoding";
const char* const E_GL_ARB_shader_image_size = "GL_ARB_shader_image_size";
const char* const E_GL_ARB_shader_storage_buffer_object = "GL_ARB_shader_storage_buffer_object";
const char* const E_GL_ARB_shading_language_packing = "GL_ARB_shading_language_packing";
const char* const E_GL_ARB_texture_query_lod = "GL_ARB_texture_query_lod";
const char* const E_GL_ARB_vertex_attrib_64bit = "GL_ARB_vertex_attrib_64bit";
const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic";
const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote";
const char* const E_GL_KHR_shader_subgroup_arithmetic = "GL_KHR_shader_subgroup_arithmetic";
const char* const E_GL_KHR_shader_subgroup_ballot = "GL_KHR_shader_subgroup_ballot";
const char* const E_GL_KHR_shader_subgroup_shuffle = "GL_KHR_shader_subgroup_shuffle";
const char* const E_GL_KHR_shader_subgroup_shuffle_relative = "GL_KHR_shader_subgroup_shuffle_relative";
const char* const E_GL_KHR_shader_subgroup_clustered = "GL_KHR_shader_subgroup_clustered";
const char* const E_GL_KHR_shader_subgroup_quad = "GL_KHR_shader_subgroup_quad";
const char* const E_GL_KHR_memory_scope_semantics = "GL_KHR_memory_scope_semantics";
const char* const E_GL_EXT_shader_atomic_int64 = "GL_EXT_shader_atomic_int64";
const char* const E_GL_EXT_shader_non_constant_global_initializers = "GL_EXT_shader_non_constant_global_initializers";
const char* const E_GL_EXT_shader_image_load_formatted = "GL_EXT_shader_image_load_formatted";
const char* const E_GL_EXT_shader_16bit_storage = "GL_EXT_shader_16bit_storage";
const char* const E_GL_EXT_shader_8bit_storage = "GL_EXT_shader_8bit_storage";
// EXT extensions
const char* const E_GL_EXT_device_group = "GL_EXT_device_group";
const char* const E_GL_EXT_multiview = "GL_EXT_multiview";
const char* const E_GL_EXT_post_depth_coverage = "GL_EXT_post_depth_coverage";
const char* const E_GL_EXT_control_flow_attributes = "GL_EXT_control_flow_attributes";
const char* const E_GL_EXT_nonuniform_qualifier = "GL_EXT_nonuniform_qualifier";
const char* const E_GL_EXT_samplerless_texture_functions = "GL_EXT_samplerless_texture_functions";
const char* const E_GL_EXT_scalar_block_layout = "GL_EXT_scalar_block_layout";
const char* const E_GL_EXT_fragment_invocation_density = "GL_EXT_fragment_invocation_density";
const char* const E_GL_EXT_buffer_reference = "GL_EXT_buffer_reference";
const char* const E_GL_EXT_buffer_reference2 = "GL_EXT_buffer_reference2";
const char* const E_GL_EXT_buffer_reference_uvec2 = "GL_EXT_buffer_reference_uvec2";
const char* const E_GL_EXT_demote_to_helper_invocation = "GL_EXT_demote_to_helper_invocation";
const char* const E_GL_EXT_shader_realtime_clock = "GL_EXT_shader_realtime_clock";
const char* const E_GL_EXT_debug_printf = "GL_EXT_debug_printf";
const char* const E_GL_EXT_ray_tracing = "GL_EXT_ray_tracing";
const char* const E_GL_EXT_ray_query = "GL_EXT_ray_query";
const char* const E_GL_EXT_ray_flags_primitive_culling = "GL_EXT_ray_flags_primitive_culling";
const char* const E_GL_EXT_blend_func_extended = "GL_EXT_blend_func_extended";
const char* const E_GL_EXT_shader_implicit_conversions = "GL_EXT_shader_implicit_conversions";
const char* const E_GL_EXT_fragment_shading_rate = "GL_EXT_fragment_shading_rate";
const char* const E_GL_EXT_shader_image_int64 = "GL_EXT_shader_image_int64";
const char* const E_GL_EXT_null_initializer = "GL_EXT_null_initializer";
const char* const E_GL_EXT_shared_memory_block = "GL_EXT_shared_memory_block";
// Arrays of extensions for the above viewportEXTs duplications
const char* const post_depth_coverageEXTs[] = { E_GL_ARB_post_depth_coverage, E_GL_EXT_post_depth_coverage };
const int Num_post_depth_coverageEXTs = sizeof(post_depth_coverageEXTs) / sizeof(post_depth_coverageEXTs[0]);
// OVR extensions
const char* const E_GL_OVR_multiview = "GL_OVR_multiview";
const char* const E_GL_OVR_multiview2 = "GL_OVR_multiview2";
const char* const OVR_multiview_EXTs[] = { E_GL_OVR_multiview, E_GL_OVR_multiview2 };
const int Num_OVR_multiview_EXTs = sizeof(OVR_multiview_EXTs) / sizeof(OVR_multiview_EXTs[0]);
// #line and #include
const char* const E_GL_GOOGLE_cpp_style_line_directive = "GL_GOOGLE_cpp_style_line_directive";
const char* const E_GL_GOOGLE_include_directive = "GL_GOOGLE_include_directive";
const char* const E_GL_AMD_shader_ballot = "GL_AMD_shader_ballot";
const char* const E_GL_AMD_shader_trinary_minmax = "GL_AMD_shader_trinary_minmax";
const char* const E_GL_AMD_shader_explicit_vertex_parameter = "GL_AMD_shader_explicit_vertex_parameter";
const char* const E_GL_AMD_gcn_shader = "GL_AMD_gcn_shader";
const char* const E_GL_AMD_gpu_shader_half_float = "GL_AMD_gpu_shader_half_float";
const char* const E_GL_AMD_texture_gather_bias_lod = "GL_AMD_texture_gather_bias_lod";
const char* const E_GL_AMD_gpu_shader_int16 = "GL_AMD_gpu_shader_int16";
const char* const E_GL_AMD_shader_image_load_store_lod = "GL_AMD_shader_image_load_store_lod";
const char* const E_GL_AMD_shader_fragment_mask = "GL_AMD_shader_fragment_mask";
const char* const E_GL_AMD_gpu_shader_half_float_fetch = "GL_AMD_gpu_shader_half_float_fetch";
const char* const E_GL_INTEL_shader_integer_functions2 = "GL_INTEL_shader_integer_functions2";
const char* const E_GL_NV_sample_mask_override_coverage = "GL_NV_sample_mask_override_coverage";
const char* const E_SPV_NV_geometry_shader_passthrough = "GL_NV_geometry_shader_passthrough";
const char* const E_GL_NV_viewport_array2 = "GL_NV_viewport_array2";
const char* const E_GL_NV_stereo_view_rendering = "GL_NV_stereo_view_rendering";
const char* const E_GL_NVX_multiview_per_view_attributes = "GL_NVX_multiview_per_view_attributes";
const char* const E_GL_NV_shader_atomic_int64 = "GL_NV_shader_atomic_int64";
const char* const E_GL_NV_conservative_raster_underestimation = "GL_NV_conservative_raster_underestimation";
const char* const E_GL_NV_shader_noperspective_interpolation = "GL_NV_shader_noperspective_interpolation";
const char* const E_GL_NV_shader_subgroup_partitioned = "GL_NV_shader_subgroup_partitioned";
const char* const E_GL_NV_shading_rate_image = "GL_NV_shading_rate_image";
const char* const E_GL_NV_ray_tracing = "GL_NV_ray_tracing";
const char* const E_GL_NV_fragment_shader_barycentric = "GL_NV_fragment_shader_barycentric";
const char* const E_GL_NV_compute_shader_derivatives = "GL_NV_compute_shader_derivatives";
const char* const E_GL_NV_shader_texture_footprint = "GL_NV_shader_texture_footprint";
const char* const E_GL_NV_mesh_shader = "GL_NV_mesh_shader";
// Arrays of extensions for the above viewportEXTs duplications
const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_NV_viewport_array2 };
const int Num_viewportEXTs = sizeof(viewportEXTs) / sizeof(viewportEXTs[0]);
const char* const E_GL_NV_cooperative_matrix = "GL_NV_cooperative_matrix";
const char* const E_GL_NV_shader_sm_builtins = "GL_NV_shader_sm_builtins";
const char* const E_GL_NV_integer_cooperative_matrix = "GL_NV_integer_cooperative_matrix";
// AEP
const char* const E_GL_ANDROID_extension_pack_es31a = "GL_ANDROID_extension_pack_es31a";
const char* const E_GL_KHR_blend_equation_advanced = "GL_KHR_blend_equation_advanced";
const char* const E_GL_OES_sample_variables = "GL_OES_sample_variables";
const char* const E_GL_OES_shader_image_atomic = "GL_OES_shader_image_atomic";
const char* const E_GL_OES_shader_multisample_interpolation = "GL_OES_shader_multisample_interpolation";
const char* const E_GL_OES_texture_storage_multisample_2d_array = "GL_OES_texture_storage_multisample_2d_array";
const char* const E_GL_EXT_geometry_shader = "GL_EXT_geometry_shader";
const char* const E_GL_EXT_geometry_point_size = "GL_EXT_geometry_point_size";
const char* const E_GL_EXT_gpu_shader5 = "GL_EXT_gpu_shader5";
const char* const E_GL_EXT_primitive_bounding_box = "GL_EXT_primitive_bounding_box";
const char* const E_GL_EXT_shader_io_blocks = "GL_EXT_shader_io_blocks";
const char* const E_GL_EXT_tessellation_shader = "GL_EXT_tessellation_shader";
const char* const E_GL_EXT_tessellation_point_size = "GL_EXT_tessellation_point_size";
const char* const E_GL_EXT_texture_buffer = "GL_EXT_texture_buffer";
const char* const E_GL_EXT_texture_cube_map_array = "GL_EXT_texture_cube_map_array";
const char* const E_GL_EXT_shader_integer_mix = "GL_EXT_shader_integer_mix";
// OES matching AEP
const char* const E_GL_OES_geometry_shader = "GL_OES_geometry_shader";
const char* const E_GL_OES_geometry_point_size = "GL_OES_geometry_point_size";
const char* const E_GL_OES_gpu_shader5 = "GL_OES_gpu_shader5";
const char* const E_GL_OES_primitive_bounding_box = "GL_OES_primitive_bounding_box";
const char* const E_GL_OES_shader_io_blocks = "GL_OES_shader_io_blocks";
const char* const E_GL_OES_tessellation_shader = "GL_OES_tessellation_shader";
const char* const E_GL_OES_tessellation_point_size = "GL_OES_tessellation_point_size";
const char* const E_GL_OES_texture_buffer = "GL_OES_texture_buffer";
const char* const E_GL_OES_texture_cube_map_array = "GL_OES_texture_cube_map_array";
// EXT
const char* const E_GL_EXT_shader_explicit_arithmetic_types = "GL_EXT_shader_explicit_arithmetic_types";
const char* const E_GL_EXT_shader_explicit_arithmetic_types_int8 = "GL_EXT_shader_explicit_arithmetic_types_int8";
const char* const E_GL_EXT_shader_explicit_arithmetic_types_int16 = "GL_EXT_shader_explicit_arithmetic_types_int16";
const char* const E_GL_EXT_shader_explicit_arithmetic_types_int32 = "GL_EXT_shader_explicit_arithmetic_types_int32";
const char* const E_GL_EXT_shader_explicit_arithmetic_types_int64 = "GL_EXT_shader_explicit_arithmetic_types_int64";
const char* const E_GL_EXT_shader_explicit_arithmetic_types_float16 = "GL_EXT_shader_explicit_arithmetic_types_float16";
const char* const E_GL_EXT_shader_explicit_arithmetic_types_float32 = "GL_EXT_shader_explicit_arithmetic_types_float32";
const char* const E_GL_EXT_shader_explicit_arithmetic_types_float64 = "GL_EXT_shader_explicit_arithmetic_types_float64";
const char* const E_GL_EXT_shader_subgroup_extended_types_int8 = "GL_EXT_shader_subgroup_extended_types_int8";
const char* const E_GL_EXT_shader_subgroup_extended_types_int16 = "GL_EXT_shader_subgroup_extended_types_int16";
const char* const E_GL_EXT_shader_subgroup_extended_types_int64 = "GL_EXT_shader_subgroup_extended_types_int64";
const char* const E_GL_EXT_shader_subgroup_extended_types_float16 = "GL_EXT_shader_subgroup_extended_types_float16";
const char* const E_GL_EXT_terminate_invocation = "GL_EXT_terminate_invocation";
const char* const E_GL_EXT_shader_atomic_float = "GL_EXT_shader_atomic_float";
// Arrays of extensions for the above AEP duplications
const char* const AEP_geometry_shader[] = { E_GL_EXT_geometry_shader, E_GL_OES_geometry_shader };
const int Num_AEP_geometry_shader = sizeof(AEP_geometry_shader)/sizeof(AEP_geometry_shader[0]);
const char* const AEP_geometry_point_size[] = { E_GL_EXT_geometry_point_size, E_GL_OES_geometry_point_size };
const int Num_AEP_geometry_point_size = sizeof(AEP_geometry_point_size)/sizeof(AEP_geometry_point_size[0]);
const char* const AEP_gpu_shader5[] = { E_GL_EXT_gpu_shader5, E_GL_OES_gpu_shader5 };
const int Num_AEP_gpu_shader5 = sizeof(AEP_gpu_shader5)/sizeof(AEP_gpu_shader5[0]);
const char* const AEP_primitive_bounding_box[] = { E_GL_EXT_primitive_bounding_box, E_GL_OES_primitive_bounding_box };
const int Num_AEP_primitive_bounding_box = sizeof(AEP_primitive_bounding_box)/sizeof(AEP_primitive_bounding_box[0]);
const char* const AEP_shader_io_blocks[] = { E_GL_EXT_shader_io_blocks, E_GL_OES_shader_io_blocks };
const int Num_AEP_shader_io_blocks = sizeof(AEP_shader_io_blocks)/sizeof(AEP_shader_io_blocks[0]);
const char* const AEP_tessellation_shader[] = { E_GL_EXT_tessellation_shader, E_GL_OES_tessellation_shader };
const int Num_AEP_tessellation_shader = sizeof(AEP_tessellation_shader)/sizeof(AEP_tessellation_shader[0]);
const char* const AEP_tessellation_point_size[] = { E_GL_EXT_tessellation_point_size, E_GL_OES_tessellation_point_size };
const int Num_AEP_tessellation_point_size = sizeof(AEP_tessellation_point_size)/sizeof(AEP_tessellation_point_size[0]);
const char* const AEP_texture_buffer[] = { E_GL_EXT_texture_buffer, E_GL_OES_texture_buffer };
const int Num_AEP_texture_buffer = sizeof(AEP_texture_buffer)/sizeof(AEP_texture_buffer[0]);
const char* const AEP_texture_cube_map_array[] = { E_GL_EXT_texture_cube_map_array, E_GL_OES_texture_cube_map_array };
const int Num_AEP_texture_cube_map_array = sizeof(AEP_texture_cube_map_array)/sizeof(AEP_texture_cube_map_array[0]);
} // end namespace glslang
#endif // _VERSIONS_INCLUDED_

@ -0,0 +1,149 @@
//
// Copyright (C) 2017 LunarG, Inc.
// Copyright (C) 2018 Google, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _ATTRIBUTE_INCLUDED_
#define _ATTRIBUTE_INCLUDED_
#include "../Include/Common.h"
#include "../Include/ConstantUnion.h"
namespace glslang {
enum TAttributeType {
EatNone,
EatAllow_uav_condition,
EatBranch,
EatCall,
EatDomain,
EatEarlyDepthStencil,
EatFastOpt,
EatFlatten,
EatForceCase,
EatInstance,
EatMaxTessFactor,
EatNumThreads,
EatMaxVertexCount,
EatOutputControlPoints,
EatOutputTopology,
EatPartitioning,
EatPatchConstantFunc,
EatPatchSize,
EatUnroll,
EatLoop,
EatBinding,
EatGlobalBinding,
EatLocation,
EatInputAttachment,
EatBuiltIn,
EatPushConstant,
EatConstantId,
EatDependencyInfinite,
EatDependencyLength,
EatMinIterations,
EatMaxIterations,
EatIterationMultiple,
EatPeelCount,
EatPartialCount,
EatFormatRgba32f,
EatFormatRgba16f,
EatFormatR32f,
EatFormatRgba8,
EatFormatRgba8Snorm,
EatFormatRg32f,
EatFormatRg16f,
EatFormatR11fG11fB10f,
EatFormatR16f,
EatFormatRgba16,
EatFormatRgb10A2,
EatFormatRg16,
EatFormatRg8,
EatFormatR16,
EatFormatR8,
EatFormatRgba16Snorm,
EatFormatRg16Snorm,
EatFormatRg8Snorm,
EatFormatR16Snorm,
EatFormatR8Snorm,
EatFormatRgba32i,
EatFormatRgba16i,
EatFormatRgba8i,
EatFormatR32i,
EatFormatRg32i,
EatFormatRg16i,
EatFormatRg8i,
EatFormatR16i,
EatFormatR8i,
EatFormatRgba32ui,
EatFormatRgba16ui,
EatFormatRgba8ui,
EatFormatR32ui,
EatFormatRgb10a2ui,
EatFormatRg32ui,
EatFormatRg16ui,
EatFormatRg8ui,
EatFormatR16ui,
EatFormatR8ui,
EatFormatUnknown,
EatNonWritable,
EatNonReadable
};
class TIntermAggregate;
struct TAttributeArgs {
TAttributeType name;
const TIntermAggregate* args;
// Obtain attribute as integer
// Return false if it cannot be obtained
bool getInt(int& value, int argNum = 0) const;
// Obtain attribute as string, with optional to-lower transform
// Return false if it cannot be obtained
bool getString(TString& value, int argNum = 0, bool convertToLower = true) const;
// How many arguments were provided to the attribute?
int size() const;
protected:
const TConstUnion* getConstUnion(TBasicType basicType, int argNum) const;
};
typedef TList<TAttributeArgs> TAttributes;
} // end namespace glslang
#endif // _ATTRIBUTE_INCLUDED_

@ -0,0 +1,218 @@
/*
** Copyright (c) 2013 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#pragma once
#define GL_FLOAT 0x1406
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51
#define GL_FLOAT_VEC4 0x8B52
#define GL_DOUBLE 0x140A
#define GL_DOUBLE_VEC2 0x8FFC
#define GL_DOUBLE_VEC3 0x8FFD
#define GL_DOUBLE_VEC4 0x8FFE
#define GL_INT 0x1404
#define GL_INT_VEC2 0x8B53
#define GL_INT_VEC3 0x8B54
#define GL_INT_VEC4 0x8B55
#define GL_UNSIGNED_INT 0x1405
#define GL_UNSIGNED_INT_VEC2 0x8DC6
#define GL_UNSIGNED_INT_VEC3 0x8DC7
#define GL_UNSIGNED_INT_VEC4 0x8DC8
#define GL_INT64_ARB 0x140E
#define GL_INT64_VEC2_ARB 0x8FE9
#define GL_INT64_VEC3_ARB 0x8FEA
#define GL_INT64_VEC4_ARB 0x8FEB
#define GL_UNSIGNED_INT64_ARB 0x140F
#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FE5
#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FE6
#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FE7
#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1
#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2
#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3
#define GL_INT16_NV 0x8FE4
#define GL_INT16_VEC2_NV 0x8FE5
#define GL_INT16_VEC3_NV 0x8FE6
#define GL_INT16_VEC4_NV 0x8FE7
#define GL_BOOL 0x8B56
#define GL_BOOL_VEC2 0x8B57
#define GL_BOOL_VEC3 0x8B58
#define GL_BOOL_VEC4 0x8B59
#define GL_FLOAT_MAT2 0x8B5A
#define GL_FLOAT_MAT3 0x8B5B
#define GL_FLOAT_MAT4 0x8B5C
#define GL_FLOAT_MAT2x3 0x8B65
#define GL_FLOAT_MAT2x4 0x8B66
#define GL_FLOAT_MAT3x2 0x8B67
#define GL_FLOAT_MAT3x4 0x8B68
#define GL_FLOAT_MAT4x2 0x8B69
#define GL_FLOAT_MAT4x3 0x8B6A
#define GL_DOUBLE_MAT2 0x8F46
#define GL_DOUBLE_MAT3 0x8F47
#define GL_DOUBLE_MAT4 0x8F48
#define GL_DOUBLE_MAT2x3 0x8F49
#define GL_DOUBLE_MAT2x4 0x8F4A
#define GL_DOUBLE_MAT3x2 0x8F4B
#define GL_DOUBLE_MAT3x4 0x8F4C
#define GL_DOUBLE_MAT4x2 0x8F4D
#define GL_DOUBLE_MAT4x3 0x8F4E
// Those constants are borrowed from extension NV_gpu_shader5
#define GL_FLOAT16_NV 0x8FF8
#define GL_FLOAT16_VEC2_NV 0x8FF9
#define GL_FLOAT16_VEC3_NV 0x8FFA
#define GL_FLOAT16_VEC4_NV 0x8FFB
#define GL_FLOAT16_MAT2_AMD 0x91C5
#define GL_FLOAT16_MAT3_AMD 0x91C6
#define GL_FLOAT16_MAT4_AMD 0x91C7
#define GL_FLOAT16_MAT2x3_AMD 0x91C8
#define GL_FLOAT16_MAT2x4_AMD 0x91C9
#define GL_FLOAT16_MAT3x2_AMD 0x91CA
#define GL_FLOAT16_MAT3x4_AMD 0x91CB
#define GL_FLOAT16_MAT4x2_AMD 0x91CC
#define GL_FLOAT16_MAT4x3_AMD 0x91CD
#define GL_SAMPLER_1D 0x8B5D
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_3D 0x8B5F
#define GL_SAMPLER_CUBE 0x8B60
#define GL_SAMPLER_BUFFER 0x8DC2
#define GL_SAMPLER_1D_ARRAY 0x8DC0
#define GL_SAMPLER_2D_ARRAY 0x8DC1
#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
#define GL_SAMPLER_1D_SHADOW 0x8B61
#define GL_SAMPLER_2D_SHADOW 0x8B62
#define GL_SAMPLER_2D_RECT 0x8B63
#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C
#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D
#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C
#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D
#define GL_FLOAT16_SAMPLER_1D_AMD 0x91CE
#define GL_FLOAT16_SAMPLER_2D_AMD 0x91CF
#define GL_FLOAT16_SAMPLER_3D_AMD 0x91D0
#define GL_FLOAT16_SAMPLER_CUBE_AMD 0x91D1
#define GL_FLOAT16_SAMPLER_2D_RECT_AMD 0x91D2
#define GL_FLOAT16_SAMPLER_1D_ARRAY_AMD 0x91D3
#define GL_FLOAT16_SAMPLER_2D_ARRAY_AMD 0x91D4
#define GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_AMD 0x91D5
#define GL_FLOAT16_SAMPLER_BUFFER_AMD 0x91D6
#define GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_AMD 0x91D7
#define GL_FLOAT16_SAMPLER_2D_MULTISAMPLE_ARRAY_AMD 0x91D8
#define GL_FLOAT16_SAMPLER_1D_SHADOW_AMD 0x91D9
#define GL_FLOAT16_SAMPLER_2D_SHADOW_AMD 0x91DA
#define GL_FLOAT16_SAMPLER_2D_RECT_SHADOW_AMD 0x91DB
#define GL_FLOAT16_SAMPLER_1D_ARRAY_SHADOW_AMD 0x91DC
#define GL_FLOAT16_SAMPLER_2D_ARRAY_SHADOW_AMD 0x91DD
#define GL_FLOAT16_SAMPLER_CUBE_SHADOW_AMD 0x91DE
#define GL_FLOAT16_SAMPLER_CUBE_MAP_ARRAY_SHADOW_AMD 0x91DF
#define GL_FLOAT16_IMAGE_1D_AMD 0x91E0
#define GL_FLOAT16_IMAGE_2D_AMD 0x91E1
#define GL_FLOAT16_IMAGE_3D_AMD 0x91E2
#define GL_FLOAT16_IMAGE_2D_RECT_AMD 0x91E3
#define GL_FLOAT16_IMAGE_CUBE_AMD 0x91E4
#define GL_FLOAT16_IMAGE_1D_ARRAY_AMD 0x91E5
#define GL_FLOAT16_IMAGE_2D_ARRAY_AMD 0x91E6
#define GL_FLOAT16_IMAGE_CUBE_MAP_ARRAY_AMD 0x91E7
#define GL_FLOAT16_IMAGE_BUFFER_AMD 0x91E8
#define GL_FLOAT16_IMAGE_2D_MULTISAMPLE_AMD 0x91E9
#define GL_FLOAT16_IMAGE_2D_MULTISAMPLE_ARRAY_AMD 0x91EA
#define GL_INT_SAMPLER_1D 0x8DC9
#define GL_INT_SAMPLER_2D 0x8DCA
#define GL_INT_SAMPLER_3D 0x8DCB
#define GL_INT_SAMPLER_CUBE 0x8DCC
#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
#define GL_INT_SAMPLER_2D_RECT 0x8DCD
#define GL_INT_SAMPLER_BUFFER 0x8DD0
#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E
#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
#define GL_IMAGE_1D 0x904C
#define GL_IMAGE_2D 0x904D
#define GL_IMAGE_3D 0x904E
#define GL_IMAGE_2D_RECT 0x904F
#define GL_IMAGE_CUBE 0x9050
#define GL_IMAGE_BUFFER 0x9051
#define GL_IMAGE_1D_ARRAY 0x9052
#define GL_IMAGE_2D_ARRAY 0x9053
#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
#define GL_IMAGE_2D_MULTISAMPLE 0x9055
#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056
#define GL_INT_IMAGE_1D 0x9057
#define GL_INT_IMAGE_2D 0x9058
#define GL_INT_IMAGE_3D 0x9059
#define GL_INT_IMAGE_2D_RECT 0x905A
#define GL_INT_IMAGE_CUBE 0x905B
#define GL_INT_IMAGE_BUFFER 0x905C
#define GL_INT_IMAGE_1D_ARRAY 0x905D
#define GL_INT_IMAGE_2D_ARRAY 0x905E
#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060
#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
#define GL_UNSIGNED_INT_IMAGE_1D 0x9062
#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065
#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB

@ -0,0 +1,555 @@
/* A Bison parser, made by GNU Bison 3.7.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED
# define YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
CONST = 258, /* CONST */
BOOL = 259, /* BOOL */
INT = 260, /* INT */
UINT = 261, /* UINT */
FLOAT = 262, /* FLOAT */
BVEC2 = 263, /* BVEC2 */
BVEC3 = 264, /* BVEC3 */
BVEC4 = 265, /* BVEC4 */
IVEC2 = 266, /* IVEC2 */
IVEC3 = 267, /* IVEC3 */
IVEC4 = 268, /* IVEC4 */
UVEC2 = 269, /* UVEC2 */
UVEC3 = 270, /* UVEC3 */
UVEC4 = 271, /* UVEC4 */
VEC2 = 272, /* VEC2 */
VEC3 = 273, /* VEC3 */
VEC4 = 274, /* VEC4 */
MAT2 = 275, /* MAT2 */
MAT3 = 276, /* MAT3 */
MAT4 = 277, /* MAT4 */
MAT2X2 = 278, /* MAT2X2 */
MAT2X3 = 279, /* MAT2X3 */
MAT2X4 = 280, /* MAT2X4 */
MAT3X2 = 281, /* MAT3X2 */
MAT3X3 = 282, /* MAT3X3 */
MAT3X4 = 283, /* MAT3X4 */
MAT4X2 = 284, /* MAT4X2 */
MAT4X3 = 285, /* MAT4X3 */
MAT4X4 = 286, /* MAT4X4 */
SAMPLER2D = 287, /* SAMPLER2D */
SAMPLER3D = 288, /* SAMPLER3D */
SAMPLERCUBE = 289, /* SAMPLERCUBE */
SAMPLER2DSHADOW = 290, /* SAMPLER2DSHADOW */
SAMPLERCUBESHADOW = 291, /* SAMPLERCUBESHADOW */
SAMPLER2DARRAY = 292, /* SAMPLER2DARRAY */
SAMPLER2DARRAYSHADOW = 293, /* SAMPLER2DARRAYSHADOW */
ISAMPLER2D = 294, /* ISAMPLER2D */
ISAMPLER3D = 295, /* ISAMPLER3D */
ISAMPLERCUBE = 296, /* ISAMPLERCUBE */
ISAMPLER2DARRAY = 297, /* ISAMPLER2DARRAY */
USAMPLER2D = 298, /* USAMPLER2D */
USAMPLER3D = 299, /* USAMPLER3D */
USAMPLERCUBE = 300, /* USAMPLERCUBE */
USAMPLER2DARRAY = 301, /* USAMPLER2DARRAY */
SAMPLER = 302, /* SAMPLER */
SAMPLERSHADOW = 303, /* SAMPLERSHADOW */
TEXTURE2D = 304, /* TEXTURE2D */
TEXTURE3D = 305, /* TEXTURE3D */
TEXTURECUBE = 306, /* TEXTURECUBE */
TEXTURE2DARRAY = 307, /* TEXTURE2DARRAY */
ITEXTURE2D = 308, /* ITEXTURE2D */
ITEXTURE3D = 309, /* ITEXTURE3D */
ITEXTURECUBE = 310, /* ITEXTURECUBE */
ITEXTURE2DARRAY = 311, /* ITEXTURE2DARRAY */
UTEXTURE2D = 312, /* UTEXTURE2D */
UTEXTURE3D = 313, /* UTEXTURE3D */
UTEXTURECUBE = 314, /* UTEXTURECUBE */
UTEXTURE2DARRAY = 315, /* UTEXTURE2DARRAY */
ATTRIBUTE = 316, /* ATTRIBUTE */
VARYING = 317, /* VARYING */
FLOAT16_T = 318, /* FLOAT16_T */
FLOAT32_T = 319, /* FLOAT32_T */
DOUBLE = 320, /* DOUBLE */
FLOAT64_T = 321, /* FLOAT64_T */
INT64_T = 322, /* INT64_T */
UINT64_T = 323, /* UINT64_T */
INT32_T = 324, /* INT32_T */
UINT32_T = 325, /* UINT32_T */
INT16_T = 326, /* INT16_T */
UINT16_T = 327, /* UINT16_T */
INT8_T = 328, /* INT8_T */
UINT8_T = 329, /* UINT8_T */
I64VEC2 = 330, /* I64VEC2 */
I64VEC3 = 331, /* I64VEC3 */
I64VEC4 = 332, /* I64VEC4 */
U64VEC2 = 333, /* U64VEC2 */
U64VEC3 = 334, /* U64VEC3 */
U64VEC4 = 335, /* U64VEC4 */
I32VEC2 = 336, /* I32VEC2 */
I32VEC3 = 337, /* I32VEC3 */
I32VEC4 = 338, /* I32VEC4 */
U32VEC2 = 339, /* U32VEC2 */
U32VEC3 = 340, /* U32VEC3 */
U32VEC4 = 341, /* U32VEC4 */
I16VEC2 = 342, /* I16VEC2 */
I16VEC3 = 343, /* I16VEC3 */
I16VEC4 = 344, /* I16VEC4 */
U16VEC2 = 345, /* U16VEC2 */
U16VEC3 = 346, /* U16VEC3 */
U16VEC4 = 347, /* U16VEC4 */
I8VEC2 = 348, /* I8VEC2 */
I8VEC3 = 349, /* I8VEC3 */
I8VEC4 = 350, /* I8VEC4 */
U8VEC2 = 351, /* U8VEC2 */
U8VEC3 = 352, /* U8VEC3 */
U8VEC4 = 353, /* U8VEC4 */
DVEC2 = 354, /* DVEC2 */
DVEC3 = 355, /* DVEC3 */
DVEC4 = 356, /* DVEC4 */
DMAT2 = 357, /* DMAT2 */
DMAT3 = 358, /* DMAT3 */
DMAT4 = 359, /* DMAT4 */
F16VEC2 = 360, /* F16VEC2 */
F16VEC3 = 361, /* F16VEC3 */
F16VEC4 = 362, /* F16VEC4 */
F16MAT2 = 363, /* F16MAT2 */
F16MAT3 = 364, /* F16MAT3 */
F16MAT4 = 365, /* F16MAT4 */
F32VEC2 = 366, /* F32VEC2 */
F32VEC3 = 367, /* F32VEC3 */
F32VEC4 = 368, /* F32VEC4 */
F32MAT2 = 369, /* F32MAT2 */
F32MAT3 = 370, /* F32MAT3 */
F32MAT4 = 371, /* F32MAT4 */
F64VEC2 = 372, /* F64VEC2 */
F64VEC3 = 373, /* F64VEC3 */
F64VEC4 = 374, /* F64VEC4 */
F64MAT2 = 375, /* F64MAT2 */
F64MAT3 = 376, /* F64MAT3 */
F64MAT4 = 377, /* F64MAT4 */
DMAT2X2 = 378, /* DMAT2X2 */
DMAT2X3 = 379, /* DMAT2X3 */
DMAT2X4 = 380, /* DMAT2X4 */
DMAT3X2 = 381, /* DMAT3X2 */
DMAT3X3 = 382, /* DMAT3X3 */
DMAT3X4 = 383, /* DMAT3X4 */
DMAT4X2 = 384, /* DMAT4X2 */
DMAT4X3 = 385, /* DMAT4X3 */
DMAT4X4 = 386, /* DMAT4X4 */
F16MAT2X2 = 387, /* F16MAT2X2 */
F16MAT2X3 = 388, /* F16MAT2X3 */
F16MAT2X4 = 389, /* F16MAT2X4 */
F16MAT3X2 = 390, /* F16MAT3X2 */
F16MAT3X3 = 391, /* F16MAT3X3 */
F16MAT3X4 = 392, /* F16MAT3X4 */
F16MAT4X2 = 393, /* F16MAT4X2 */
F16MAT4X3 = 394, /* F16MAT4X3 */
F16MAT4X4 = 395, /* F16MAT4X4 */
F32MAT2X2 = 396, /* F32MAT2X2 */
F32MAT2X3 = 397, /* F32MAT2X3 */
F32MAT2X4 = 398, /* F32MAT2X4 */
F32MAT3X2 = 399, /* F32MAT3X2 */
F32MAT3X3 = 400, /* F32MAT3X3 */
F32MAT3X4 = 401, /* F32MAT3X4 */
F32MAT4X2 = 402, /* F32MAT4X2 */
F32MAT4X3 = 403, /* F32MAT4X3 */
F32MAT4X4 = 404, /* F32MAT4X4 */
F64MAT2X2 = 405, /* F64MAT2X2 */
F64MAT2X3 = 406, /* F64MAT2X3 */
F64MAT2X4 = 407, /* F64MAT2X4 */
F64MAT3X2 = 408, /* F64MAT3X2 */
F64MAT3X3 = 409, /* F64MAT3X3 */
F64MAT3X4 = 410, /* F64MAT3X4 */
F64MAT4X2 = 411, /* F64MAT4X2 */
F64MAT4X3 = 412, /* F64MAT4X3 */
F64MAT4X4 = 413, /* F64MAT4X4 */
ATOMIC_UINT = 414, /* ATOMIC_UINT */
ACCSTRUCTNV = 415, /* ACCSTRUCTNV */
ACCSTRUCTEXT = 416, /* ACCSTRUCTEXT */
RAYQUERYEXT = 417, /* RAYQUERYEXT */
FCOOPMATNV = 418, /* FCOOPMATNV */
ICOOPMATNV = 419, /* ICOOPMATNV */
UCOOPMATNV = 420, /* UCOOPMATNV */
SAMPLERCUBEARRAY = 421, /* SAMPLERCUBEARRAY */
SAMPLERCUBEARRAYSHADOW = 422, /* SAMPLERCUBEARRAYSHADOW */
ISAMPLERCUBEARRAY = 423, /* ISAMPLERCUBEARRAY */
USAMPLERCUBEARRAY = 424, /* USAMPLERCUBEARRAY */
SAMPLER1D = 425, /* SAMPLER1D */
SAMPLER1DARRAY = 426, /* SAMPLER1DARRAY */
SAMPLER1DARRAYSHADOW = 427, /* SAMPLER1DARRAYSHADOW */
ISAMPLER1D = 428, /* ISAMPLER1D */
SAMPLER1DSHADOW = 429, /* SAMPLER1DSHADOW */
SAMPLER2DRECT = 430, /* SAMPLER2DRECT */
SAMPLER2DRECTSHADOW = 431, /* SAMPLER2DRECTSHADOW */
ISAMPLER2DRECT = 432, /* ISAMPLER2DRECT */
USAMPLER2DRECT = 433, /* USAMPLER2DRECT */
SAMPLERBUFFER = 434, /* SAMPLERBUFFER */
ISAMPLERBUFFER = 435, /* ISAMPLERBUFFER */
USAMPLERBUFFER = 436, /* USAMPLERBUFFER */
SAMPLER2DMS = 437, /* SAMPLER2DMS */
ISAMPLER2DMS = 438, /* ISAMPLER2DMS */
USAMPLER2DMS = 439, /* USAMPLER2DMS */
SAMPLER2DMSARRAY = 440, /* SAMPLER2DMSARRAY */
ISAMPLER2DMSARRAY = 441, /* ISAMPLER2DMSARRAY */
USAMPLER2DMSARRAY = 442, /* USAMPLER2DMSARRAY */
SAMPLEREXTERNALOES = 443, /* SAMPLEREXTERNALOES */
SAMPLEREXTERNAL2DY2YEXT = 444, /* SAMPLEREXTERNAL2DY2YEXT */
ISAMPLER1DARRAY = 445, /* ISAMPLER1DARRAY */
USAMPLER1D = 446, /* USAMPLER1D */
USAMPLER1DARRAY = 447, /* USAMPLER1DARRAY */
F16SAMPLER1D = 448, /* F16SAMPLER1D */
F16SAMPLER2D = 449, /* F16SAMPLER2D */
F16SAMPLER3D = 450, /* F16SAMPLER3D */
F16SAMPLER2DRECT = 451, /* F16SAMPLER2DRECT */
F16SAMPLERCUBE = 452, /* F16SAMPLERCUBE */
F16SAMPLER1DARRAY = 453, /* F16SAMPLER1DARRAY */
F16SAMPLER2DARRAY = 454, /* F16SAMPLER2DARRAY */
F16SAMPLERCUBEARRAY = 455, /* F16SAMPLERCUBEARRAY */
F16SAMPLERBUFFER = 456, /* F16SAMPLERBUFFER */
F16SAMPLER2DMS = 457, /* F16SAMPLER2DMS */
F16SAMPLER2DMSARRAY = 458, /* F16SAMPLER2DMSARRAY */
F16SAMPLER1DSHADOW = 459, /* F16SAMPLER1DSHADOW */
F16SAMPLER2DSHADOW = 460, /* F16SAMPLER2DSHADOW */
F16SAMPLER1DARRAYSHADOW = 461, /* F16SAMPLER1DARRAYSHADOW */
F16SAMPLER2DARRAYSHADOW = 462, /* F16SAMPLER2DARRAYSHADOW */
F16SAMPLER2DRECTSHADOW = 463, /* F16SAMPLER2DRECTSHADOW */
F16SAMPLERCUBESHADOW = 464, /* F16SAMPLERCUBESHADOW */
F16SAMPLERCUBEARRAYSHADOW = 465, /* F16SAMPLERCUBEARRAYSHADOW */
IMAGE1D = 466, /* IMAGE1D */
IIMAGE1D = 467, /* IIMAGE1D */
UIMAGE1D = 468, /* UIMAGE1D */
IMAGE2D = 469, /* IMAGE2D */
IIMAGE2D = 470, /* IIMAGE2D */
UIMAGE2D = 471, /* UIMAGE2D */
IMAGE3D = 472, /* IMAGE3D */
IIMAGE3D = 473, /* IIMAGE3D */
UIMAGE3D = 474, /* UIMAGE3D */
IMAGE2DRECT = 475, /* IMAGE2DRECT */
IIMAGE2DRECT = 476, /* IIMAGE2DRECT */
UIMAGE2DRECT = 477, /* UIMAGE2DRECT */
IMAGECUBE = 478, /* IMAGECUBE */
IIMAGECUBE = 479, /* IIMAGECUBE */
UIMAGECUBE = 480, /* UIMAGECUBE */
IMAGEBUFFER = 481, /* IMAGEBUFFER */
IIMAGEBUFFER = 482, /* IIMAGEBUFFER */
UIMAGEBUFFER = 483, /* UIMAGEBUFFER */
IMAGE1DARRAY = 484, /* IMAGE1DARRAY */
IIMAGE1DARRAY = 485, /* IIMAGE1DARRAY */
UIMAGE1DARRAY = 486, /* UIMAGE1DARRAY */
IMAGE2DARRAY = 487, /* IMAGE2DARRAY */
IIMAGE2DARRAY = 488, /* IIMAGE2DARRAY */
UIMAGE2DARRAY = 489, /* UIMAGE2DARRAY */
IMAGECUBEARRAY = 490, /* IMAGECUBEARRAY */
IIMAGECUBEARRAY = 491, /* IIMAGECUBEARRAY */
UIMAGECUBEARRAY = 492, /* UIMAGECUBEARRAY */
IMAGE2DMS = 493, /* IMAGE2DMS */
IIMAGE2DMS = 494, /* IIMAGE2DMS */
UIMAGE2DMS = 495, /* UIMAGE2DMS */
IMAGE2DMSARRAY = 496, /* IMAGE2DMSARRAY */
IIMAGE2DMSARRAY = 497, /* IIMAGE2DMSARRAY */
UIMAGE2DMSARRAY = 498, /* UIMAGE2DMSARRAY */
F16IMAGE1D = 499, /* F16IMAGE1D */
F16IMAGE2D = 500, /* F16IMAGE2D */
F16IMAGE3D = 501, /* F16IMAGE3D */
F16IMAGE2DRECT = 502, /* F16IMAGE2DRECT */
F16IMAGECUBE = 503, /* F16IMAGECUBE */
F16IMAGE1DARRAY = 504, /* F16IMAGE1DARRAY */
F16IMAGE2DARRAY = 505, /* F16IMAGE2DARRAY */
F16IMAGECUBEARRAY = 506, /* F16IMAGECUBEARRAY */
F16IMAGEBUFFER = 507, /* F16IMAGEBUFFER */
F16IMAGE2DMS = 508, /* F16IMAGE2DMS */
F16IMAGE2DMSARRAY = 509, /* F16IMAGE2DMSARRAY */
I64IMAGE1D = 510, /* I64IMAGE1D */
U64IMAGE1D = 511, /* U64IMAGE1D */
I64IMAGE2D = 512, /* I64IMAGE2D */
U64IMAGE2D = 513, /* U64IMAGE2D */
I64IMAGE3D = 514, /* I64IMAGE3D */
U64IMAGE3D = 515, /* U64IMAGE3D */
I64IMAGE2DRECT = 516, /* I64IMAGE2DRECT */
U64IMAGE2DRECT = 517, /* U64IMAGE2DRECT */
I64IMAGECUBE = 518, /* I64IMAGECUBE */
U64IMAGECUBE = 519, /* U64IMAGECUBE */
I64IMAGEBUFFER = 520, /* I64IMAGEBUFFER */
U64IMAGEBUFFER = 521, /* U64IMAGEBUFFER */
I64IMAGE1DARRAY = 522, /* I64IMAGE1DARRAY */
U64IMAGE1DARRAY = 523, /* U64IMAGE1DARRAY */
I64IMAGE2DARRAY = 524, /* I64IMAGE2DARRAY */
U64IMAGE2DARRAY = 525, /* U64IMAGE2DARRAY */
I64IMAGECUBEARRAY = 526, /* I64IMAGECUBEARRAY */
U64IMAGECUBEARRAY = 527, /* U64IMAGECUBEARRAY */
I64IMAGE2DMS = 528, /* I64IMAGE2DMS */
U64IMAGE2DMS = 529, /* U64IMAGE2DMS */
I64IMAGE2DMSARRAY = 530, /* I64IMAGE2DMSARRAY */
U64IMAGE2DMSARRAY = 531, /* U64IMAGE2DMSARRAY */
TEXTURECUBEARRAY = 532, /* TEXTURECUBEARRAY */
ITEXTURECUBEARRAY = 533, /* ITEXTURECUBEARRAY */
UTEXTURECUBEARRAY = 534, /* UTEXTURECUBEARRAY */
TEXTURE1D = 535, /* TEXTURE1D */
ITEXTURE1D = 536, /* ITEXTURE1D */
UTEXTURE1D = 537, /* UTEXTURE1D */
TEXTURE1DARRAY = 538, /* TEXTURE1DARRAY */
ITEXTURE1DARRAY = 539, /* ITEXTURE1DARRAY */
UTEXTURE1DARRAY = 540, /* UTEXTURE1DARRAY */
TEXTURE2DRECT = 541, /* TEXTURE2DRECT */
ITEXTURE2DRECT = 542, /* ITEXTURE2DRECT */
UTEXTURE2DRECT = 543, /* UTEXTURE2DRECT */
TEXTUREBUFFER = 544, /* TEXTUREBUFFER */
ITEXTUREBUFFER = 545, /* ITEXTUREBUFFER */
UTEXTUREBUFFER = 546, /* UTEXTUREBUFFER */
TEXTURE2DMS = 547, /* TEXTURE2DMS */
ITEXTURE2DMS = 548, /* ITEXTURE2DMS */
UTEXTURE2DMS = 549, /* UTEXTURE2DMS */
TEXTURE2DMSARRAY = 550, /* TEXTURE2DMSARRAY */
ITEXTURE2DMSARRAY = 551, /* ITEXTURE2DMSARRAY */
UTEXTURE2DMSARRAY = 552, /* UTEXTURE2DMSARRAY */
F16TEXTURE1D = 553, /* F16TEXTURE1D */
F16TEXTURE2D = 554, /* F16TEXTURE2D */
F16TEXTURE3D = 555, /* F16TEXTURE3D */
F16TEXTURE2DRECT = 556, /* F16TEXTURE2DRECT */
F16TEXTURECUBE = 557, /* F16TEXTURECUBE */
F16TEXTURE1DARRAY = 558, /* F16TEXTURE1DARRAY */
F16TEXTURE2DARRAY = 559, /* F16TEXTURE2DARRAY */
F16TEXTURECUBEARRAY = 560, /* F16TEXTURECUBEARRAY */
F16TEXTUREBUFFER = 561, /* F16TEXTUREBUFFER */
F16TEXTURE2DMS = 562, /* F16TEXTURE2DMS */
F16TEXTURE2DMSARRAY = 563, /* F16TEXTURE2DMSARRAY */
SUBPASSINPUT = 564, /* SUBPASSINPUT */
SUBPASSINPUTMS = 565, /* SUBPASSINPUTMS */
ISUBPASSINPUT = 566, /* ISUBPASSINPUT */
ISUBPASSINPUTMS = 567, /* ISUBPASSINPUTMS */
USUBPASSINPUT = 568, /* USUBPASSINPUT */
USUBPASSINPUTMS = 569, /* USUBPASSINPUTMS */
F16SUBPASSINPUT = 570, /* F16SUBPASSINPUT */
F16SUBPASSINPUTMS = 571, /* F16SUBPASSINPUTMS */
LEFT_OP = 572, /* LEFT_OP */
RIGHT_OP = 573, /* RIGHT_OP */
INC_OP = 574, /* INC_OP */
DEC_OP = 575, /* DEC_OP */
LE_OP = 576, /* LE_OP */
GE_OP = 577, /* GE_OP */
EQ_OP = 578, /* EQ_OP */
NE_OP = 579, /* NE_OP */
AND_OP = 580, /* AND_OP */
OR_OP = 581, /* OR_OP */
XOR_OP = 582, /* XOR_OP */
MUL_ASSIGN = 583, /* MUL_ASSIGN */
DIV_ASSIGN = 584, /* DIV_ASSIGN */
ADD_ASSIGN = 585, /* ADD_ASSIGN */
MOD_ASSIGN = 586, /* MOD_ASSIGN */
LEFT_ASSIGN = 587, /* LEFT_ASSIGN */
RIGHT_ASSIGN = 588, /* RIGHT_ASSIGN */
AND_ASSIGN = 589, /* AND_ASSIGN */
XOR_ASSIGN = 590, /* XOR_ASSIGN */
OR_ASSIGN = 591, /* OR_ASSIGN */
SUB_ASSIGN = 592, /* SUB_ASSIGN */
STRING_LITERAL = 593, /* STRING_LITERAL */
LEFT_PAREN = 594, /* LEFT_PAREN */
RIGHT_PAREN = 595, /* RIGHT_PAREN */
LEFT_BRACKET = 596, /* LEFT_BRACKET */
RIGHT_BRACKET = 597, /* RIGHT_BRACKET */
LEFT_BRACE = 598, /* LEFT_BRACE */
RIGHT_BRACE = 599, /* RIGHT_BRACE */
DOT = 600, /* DOT */
COMMA = 601, /* COMMA */
COLON = 602, /* COLON */
EQUAL = 603, /* EQUAL */
SEMICOLON = 604, /* SEMICOLON */
BANG = 605, /* BANG */
DASH = 606, /* DASH */
TILDE = 607, /* TILDE */
PLUS = 608, /* PLUS */
STAR = 609, /* STAR */
SLASH = 610, /* SLASH */
PERCENT = 611, /* PERCENT */
LEFT_ANGLE = 612, /* LEFT_ANGLE */
RIGHT_ANGLE = 613, /* RIGHT_ANGLE */
VERTICAL_BAR = 614, /* VERTICAL_BAR */
CARET = 615, /* CARET */
AMPERSAND = 616, /* AMPERSAND */
QUESTION = 617, /* QUESTION */
INVARIANT = 618, /* INVARIANT */
HIGH_PRECISION = 619, /* HIGH_PRECISION */
MEDIUM_PRECISION = 620, /* MEDIUM_PRECISION */
LOW_PRECISION = 621, /* LOW_PRECISION */
PRECISION = 622, /* PRECISION */
PACKED = 623, /* PACKED */
RESOURCE = 624, /* RESOURCE */
SUPERP = 625, /* SUPERP */
FLOATCONSTANT = 626, /* FLOATCONSTANT */
INTCONSTANT = 627, /* INTCONSTANT */
UINTCONSTANT = 628, /* UINTCONSTANT */
BOOLCONSTANT = 629, /* BOOLCONSTANT */
IDENTIFIER = 630, /* IDENTIFIER */
TYPE_NAME = 631, /* TYPE_NAME */
CENTROID = 632, /* CENTROID */
IN = 633, /* IN */
OUT = 634, /* OUT */
INOUT = 635, /* INOUT */
STRUCT = 636, /* STRUCT */
VOID = 637, /* VOID */
WHILE = 638, /* WHILE */
BREAK = 639, /* BREAK */
CONTINUE = 640, /* CONTINUE */
DO = 641, /* DO */
ELSE = 642, /* ELSE */
FOR = 643, /* FOR */
IF = 644, /* IF */
DISCARD = 645, /* DISCARD */
RETURN = 646, /* RETURN */
SWITCH = 647, /* SWITCH */
CASE = 648, /* CASE */
DEFAULT = 649, /* DEFAULT */
TERMINATE_INVOCATION = 650, /* TERMINATE_INVOCATION */
TERMINATE_RAY = 651, /* TERMINATE_RAY */
IGNORE_INTERSECTION = 652, /* IGNORE_INTERSECTION */
UNIFORM = 653, /* UNIFORM */
SHARED = 654, /* SHARED */
BUFFER = 655, /* BUFFER */
FLAT = 656, /* FLAT */
SMOOTH = 657, /* SMOOTH */
LAYOUT = 658, /* LAYOUT */
DOUBLECONSTANT = 659, /* DOUBLECONSTANT */
INT16CONSTANT = 660, /* INT16CONSTANT */
UINT16CONSTANT = 661, /* UINT16CONSTANT */
FLOAT16CONSTANT = 662, /* FLOAT16CONSTANT */
INT32CONSTANT = 663, /* INT32CONSTANT */
UINT32CONSTANT = 664, /* UINT32CONSTANT */
INT64CONSTANT = 665, /* INT64CONSTANT */
UINT64CONSTANT = 666, /* UINT64CONSTANT */
SUBROUTINE = 667, /* SUBROUTINE */
DEMOTE = 668, /* DEMOTE */
PAYLOADNV = 669, /* PAYLOADNV */
PAYLOADINNV = 670, /* PAYLOADINNV */
HITATTRNV = 671, /* HITATTRNV */
CALLDATANV = 672, /* CALLDATANV */
CALLDATAINNV = 673, /* CALLDATAINNV */
PAYLOADEXT = 674, /* PAYLOADEXT */
PAYLOADINEXT = 675, /* PAYLOADINEXT */
HITATTREXT = 676, /* HITATTREXT */
CALLDATAEXT = 677, /* CALLDATAEXT */
CALLDATAINEXT = 678, /* CALLDATAINEXT */
PATCH = 679, /* PATCH */
SAMPLE = 680, /* SAMPLE */
NONUNIFORM = 681, /* NONUNIFORM */
COHERENT = 682, /* COHERENT */
VOLATILE = 683, /* VOLATILE */
RESTRICT = 684, /* RESTRICT */
READONLY = 685, /* READONLY */
WRITEONLY = 686, /* WRITEONLY */
DEVICECOHERENT = 687, /* DEVICECOHERENT */
QUEUEFAMILYCOHERENT = 688, /* QUEUEFAMILYCOHERENT */
WORKGROUPCOHERENT = 689, /* WORKGROUPCOHERENT */
SUBGROUPCOHERENT = 690, /* SUBGROUPCOHERENT */
NONPRIVATE = 691, /* NONPRIVATE */
SHADERCALLCOHERENT = 692, /* SHADERCALLCOHERENT */
NOPERSPECTIVE = 693, /* NOPERSPECTIVE */
EXPLICITINTERPAMD = 694, /* EXPLICITINTERPAMD */
PERVERTEXNV = 695, /* PERVERTEXNV */
PERPRIMITIVENV = 696, /* PERPRIMITIVENV */
PERVIEWNV = 697, /* PERVIEWNV */
PERTASKNV = 698, /* PERTASKNV */
PRECISE = 699 /* PRECISE */
};
typedef enum yytokentype yytoken_kind_t;
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 97 "MachineIndependent/glslang.y"
struct {
glslang::TSourceLoc loc;
union {
glslang::TString *string;
int i;
unsigned int u;
long long i64;
unsigned long long u64;
bool b;
double d;
};
glslang::TSymbol* symbol;
} lex;
struct {
glslang::TSourceLoc loc;
glslang::TOperator op;
union {
TIntermNode* intermNode;
glslang::TIntermNodePair nodePair;
glslang::TIntermTyped* intermTypedNode;
glslang::TAttributes* attributes;
};
union {
glslang::TPublicType type;
glslang::TFunction* function;
glslang::TParameter param;
glslang::TTypeLoc typeLine;
glslang::TTypeList* typeList;
glslang::TArraySizes* arraySizes;
glslang::TIdentifierList* identifierList;
};
glslang::TArraySizes* typeParameters;
} interm;
#line 544 "MachineIndependent/glslang_tab.cpp.h"
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
int yyparse (glslang::TParseContext* pParseContext);
#endif /* !YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED */

@ -0,0 +1,305 @@
//
// Copyright (C) 2016 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#ifndef _IOMAPPER_INCLUDED
#define _IOMAPPER_INCLUDED
#include <cstdint>
#include "LiveTraverser.h"
#include <unordered_map>
#include <unordered_set>
//
// A reflection database and its interface, consistent with the OpenGL API reflection queries.
//
class TInfoSink;
namespace glslang {
class TIntermediate;
struct TVarEntryInfo {
int id;
TIntermSymbol* symbol;
bool live;
int newBinding;
int newSet;
int newLocation;
int newComponent;
int newIndex;
EShLanguage stage;
struct TOrderById {
inline bool operator()(const TVarEntryInfo& l, const TVarEntryInfo& r) { return l.id < r.id; }
};
struct TOrderByPriority {
// ordering:
// 1) has both binding and set
// 2) has binding but no set
// 3) has no binding but set
// 4) has no binding and no set
inline bool operator()(const TVarEntryInfo& l, const TVarEntryInfo& r) {
const TQualifier& lq = l.symbol->getQualifier();
const TQualifier& rq = r.symbol->getQualifier();
// simple rules:
// has binding gives 2 points
// has set gives 1 point
// who has the most points is more important.
int lPoints = (lq.hasBinding() ? 2 : 0) + (lq.hasSet() ? 1 : 0);
int rPoints = (rq.hasBinding() ? 2 : 0) + (rq.hasSet() ? 1 : 0);
if (lPoints == rPoints)
return l.id < r.id;
return lPoints > rPoints;
}
};
};
// Base class for shared TIoMapResolver services, used by several derivations.
struct TDefaultIoResolverBase : public glslang::TIoMapResolver {
public:
TDefaultIoResolverBase(const TIntermediate& intermediate);
typedef std::vector<int> TSlotSet;
typedef std::unordered_map<int, TSlotSet> TSlotSetMap;
// grow the reflection stage by stage
void notifyBinding(EShLanguage, TVarEntryInfo& /*ent*/) override {}
void notifyInOut(EShLanguage, TVarEntryInfo& /*ent*/) override {}
void beginNotifications(EShLanguage) override {}
void endNotifications(EShLanguage) override {}
void beginResolve(EShLanguage) override {}
void endResolve(EShLanguage) override {}
void beginCollect(EShLanguage) override {}
void endCollect(EShLanguage) override {}
void reserverResourceSlot(TVarEntryInfo& /*ent*/, TInfoSink& /*infoSink*/) override {}
void reserverStorageSlot(TVarEntryInfo& /*ent*/, TInfoSink& /*infoSink*/) override {}
int getBaseBinding(TResourceType res, unsigned int set) const;
const std::vector<std::string>& getResourceSetBinding() const;
virtual TResourceType getResourceType(const glslang::TType& type) = 0;
bool doAutoBindingMapping() const;
bool doAutoLocationMapping() const;
TSlotSet::iterator findSlot(int set, int slot);
bool checkEmpty(int set, int slot);
bool validateInOut(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; }
int reserveSlot(int set, int slot, int size = 1);
int getFreeSlot(int set, int base, int size = 1);
int resolveSet(EShLanguage /*stage*/, TVarEntryInfo& ent) override;
int resolveUniformLocation(EShLanguage /*stage*/, TVarEntryInfo& ent) override;
int resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) override;
int resolveInOutComponent(EShLanguage /*stage*/, TVarEntryInfo& ent) override;
int resolveInOutIndex(EShLanguage /*stage*/, TVarEntryInfo& ent) override;
void addStage(EShLanguage stage) override {
if (stage < EShLangCount)
stageMask[stage] = true;
}
uint32_t computeTypeLocationSize(const TType& type, EShLanguage stage);
TSlotSetMap slots;
bool hasError = false;
protected:
TDefaultIoResolverBase(TDefaultIoResolverBase&);
TDefaultIoResolverBase& operator=(TDefaultIoResolverBase&);
const TIntermediate& intermediate;
int nextUniformLocation;
int nextInputLocation;
int nextOutputLocation;
bool stageMask[EShLangCount + 1];
// Return descriptor set specific base if there is one, and the generic base otherwise.
int selectBaseBinding(int base, int descriptorSetBase) const {
return descriptorSetBase != -1 ? descriptorSetBase : base;
}
static int getLayoutSet(const glslang::TType& type) {
if (type.getQualifier().hasSet())
return type.getQualifier().layoutSet;
else
return 0;
}
static bool isSamplerType(const glslang::TType& type) {
return type.getBasicType() == glslang::EbtSampler && type.getSampler().isPureSampler();
}
static bool isTextureType(const glslang::TType& type) {
return (type.getBasicType() == glslang::EbtSampler &&
(type.getSampler().isTexture() || type.getSampler().isSubpass()));
}
static bool isUboType(const glslang::TType& type) {
return type.getQualifier().storage == EvqUniform;
}
static bool isImageType(const glslang::TType& type) {
return type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage();
}
static bool isSsboType(const glslang::TType& type) {
return type.getQualifier().storage == EvqBuffer;
}
// Return true if this is a SRV (shader resource view) type:
static bool isSrvType(const glslang::TType& type) {
return isTextureType(type) || type.getQualifier().storage == EvqBuffer;
}
// Return true if this is a UAV (unordered access view) type:
static bool isUavType(const glslang::TType& type) {
if (type.getQualifier().isReadOnly())
return false;
return (type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage()) ||
(type.getQualifier().storage == EvqBuffer);
}
};
// Default I/O resolver for OpenGL
struct TDefaultGlslIoResolver : public TDefaultIoResolverBase {
public:
typedef std::map<TString, int> TVarSlotMap; // <resourceName, location/binding>
typedef std::map<int, TVarSlotMap> TSlotMap; // <resourceKey, TVarSlotMap>
TDefaultGlslIoResolver(const TIntermediate& intermediate);
bool validateBinding(EShLanguage /*stage*/, TVarEntryInfo& /*ent*/) override { return true; }
TResourceType getResourceType(const glslang::TType& type) override;
int resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) override;
int resolveUniformLocation(EShLanguage /*stage*/, TVarEntryInfo& ent) override;
int resolveBinding(EShLanguage /*stage*/, TVarEntryInfo& ent) override;
void beginResolve(EShLanguage /*stage*/) override;
void endResolve(EShLanguage stage) override;
void beginCollect(EShLanguage) override;
void endCollect(EShLanguage) override;
void reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& infoSink) override;
void reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& infoSink) override;
// in/out symbol and uniform symbol are stored in the same resourceSlotMap, the storage key is used to identify each type of symbol.
// We use stage and storage qualifier to construct a storage key. it can help us identify the same storage resource used in different stage.
// if a resource is a program resource and we don't need know it usage stage, we can use same stage to build storage key.
// Note: both stage and type must less then 0xffff.
int buildStorageKey(EShLanguage stage, TStorageQualifier type) {
assert(static_cast<uint32_t>(stage) <= 0x0000ffff && static_cast<uint32_t>(type) <= 0x0000ffff);
return (stage << 16) | type;
}
protected:
// Use for mark pre stage, to get more interface symbol information.
EShLanguage preStage;
// Use for mark current shader stage for resolver
EShLanguage currentStage;
// Slot map for storage resource(location of uniform and interface symbol) It's a program share slot
TSlotMap resourceSlotMap;
// Slot map for other resource(image, ubo, ssbo), It's a program share slot.
TSlotMap storageSlotMap;
};
typedef std::map<TString, TVarEntryInfo> TVarLiveMap;
// override function "operator=", if a vector<const _Kty, _Ty> being sort,
// when use vc++, the sort function will call :
// pair& operator=(const pair<_Other1, _Other2>& _Right)
// {
// first = _Right.first;
// second = _Right.second;
// return (*this);
// }
// that will make a const type handing on left.
// override this function can avoid a compiler error.
// In the future, if the vc++ compiler can handle such a situation,
// this part of the code will be removed.
struct TVarLivePair : std::pair<const TString, TVarEntryInfo> {
TVarLivePair(const std::pair<const TString, TVarEntryInfo>& _Right) : pair(_Right.first, _Right.second) {}
TVarLivePair& operator=(const TVarLivePair& _Right) {
const_cast<TString&>(first) = _Right.first;
second = _Right.second;
return (*this);
}
TVarLivePair(const TVarLivePair& src) : pair(src) { }
};
typedef std::vector<TVarLivePair> TVarLiveVector;
// I/O mapper
class TIoMapper {
public:
TIoMapper() {}
virtual ~TIoMapper() {}
// grow the reflection stage by stage
bool virtual addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*);
bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; }
};
// I/O mapper for OpenGL
class TGlslIoMapper : public TIoMapper {
public:
TGlslIoMapper() {
memset(inVarMaps, 0, sizeof(TVarLiveMap*) * (EShLangCount + 1));
memset(outVarMaps, 0, sizeof(TVarLiveMap*) * (EShLangCount + 1));
memset(uniformVarMap, 0, sizeof(TVarLiveMap*) * (EShLangCount + 1));
memset(intermediates, 0, sizeof(TIntermediate*) * (EShLangCount + 1));
profile = ENoProfile;
version = 0;
}
virtual ~TGlslIoMapper() {
for (size_t stage = 0; stage < EShLangCount; stage++) {
if (inVarMaps[stage] != nullptr) {
delete inVarMaps[stage];
inVarMaps[stage] = nullptr;
}
if (outVarMaps[stage] != nullptr) {
delete outVarMaps[stage];
outVarMaps[stage] = nullptr;
}
if (uniformVarMap[stage] != nullptr) {
delete uniformVarMap[stage];
uniformVarMap[stage] = nullptr;
}
if (intermediates[stage] != nullptr)
intermediates[stage] = nullptr;
}
}
// grow the reflection stage by stage
bool addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*) override;
bool doMap(TIoMapResolver*, TInfoSink&) override;
TVarLiveMap *inVarMaps[EShLangCount], *outVarMaps[EShLangCount],
*uniformVarMap[EShLangCount];
TIntermediate* intermediates[EShLangCount];
bool hadError = false;
EProfile profile;
int version;
};
} // end namespace glslang
#endif // _IOMAPPER_INCLUDED
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

@ -0,0 +1,245 @@
//
// Copyright (C) 2015-2018 Google, Inc.
// Copyright (C) 2017 ARM Limited.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is implemented in Versions.cpp
#ifndef _PARSE_VERSIONS_INCLUDED_
#define _PARSE_VERSIONS_INCLUDED_
#include "../Public/ShaderLang.h"
#include "../Include/InfoSink.h"
#include "Scan.h"
#include <map>
namespace glslang {
//
// Base class for parse helpers.
// This just has version-related information and checking.
// This class should be sufficient for preprocessing.
//
class TParseVersions {
public:
TParseVersions(TIntermediate& interm, int version, EProfile profile,
const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink,
bool forwardCompatible, EShMessages messages)
:
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
forwardCompatible(forwardCompatible),
profile(profile),
#endif
infoSink(infoSink), version(version),
language(language),
spvVersion(spvVersion),
intermediate(interm), messages(messages), numErrors(0), currentScanner(0) { }
virtual ~TParseVersions() { }
void requireStage(const TSourceLoc&, EShLanguageMask, const char* featureDesc);
void requireStage(const TSourceLoc&, EShLanguage, const char* featureDesc);
#ifdef GLSLANG_WEB
const EProfile profile = EEsProfile;
bool isEsProfile() const { return true; }
void requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc)
{
if (! (EEsProfile & profileMask))
error(loc, "not supported with this profile:", featureDesc, ProfileName(profile));
}
void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions,
const char* const extensions[], const char* featureDesc)
{
if ((EEsProfile & profileMask) && (minVersion == 0 || version < minVersion))
error(loc, "not supported for this version or the enabled extensions", featureDesc, "");
}
void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, const char* extension,
const char* featureDesc)
{
profileRequires(loc, profileMask, minVersion, extension ? 1 : 0, &extension, featureDesc);
}
void initializeExtensionBehavior() { }
void checkDeprecated(const TSourceLoc&, int queryProfiles, int depVersion, const char* featureDesc) { }
void requireNotRemoved(const TSourceLoc&, int queryProfiles, int removedVersion, const char* featureDesc) { }
void requireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc) { }
void ppRequireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc) { }
TExtensionBehavior getExtensionBehavior(const char*) { return EBhMissing; }
bool extensionTurnedOn(const char* const extension) { return false; }
bool extensionsTurnedOn(int numExtensions, const char* const extensions[]) { return false; }
void updateExtensionBehavior(int line, const char* const extension, const char* behavior) { }
void updateExtensionBehavior(const char* const extension, TExtensionBehavior) { }
void checkExtensionStage(const TSourceLoc&, const char* const extension) { }
void extensionRequires(const TSourceLoc&, const char* const extension, const char* behavior) { }
void fullIntegerCheck(const TSourceLoc&, const char* op) { }
void doubleCheck(const TSourceLoc&, const char* op) { }
bool float16Arithmetic() { return false; }
void requireFloat16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { }
bool int16Arithmetic() { return false; }
void requireInt16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { }
bool int8Arithmetic() { return false; }
void requireInt8Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) { }
void int64Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
void explicitFloat32Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
void explicitFloat64Check(const TSourceLoc&, const char* op, bool builtIn = false) { }
bool relaxedErrors() const { return false; }
bool suppressWarnings() const { return true; }
bool isForwardCompatible() const { return false; }
#else
#ifdef GLSLANG_ANGLE
const bool forwardCompatible = true;
const EProfile profile = ECoreProfile;
#else
bool forwardCompatible; // true if errors are to be given for use of deprecated features
EProfile profile; // the declared profile in the shader (core by default)
#endif
bool isEsProfile() const { return profile == EEsProfile; }
void requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc);
void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions,
const char* const extensions[], const char* featureDesc);
void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, const char* extension,
const char* featureDesc);
virtual void initializeExtensionBehavior();
virtual void checkDeprecated(const TSourceLoc&, int queryProfiles, int depVersion, const char* featureDesc);
virtual void requireNotRemoved(const TSourceLoc&, int queryProfiles, int removedVersion, const char* featureDesc);
virtual void requireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc);
virtual void ppRequireExtensions(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc);
virtual TExtensionBehavior getExtensionBehavior(const char*);
virtual bool extensionTurnedOn(const char* const extension);
virtual bool extensionsTurnedOn(int numExtensions, const char* const extensions[]);
virtual void updateExtensionBehavior(int line, const char* const extension, const char* behavior);
virtual void updateExtensionBehavior(const char* const extension, TExtensionBehavior);
virtual bool checkExtensionsRequested(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc);
virtual void checkExtensionStage(const TSourceLoc&, const char* const extension);
virtual void extensionRequires(const TSourceLoc&, const char* const extension, const char* behavior);
virtual void fullIntegerCheck(const TSourceLoc&, const char* op);
virtual void unimplemented(const TSourceLoc&, const char* featureDesc);
virtual void doubleCheck(const TSourceLoc&, const char* op);
virtual void float16Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void float16ScalarVectorCheck(const TSourceLoc&, const char* op, bool builtIn = false);
virtual bool float16Arithmetic();
virtual void requireFloat16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc);
virtual void int16ScalarVectorCheck(const TSourceLoc&, const char* op, bool builtIn = false);
virtual bool int16Arithmetic();
virtual void requireInt16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc);
virtual void int8ScalarVectorCheck(const TSourceLoc&, const char* op, bool builtIn = false);
virtual bool int8Arithmetic();
virtual void requireInt8Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc);
virtual void float16OpaqueCheck(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void int64Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitInt8Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitInt16Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitInt32Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitFloat32Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitFloat64Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void fcoopmatCheck(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void intcoopmatCheck(const TSourceLoc&, const char *op, bool builtIn = false);
bool relaxedErrors() const { return (messages & EShMsgRelaxedErrors) != 0; }
bool suppressWarnings() const { return (messages & EShMsgSuppressWarnings) != 0; }
bool isForwardCompatible() const { return forwardCompatible; }
#endif // GLSLANG_WEB
virtual void spvRemoved(const TSourceLoc&, const char* op);
virtual void vulkanRemoved(const TSourceLoc&, const char* op);
virtual void requireVulkan(const TSourceLoc&, const char* op);
virtual void requireSpv(const TSourceLoc&, const char* op);
virtual void requireSpv(const TSourceLoc&, const char *op, unsigned int version);
#if defined(GLSLANG_WEB) && !defined(GLSLANG_WEB_DEVEL)
void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) { addError(); }
void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) { }
void C_DECL ppError(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) { addError(); }
void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) { }
#else
virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) = 0;
virtual void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) = 0;
virtual void C_DECL ppError(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) = 0;
virtual void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) = 0;
#endif
void addError() { ++numErrors; }
int getNumErrors() const { return numErrors; }
void setScanner(TInputScanner* scanner) { currentScanner = scanner; }
TInputScanner* getScanner() const { return currentScanner; }
const TSourceLoc& getCurrentLoc() const { return currentScanner->getSourceLoc(); }
void setCurrentLine(int line) { currentScanner->setLine(line); }
void setCurrentColumn(int col) { currentScanner->setColumn(col); }
void setCurrentSourceName(const char* name) { currentScanner->setFile(name); }
void setCurrentString(int string) { currentScanner->setString(string); }
void getPreamble(std::string&);
#ifdef ENABLE_HLSL
bool isReadingHLSL() const { return (messages & EShMsgReadHlsl) == EShMsgReadHlsl; }
bool hlslEnable16BitTypes() const { return (messages & EShMsgHlslEnable16BitTypes) != 0; }
bool hlslDX9Compatible() const { return (messages & EShMsgHlslDX9Compatible) != 0; }
#else
bool isReadingHLSL() const { return false; }
#endif
TInfoSink& infoSink;
// compilation mode
int version; // version, updated by #version in the shader
EShLanguage language; // really the stage
SpvVersion spvVersion;
TIntermediate& intermediate; // helper for making and hooking up pieces of the parse tree
protected:
TMap<TString, TExtensionBehavior> extensionBehavior; // for each extension string, what its current behavior is
TMap<TString, unsigned int> extensionMinSpv; // for each extension string, store minimum spirv required
EShMessages messages; // errors/warnings/rule-sets
int numErrors; // number of compile-time errors encountered
TInputScanner* currentScanner;
private:
explicit TParseVersions(const TParseVersions&);
TParseVersions& operator=(const TParseVersions&);
};
} // end namespace glslang
#endif // _PARSE_VERSIONS_INCLUDED_

@ -0,0 +1,703 @@
//
// Copyright (C) 2013 LunarG, Inc.
// Copyright (C) 2015-2018 Google, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
NVIDIA Corporation("NVIDIA") supplies this software to you in
consideration of your agreement to the following terms, and your use,
installation, modification or redistribution of this NVIDIA software
constitutes acceptance of these terms. If you do not agree with these
terms, please do not use, install, modify or redistribute this NVIDIA
software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, NVIDIA grants you a personal, non-exclusive
license, under NVIDIA's copyrights in this original NVIDIA software (the
"NVIDIA Software"), to use, reproduce, modify and redistribute the
NVIDIA Software, with or without modifications, in source and/or binary
forms; provided that if you redistribute the NVIDIA Software, you must
retain the copyright notice of NVIDIA, this notice and the following
text and disclaimers in all such redistributions of the NVIDIA Software.
Neither the name, trademarks, service marks nor logos of NVIDIA
Corporation may be used to endorse or promote products derived from the
NVIDIA Software without specific prior written permission from NVIDIA.
Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
PRODUCTS.
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
#ifndef PPCONTEXT_H
#define PPCONTEXT_H
#include <stack>
#include <unordered_map>
#include <sstream>
#include "../ParseHelper.h"
#include "PpTokens.h"
/* windows only pragma */
#ifdef _MSC_VER
#pragma warning(disable : 4127)
#endif
namespace glslang {
class TPpToken {
public:
TPpToken() { clear(); }
void clear()
{
space = false;
i64val = 0;
loc.init();
name[0] = 0;
}
// Used for comparing macro definitions, so checks what is relevant for that.
bool operator==(const TPpToken& right) const
{
return space == right.space &&
ival == right.ival && dval == right.dval && i64val == right.i64val &&
strncmp(name, right.name, MaxTokenLength) == 0;
}
bool operator!=(const TPpToken& right) const { return ! operator==(right); }
TSourceLoc loc;
// True if a space (for white space or a removed comment) should also be
// recognized, in front of the token returned:
bool space;
// Numeric value of the token:
union {
int ival;
double dval;
long long i64val;
};
// Text string of the token:
char name[MaxTokenLength + 1];
};
class TStringAtomMap {
//
// Implementation is in PpAtom.cpp
//
// Maintain a bi-directional mapping between relevant preprocessor strings and
// "atoms" which a unique integers (small, contiguous, not hash-like) per string.
//
public:
TStringAtomMap();
// Map string -> atom.
// Return 0 if no existing string.
int getAtom(const char* s) const
{
auto it = atomMap.find(s);
return it == atomMap.end() ? 0 : it->second;
}
// Map a new or existing string -> atom, inventing a new atom if necessary.
int getAddAtom(const char* s)
{
int atom = getAtom(s);
if (atom == 0) {
atom = nextAtom++;
addAtomFixed(s, atom);
}
return atom;
}
// Map atom -> string.
const char* getString(int atom) const { return stringMap[atom]->c_str(); }
protected:
TStringAtomMap(TStringAtomMap&);
TStringAtomMap& operator=(TStringAtomMap&);
TUnorderedMap<TString, int> atomMap;
TVector<const TString*> stringMap; // these point into the TString in atomMap
int nextAtom;
// Bad source characters can lead to bad atoms, so gracefully handle those by
// pre-filling the table with them (to avoid if tests later).
TString badToken;
// Add bi-directional mappings:
// - string -> atom
// - atom -> string
void addAtomFixed(const char* s, int atom)
{
auto it = atomMap.insert(std::pair<TString, int>(s, atom)).first;
if (stringMap.size() < (size_t)atom + 1)
stringMap.resize(atom + 100, &badToken);
stringMap[atom] = &it->first;
}
};
class TInputScanner;
enum MacroExpandResult {
MacroExpandNotStarted, // macro not expanded, which might not be an error
MacroExpandError, // a clear error occurred while expanding, no expansion
MacroExpandStarted, // macro expansion process has started
MacroExpandUndef // macro is undefined and will be expanded
};
// This class is the result of turning a huge pile of C code communicating through globals
// into a class. This was done to allowing instancing to attain thread safety.
// Don't expect too much in terms of OO design.
class TPpContext {
public:
TPpContext(TParseContextBase&, const std::string& rootFileName, TShader::Includer&);
virtual ~TPpContext();
void setPreamble(const char* preamble, size_t length);
int tokenize(TPpToken& ppToken);
int tokenPaste(int token, TPpToken&);
class tInput {
public:
tInput(TPpContext* p) : done(false), pp(p) { }
virtual ~tInput() { }
virtual int scan(TPpToken*) = 0;
virtual int getch() = 0;
virtual void ungetch() = 0;
virtual bool peekPasting() { return false; } // true when about to see ##
virtual bool peekContinuedPasting(int) { return false; } // true when non-spaced tokens can paste
virtual bool endOfReplacementList() { return false; } // true when at the end of a macro replacement list (RHS of #define)
virtual bool isMacroInput() { return false; }
// Will be called when we start reading tokens from this instance
virtual void notifyActivated() {}
// Will be called when we do not read tokens from this instance anymore
virtual void notifyDeleted() {}
protected:
bool done;
TPpContext* pp;
};
void setInput(TInputScanner& input, bool versionWillBeError);
void pushInput(tInput* in)
{
inputStack.push_back(in);
in->notifyActivated();
}
void popInput()
{
inputStack.back()->notifyDeleted();
delete inputStack.back();
inputStack.pop_back();
}
//
// From PpTokens.cpp
//
// Capture the needed parts of a token stream for macro recording/playback.
class TokenStream {
public:
// Manage a stream of these 'Token', which capture the relevant parts
// of a TPpToken, plus its atom.
class Token {
public:
Token(int atom, const TPpToken& ppToken) :
atom(atom),
space(ppToken.space),
i64val(ppToken.i64val),
name(ppToken.name) { }
int get(TPpToken& ppToken)
{
ppToken.clear();
ppToken.space = space;
ppToken.i64val = i64val;
snprintf(ppToken.name, sizeof(ppToken.name), "%s", name.c_str());
return atom;
}
bool isAtom(int a) const { return atom == a; }
int getAtom() const { return atom; }
bool nonSpaced() const { return !space; }
protected:
Token() {}
int atom;
bool space; // did a space precede the token?
long long i64val;
TString name;
};
TokenStream() : currentPos(0) { }
void putToken(int token, TPpToken* ppToken);
bool peekToken(int atom) { return !atEnd() && stream[currentPos].isAtom(atom); }
bool peekContinuedPasting(int atom)
{
// This is basically necessary because, for example, the PP
// tokenizer only accepts valid numeric-literals plus suffixes, so
// separates numeric-literals plus bad suffix into two tokens, which
// should get both pasted together as one token when token pasting.
//
// The following code is a bit more generalized than the above example.
if (!atEnd() && atom == PpAtomIdentifier && stream[currentPos].nonSpaced()) {
switch(stream[currentPos].getAtom()) {
case PpAtomConstInt:
case PpAtomConstUint:
case PpAtomConstInt64:
case PpAtomConstUint64:
case PpAtomConstInt16:
case PpAtomConstUint16:
case PpAtomConstFloat:
case PpAtomConstDouble:
case PpAtomConstFloat16:
case PpAtomConstString:
case PpAtomIdentifier:
return true;
default:
break;
}
}
return false;
}
int getToken(TParseContextBase&, TPpToken*);
bool atEnd() { return currentPos >= stream.size(); }
bool peekTokenizedPasting(bool lastTokenPastes);
bool peekUntokenizedPasting();
void reset() { currentPos = 0; }
protected:
TVector<Token> stream;
size_t currentPos;
};
//
// From Pp.cpp
//
struct MacroSymbol {
MacroSymbol() : functionLike(0), busy(0), undef(0) { }
TVector<int> args;
TokenStream body;
unsigned functionLike : 1; // 0 means object-like, 1 means function-like
unsigned busy : 1;
unsigned undef : 1;
};
typedef TMap<int, MacroSymbol> TSymbolMap;
TSymbolMap macroDefs; // map atoms to macro definitions
MacroSymbol* lookupMacroDef(int atom)
{
auto existingMacroIt = macroDefs.find(atom);
return (existingMacroIt == macroDefs.end()) ? nullptr : &(existingMacroIt->second);
}
void addMacroDef(int atom, MacroSymbol& macroDef) { macroDefs[atom] = macroDef; }
protected:
TPpContext(TPpContext&);
TPpContext& operator=(TPpContext&);
TStringAtomMap atomStrings;
char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble
int preambleLength;
char** strings; // official strings of shader, starting a string 0 line 1
size_t* lengths;
int numStrings; // how many official strings there are
int currentString; // which string we're currently parsing (-1 for preamble)
// Scanner data:
int previous_token;
TParseContextBase& parseContext;
// Get the next token from *stack* of input sources, popping input sources
// that are out of tokens, down until an input source is found that has a token.
// Return EndOfInput when there are no more tokens to be found by doing this.
int scanToken(TPpToken* ppToken)
{
int token = EndOfInput;
while (! inputStack.empty()) {
token = inputStack.back()->scan(ppToken);
if (token != EndOfInput || inputStack.empty())
break;
popInput();
}
return token;
}
int getChar() { return inputStack.back()->getch(); }
void ungetChar() { inputStack.back()->ungetch(); }
bool peekPasting() { return !inputStack.empty() && inputStack.back()->peekPasting(); }
bool peekContinuedPasting(int a)
{
return !inputStack.empty() && inputStack.back()->peekContinuedPasting(a);
}
bool endOfReplacementList() { return inputStack.empty() || inputStack.back()->endOfReplacementList(); }
bool isMacroInput() { return inputStack.size() > 0 && inputStack.back()->isMacroInput(); }
static const int maxIfNesting = 65;
int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor)
bool elseSeen[maxIfNesting]; // Keep a track of whether an else has been seen at a particular depth
int elsetracker; // #if-#else and #endif constructs...Counter.
class tMacroInput : public tInput {
public:
tMacroInput(TPpContext* pp) : tInput(pp), prepaste(false), postpaste(false) { }
virtual ~tMacroInput()
{
for (size_t i = 0; i < args.size(); ++i)
delete args[i];
for (size_t i = 0; i < expandedArgs.size(); ++i)
delete expandedArgs[i];
}
virtual int scan(TPpToken*) override;
virtual int getch() override { assert(0); return EndOfInput; }
virtual void ungetch() override { assert(0); }
bool peekPasting() override { return prepaste; }
bool peekContinuedPasting(int a) override { return mac->body.peekContinuedPasting(a); }
bool endOfReplacementList() override { return mac->body.atEnd(); }
bool isMacroInput() override { return true; }
MacroSymbol *mac;
TVector<TokenStream*> args;
TVector<TokenStream*> expandedArgs;
protected:
bool prepaste; // true if we are just before ##
bool postpaste; // true if we are right after ##
};
class tMarkerInput : public tInput {
public:
tMarkerInput(TPpContext* pp) : tInput(pp) { }
virtual int scan(TPpToken*) override
{
if (done)
return EndOfInput;
done = true;
return marker;
}
virtual int getch() override { assert(0); return EndOfInput; }
virtual void ungetch() override { assert(0); }
static const int marker = -3;
};
class tZeroInput : public tInput {
public:
tZeroInput(TPpContext* pp) : tInput(pp) { }
virtual int scan(TPpToken*) override;
virtual int getch() override { assert(0); return EndOfInput; }
virtual void ungetch() override { assert(0); }
};
std::vector<tInput*> inputStack;
bool errorOnVersion;
bool versionSeen;
//
// from Pp.cpp
//
// Used to obtain #include content.
TShader::Includer& includer;
int CPPdefine(TPpToken * ppToken);
int CPPundef(TPpToken * ppToken);
int CPPelse(int matchelse, TPpToken * ppToken);
int extraTokenCheck(int atom, TPpToken* ppToken, int token);
int eval(int token, int precedence, bool shortCircuit, int& res, bool& err, TPpToken * ppToken);
int evalToToken(int token, bool shortCircuit, int& res, bool& err, TPpToken * ppToken);
int CPPif (TPpToken * ppToken);
int CPPifdef(int defined, TPpToken * ppToken);
int CPPinclude(TPpToken * ppToken);
int CPPline(TPpToken * ppToken);
int CPPerror(TPpToken * ppToken);
int CPPpragma(TPpToken * ppToken);
int CPPversion(TPpToken * ppToken);
int CPPextension(TPpToken * ppToken);
int readCPPline(TPpToken * ppToken);
int scanHeaderName(TPpToken* ppToken, char delimit);
TokenStream* PrescanMacroArg(TokenStream&, TPpToken*, bool newLineOkay);
MacroExpandResult MacroExpand(TPpToken* ppToken, bool expandUndef, bool newLineOkay);
//
// From PpTokens.cpp
//
void pushTokenStreamInput(TokenStream&, bool pasting = false);
void UngetToken(int token, TPpToken*);
class tTokenInput : public tInput {
public:
tTokenInput(TPpContext* pp, TokenStream* t, bool prepasting) :
tInput(pp),
tokens(t),
lastTokenPastes(prepasting) { }
virtual int scan(TPpToken *ppToken) override { return tokens->getToken(pp->parseContext, ppToken); }
virtual int getch() override { assert(0); return EndOfInput; }
virtual void ungetch() override { assert(0); }
virtual bool peekPasting() override { return tokens->peekTokenizedPasting(lastTokenPastes); }
bool peekContinuedPasting(int a) override { return tokens->peekContinuedPasting(a); }
protected:
TokenStream* tokens;
bool lastTokenPastes; // true if the last token in the input is to be pasted, rather than consumed as a token
};
class tUngotTokenInput : public tInput {
public:
tUngotTokenInput(TPpContext* pp, int t, TPpToken* p) : tInput(pp), token(t), lval(*p) { }
virtual int scan(TPpToken *) override;
virtual int getch() override { assert(0); return EndOfInput; }
virtual void ungetch() override { assert(0); }
protected:
int token;
TPpToken lval;
};
//
// From PpScanner.cpp
//
class tStringInput : public tInput {
public:
tStringInput(TPpContext* pp, TInputScanner& i) : tInput(pp), input(&i) { }
virtual int scan(TPpToken*) override;
// Scanner used to get source stream characters.
// - Escaped newlines are handled here, invisibly to the caller.
// - All forms of newline are handled, and turned into just a '\n'.
int getch() override
{
int ch = input->get();
if (ch == '\\') {
// Move past escaped newlines, as many as sequentially exist
do {
if (input->peek() == '\r' || input->peek() == '\n') {
bool allowed = pp->parseContext.lineContinuationCheck(input->getSourceLoc(), pp->inComment);
if (! allowed && pp->inComment)
return '\\';
// escape one newline now
ch = input->get();
int nextch = input->get();
if (ch == '\r' && nextch == '\n')
ch = input->get();
else
ch = nextch;
} else
return '\\';
} while (ch == '\\');
}
// handle any non-escaped newline
if (ch == '\r' || ch == '\n') {
if (ch == '\r' && input->peek() == '\n')
input->get();
return '\n';
}
return ch;
}
// Scanner used to backup the source stream characters. Newlines are
// handled here, invisibly to the caller, meaning have to undo exactly
// what getch() above does (e.g., don't leave things in the middle of a
// sequence of escaped newlines).
void ungetch() override
{
input->unget();
do {
int ch = input->peek();
if (ch == '\r' || ch == '\n') {
if (ch == '\n') {
// correct for two-character newline
input->unget();
if (input->peek() != '\r')
input->get();
}
// now in front of a complete newline, move past an escape character
input->unget();
if (input->peek() == '\\')
input->unget();
else {
input->get();
break;
}
} else
break;
} while (true);
}
protected:
TInputScanner* input;
};
// Holds a reference to included file data, as well as a
// prologue and an epilogue string. This can be scanned using the tInput
// interface and acts as a single source string.
class TokenizableIncludeFile : public tInput {
public:
// Copies prologue and epilogue. The includedFile must remain valid
// until this TokenizableIncludeFile is no longer used.
TokenizableIncludeFile(const TSourceLoc& startLoc,
const std::string& prologue,
TShader::Includer::IncludeResult* includedFile,
const std::string& epilogue,
TPpContext* pp)
: tInput(pp),
prologue_(prologue),
epilogue_(epilogue),
includedFile_(includedFile),
scanner(3, strings, lengths, nullptr, 0, 0, true),
prevScanner(nullptr),
stringInput(pp, scanner)
{
strings[0] = prologue_.data();
strings[1] = includedFile_->headerData;
strings[2] = epilogue_.data();
lengths[0] = prologue_.size();
lengths[1] = includedFile_->headerLength;
lengths[2] = epilogue_.size();
scanner.setLine(startLoc.line);
scanner.setString(startLoc.string);
scanner.setFile(startLoc.getFilenameStr(), 0);
scanner.setFile(startLoc.getFilenameStr(), 1);
scanner.setFile(startLoc.getFilenameStr(), 2);
}
// tInput methods:
int scan(TPpToken* t) override { return stringInput.scan(t); }
int getch() override { return stringInput.getch(); }
void ungetch() override { stringInput.ungetch(); }
void notifyActivated() override
{
prevScanner = pp->parseContext.getScanner();
pp->parseContext.setScanner(&scanner);
pp->push_include(includedFile_);
}
void notifyDeleted() override
{
pp->parseContext.setScanner(prevScanner);
pp->pop_include();
}
private:
TokenizableIncludeFile& operator=(const TokenizableIncludeFile&);
// Stores the prologue for this string.
const std::string prologue_;
// Stores the epilogue for this string.
const std::string epilogue_;
// Points to the IncludeResult that this TokenizableIncludeFile represents.
TShader::Includer::IncludeResult* includedFile_;
// Will point to prologue_, includedFile_->headerData and epilogue_
// This is passed to scanner constructor.
// These do not own the storage and it must remain valid until this
// object has been destroyed.
const char* strings[3];
// Length of str_, passed to scanner constructor.
size_t lengths[3];
// Scans over str_.
TInputScanner scanner;
// The previous effective scanner before the scanner in this instance
// has been activated.
TInputScanner* prevScanner;
// Delegate object implementing the tInput interface.
tStringInput stringInput;
};
int ScanFromString(char* s);
void missingEndifCheck();
int lFloatConst(int len, int ch, TPpToken* ppToken);
int characterLiteral(TPpToken* ppToken);
void push_include(TShader::Includer::IncludeResult* result)
{
currentSourceFile = result->headerName;
includeStack.push(result);
}
void pop_include()
{
TShader::Includer::IncludeResult* include = includeStack.top();
includeStack.pop();
includer.releaseInclude(include);
if (includeStack.empty()) {
currentSourceFile = rootFileName;
} else {
currentSourceFile = includeStack.top()->headerName;
}
}
bool inComment;
std::string rootFileName;
std::stack<TShader::Includer::IncludeResult*> includeStack;
std::string currentSourceFile;
std::istringstream strtodStream;
bool disableEscapeSequences;
};
} // end namespace glslang
#endif // PPCONTEXT_H

@ -0,0 +1,179 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
NVIDIA Corporation("NVIDIA") supplies this software to you in
consideration of your agreement to the following terms, and your use,
installation, modification or redistribution of this NVIDIA software
constitutes acceptance of these terms. If you do not agree with these
terms, please do not use, install, modify or redistribute this NVIDIA
software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, NVIDIA grants you a personal, non-exclusive
license, under NVIDIA's copyrights in this original NVIDIA software (the
"NVIDIA Software"), to use, reproduce, modify and redistribute the
NVIDIA Software, with or without modifications, in source and/or binary
forms; provided that if you redistribute the NVIDIA Software, you must
retain the copyright notice of NVIDIA, this notice and the following
text and disclaimers in all such redistributions of the NVIDIA Software.
Neither the name, trademarks, service marks nor logos of NVIDIA
Corporation may be used to endorse or promote products derived from the
NVIDIA Software without specific prior written permission from NVIDIA.
Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
PRODUCTS.
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
#ifndef PARSER_H
#define PARSER_H
namespace glslang {
// Multi-character tokens
enum EFixedAtoms {
// single character tokens get their own char value as their token; start here for multi-character tokens
PpAtomMaxSingle = 127,
// replace bad character tokens with this, to avoid accidental aliasing with the below
PpAtomBadToken,
// Operators
PPAtomAddAssign,
PPAtomSubAssign,
PPAtomMulAssign,
PPAtomDivAssign,
PPAtomModAssign,
PpAtomRight,
PpAtomLeft,
PpAtomRightAssign,
PpAtomLeftAssign,
PpAtomAndAssign,
PpAtomOrAssign,
PpAtomXorAssign,
PpAtomAnd,
PpAtomOr,
PpAtomXor,
PpAtomEQ,
PpAtomNE,
PpAtomGE,
PpAtomLE,
PpAtomDecrement,
PpAtomIncrement,
PpAtomColonColon,
PpAtomPaste,
// Constants
PpAtomConstInt,
PpAtomConstUint,
PpAtomConstInt64,
PpAtomConstUint64,
PpAtomConstInt16,
PpAtomConstUint16,
PpAtomConstFloat,
PpAtomConstDouble,
PpAtomConstFloat16,
PpAtomConstString,
// Identifiers
PpAtomIdentifier,
// preprocessor "keywords"
PpAtomDefine,
PpAtomUndef,
PpAtomIf,
PpAtomIfdef,
PpAtomIfndef,
PpAtomElse,
PpAtomElif,
PpAtomEndif,
PpAtomLine,
PpAtomPragma,
PpAtomError,
// #version ...
PpAtomVersion,
PpAtomCore,
PpAtomCompatibility,
PpAtomEs,
// #extension
PpAtomExtension,
// __LINE__, __FILE__, __VERSION__
PpAtomLineMacro,
PpAtomFileMacro,
PpAtomVersionMacro,
// #include
PpAtomInclude,
PpAtomLast,
};
} // end namespace glslang
#endif /* not PARSER_H */

@ -0,0 +1,55 @@
//
// Copyright (C) 2015-2016 Google, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Visit the nodes in the glslang intermediate tree representation to
// propagate 'noContraction' qualifier.
//
#pragma once
#include "../Include/intermediate.h"
namespace glslang {
// Propagates the 'precise' qualifier for objects (objects marked with
// 'noContraction' qualifier) from the shader source specified 'precise'
// variables to all the involved objects, and add 'noContraction' qualifier for
// the involved arithmetic operations.
// Note that the same qualifier: 'noContraction' is used in both object nodes
// and arithmetic operation nodes, but has different meaning. For object nodes,
// 'noContraction' means the object is 'precise'; and for arithmetic operation
// nodes, it means the operation should not be contracted.
void PropagateNoContraction(const glslang::TIntermediate& intermediate);
};

@ -0,0 +1,223 @@
//
// Copyright (C) 2013-2016 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#ifndef _REFLECTION_INCLUDED
#define _REFLECTION_INCLUDED
#include "../Public/ShaderLang.h"
#include "../Include/Types.h"
#include <list>
#include <set>
//
// A reflection database and its interface, consistent with the OpenGL API reflection queries.
//
namespace glslang {
class TIntermediate;
class TIntermAggregate;
class TReflectionTraverser;
// The full reflection database
class TReflection {
public:
TReflection(EShReflectionOptions opts, EShLanguage first, EShLanguage last)
: options(opts), firstStage(first), lastStage(last), badReflection(TObjectReflection::badReflection())
{
for (int dim=0; dim<3; ++dim)
localSize[dim] = 0;
}
virtual ~TReflection() {}
// grow the reflection stage by stage
bool addStage(EShLanguage, const TIntermediate&);
// for mapping a uniform index to a uniform object's description
int getNumUniforms() { return (int)indexToUniform.size(); }
const TObjectReflection& getUniform(int i) const
{
if (i >= 0 && i < (int)indexToUniform.size())
return indexToUniform[i];
else
return badReflection;
}
// for mapping a block index to the block's description
int getNumUniformBlocks() const { return (int)indexToUniformBlock.size(); }
const TObjectReflection& getUniformBlock(int i) const
{
if (i >= 0 && i < (int)indexToUniformBlock.size())
return indexToUniformBlock[i];
else
return badReflection;
}
// for mapping an pipeline input index to the input's description
int getNumPipeInputs() { return (int)indexToPipeInput.size(); }
const TObjectReflection& getPipeInput(int i) const
{
if (i >= 0 && i < (int)indexToPipeInput.size())
return indexToPipeInput[i];
else
return badReflection;
}
// for mapping an pipeline output index to the output's description
int getNumPipeOutputs() { return (int)indexToPipeOutput.size(); }
const TObjectReflection& getPipeOutput(int i) const
{
if (i >= 0 && i < (int)indexToPipeOutput.size())
return indexToPipeOutput[i];
else
return badReflection;
}
// for mapping from an atomic counter to the uniform index
int getNumAtomicCounters() const { return (int)atomicCounterUniformIndices.size(); }
const TObjectReflection& getAtomicCounter(int i) const
{
if (i >= 0 && i < (int)atomicCounterUniformIndices.size())
return getUniform(atomicCounterUniformIndices[i]);
else
return badReflection;
}
// for mapping a buffer variable index to a buffer variable object's description
int getNumBufferVariables() { return (int)indexToBufferVariable.size(); }
const TObjectReflection& getBufferVariable(int i) const
{
if (i >= 0 && i < (int)indexToBufferVariable.size())
return indexToBufferVariable[i];
else
return badReflection;
}
// for mapping a storage block index to the storage block's description
int getNumStorageBuffers() const { return (int)indexToBufferBlock.size(); }
const TObjectReflection& getStorageBufferBlock(int i) const
{
if (i >= 0 && i < (int)indexToBufferBlock.size())
return indexToBufferBlock[i];
else
return badReflection;
}
// for mapping any name to its index (block names, uniform names and input/output names)
int getIndex(const char* name) const
{
TNameToIndex::const_iterator it = nameToIndex.find(name);
if (it == nameToIndex.end())
return -1;
else
return it->second;
}
// see getIndex(const char*)
int getIndex(const TString& name) const { return getIndex(name.c_str()); }
// for mapping any name to its index (only pipe input/output names)
int getPipeIOIndex(const char* name, const bool inOrOut) const
{
TNameToIndex::const_iterator it = inOrOut ? pipeInNameToIndex.find(name) : pipeOutNameToIndex.find(name);
if (it == (inOrOut ? pipeInNameToIndex.end() : pipeOutNameToIndex.end()))
return -1;
else
return it->second;
}
// see gePipeIOIndex(const char*, const bool)
int getPipeIOIndex(const TString& name, const bool inOrOut) const { return getPipeIOIndex(name.c_str(), inOrOut); }
// Thread local size
unsigned getLocalSize(int dim) const { return dim <= 2 ? localSize[dim] : 0; }
void dump();
protected:
friend class glslang::TReflectionTraverser;
void buildCounterIndices(const TIntermediate&);
void buildUniformStageMask(const TIntermediate& intermediate);
void buildAttributeReflection(EShLanguage, const TIntermediate&);
// Need a TString hash: typedef std::unordered_map<TString, int> TNameToIndex;
typedef std::map<std::string, int> TNameToIndex;
typedef std::vector<TObjectReflection> TMapIndexToReflection;
typedef std::vector<int> TIndices;
TMapIndexToReflection& GetBlockMapForStorage(TStorageQualifier storage)
{
if ((options & EShReflectionSeparateBuffers) && storage == EvqBuffer)
return indexToBufferBlock;
return indexToUniformBlock;
}
TMapIndexToReflection& GetVariableMapForStorage(TStorageQualifier storage)
{
if ((options & EShReflectionSeparateBuffers) && storage == EvqBuffer)
return indexToBufferVariable;
return indexToUniform;
}
EShReflectionOptions options;
EShLanguage firstStage;
EShLanguage lastStage;
TObjectReflection badReflection; // return for queries of -1 or generally out of range; has expected descriptions with in it for this
TNameToIndex nameToIndex; // maps names to indexes; can hold all types of data: uniform/buffer and which function names have been processed
TNameToIndex pipeInNameToIndex; // maps pipe in names to indexes, this is a fix to seperate pipe I/O from uniforms and buffers.
TNameToIndex pipeOutNameToIndex; // maps pipe out names to indexes, this is a fix to seperate pipe I/O from uniforms and buffers.
TMapIndexToReflection indexToUniform;
TMapIndexToReflection indexToUniformBlock;
TMapIndexToReflection indexToBufferVariable;
TMapIndexToReflection indexToBufferBlock;
TMapIndexToReflection indexToPipeInput;
TMapIndexToReflection indexToPipeOutput;
TIndices atomicCounterUniformIndices;
unsigned int localSize[3];
};
} // end namespace glslang
#endif // _REFLECTION_INCLUDED
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

@ -0,0 +1,948 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2013-2016 LunarG, Inc.
// Copyright (C) 2015-2018 Google, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _COMPILER_INTERFACE_INCLUDED_
#define _COMPILER_INTERFACE_INCLUDED_
#include "../Include/ResourceLimits.h"
#include "../MachineIndependent/Versions.h"
#include <cstring>
#include <vector>
#ifdef _WIN32
#define C_DECL __cdecl
#else
#define C_DECL
#endif
#ifdef GLSLANG_IS_SHARED_LIBRARY
#ifdef _WIN32
#ifdef GLSLANG_EXPORTING
#define GLSLANG_EXPORT __declspec(dllexport)
#else
#define GLSLANG_EXPORT __declspec(dllimport)
#endif
#elif __GNUC__ >= 4
#define GLSLANG_EXPORT __attribute__((visibility("default")))
#endif
#endif // GLSLANG_IS_SHARED_LIBRARY
#ifndef GLSLANG_EXPORT
#define GLSLANG_EXPORT
#endif
//
// This is the platform independent interface between an OGL driver
// and the shading language compiler/linker.
//
#ifdef __cplusplus
extern "C" {
#endif
//
// Call before doing any other compiler/linker operations.
//
// (Call once per process, not once per thread.)
//
GLSLANG_EXPORT int ShInitialize();
//
// Call this at process shutdown to clean up memory.
//
GLSLANG_EXPORT int ShFinalize();
//
// Types of languages the compiler can consume.
//
typedef enum {
EShLangVertex,
EShLangTessControl,
EShLangTessEvaluation,
EShLangGeometry,
EShLangFragment,
EShLangCompute,
EShLangRayGen,
EShLangRayGenNV = EShLangRayGen,
EShLangIntersect,
EShLangIntersectNV = EShLangIntersect,
EShLangAnyHit,
EShLangAnyHitNV = EShLangAnyHit,
EShLangClosestHit,
EShLangClosestHitNV = EShLangClosestHit,
EShLangMiss,
EShLangMissNV = EShLangMiss,
EShLangCallable,
EShLangCallableNV = EShLangCallable,
EShLangTaskNV,
EShLangMeshNV,
LAST_ELEMENT_MARKER(EShLangCount),
} EShLanguage; // would be better as stage, but this is ancient now
typedef enum : unsigned {
EShLangVertexMask = (1 << EShLangVertex),
EShLangTessControlMask = (1 << EShLangTessControl),
EShLangTessEvaluationMask = (1 << EShLangTessEvaluation),
EShLangGeometryMask = (1 << EShLangGeometry),
EShLangFragmentMask = (1 << EShLangFragment),
EShLangComputeMask = (1 << EShLangCompute),
EShLangRayGenMask = (1 << EShLangRayGen),
EShLangRayGenNVMask = EShLangRayGenMask,
EShLangIntersectMask = (1 << EShLangIntersect),
EShLangIntersectNVMask = EShLangIntersectMask,
EShLangAnyHitMask = (1 << EShLangAnyHit),
EShLangAnyHitNVMask = EShLangAnyHitMask,
EShLangClosestHitMask = (1 << EShLangClosestHit),
EShLangClosestHitNVMask = EShLangClosestHitMask,
EShLangMissMask = (1 << EShLangMiss),
EShLangMissNVMask = EShLangMissMask,
EShLangCallableMask = (1 << EShLangCallable),
EShLangCallableNVMask = EShLangCallableMask,
EShLangTaskNVMask = (1 << EShLangTaskNV),
EShLangMeshNVMask = (1 << EShLangMeshNV),
LAST_ELEMENT_MARKER(EShLanguageMaskCount),
} EShLanguageMask;
namespace glslang {
class TType;
typedef enum {
EShSourceNone,
EShSourceGlsl, // GLSL, includes ESSL (OpenGL ES GLSL)
EShSourceHlsl, // HLSL
LAST_ELEMENT_MARKER(EShSourceCount),
} EShSource; // if EShLanguage were EShStage, this could be EShLanguage instead
typedef enum {
EShClientNone, // use when there is no client, e.g. for validation
EShClientVulkan,
EShClientOpenGL,
LAST_ELEMENT_MARKER(EShClientCount),
} EShClient;
typedef enum {
EShTargetNone,
EShTargetSpv, // SPIR-V (preferred spelling)
EshTargetSpv = EShTargetSpv, // legacy spelling
LAST_ELEMENT_MARKER(EShTargetCount),
} EShTargetLanguage;
typedef enum {
EShTargetVulkan_1_0 = (1 << 22), // Vulkan 1.0
EShTargetVulkan_1_1 = (1 << 22) | (1 << 12), // Vulkan 1.1
EShTargetVulkan_1_2 = (1 << 22) | (2 << 12), // Vulkan 1.2
EShTargetOpenGL_450 = 450, // OpenGL
LAST_ELEMENT_MARKER(EShTargetClientVersionCount = 4),
} EShTargetClientVersion;
typedef EShTargetClientVersion EshTargetClientVersion;
typedef enum {
EShTargetSpv_1_0 = (1 << 16), // SPIR-V 1.0
EShTargetSpv_1_1 = (1 << 16) | (1 << 8), // SPIR-V 1.1
EShTargetSpv_1_2 = (1 << 16) | (2 << 8), // SPIR-V 1.2
EShTargetSpv_1_3 = (1 << 16) | (3 << 8), // SPIR-V 1.3
EShTargetSpv_1_4 = (1 << 16) | (4 << 8), // SPIR-V 1.4
EShTargetSpv_1_5 = (1 << 16) | (5 << 8), // SPIR-V 1.5
LAST_ELEMENT_MARKER(EShTargetLanguageVersionCount = 6),
} EShTargetLanguageVersion;
struct TInputLanguage {
EShSource languageFamily; // redundant information with other input, this one overrides when not EShSourceNone
EShLanguage stage; // redundant information with other input, this one overrides when not EShSourceNone
EShClient dialect;
int dialectVersion; // version of client's language definition, not the client (when not EShClientNone)
};
struct TClient {
EShClient client;
EShTargetClientVersion version; // version of client itself (not the client's input dialect)
};
struct TTarget {
EShTargetLanguage language;
EShTargetLanguageVersion version; // version to target, if SPIR-V, defined by "word 1" of the SPIR-V header
bool hlslFunctionality1; // can target hlsl_functionality1 extension(s)
};
// All source/client/target versions and settings.
// Can override previous methods of setting, when items are set here.
// Expected to grow, as more are added, rather than growing parameter lists.
struct TEnvironment {
TInputLanguage input; // definition of the input language
TClient client; // what client is the overall compilation being done for?
TTarget target; // what to generate
};
GLSLANG_EXPORT const char* StageName(EShLanguage);
} // end namespace glslang
//
// Types of output the linker will create.
//
typedef enum {
EShExVertexFragment,
EShExFragment
} EShExecutable;
//
// Optimization level for the compiler.
//
typedef enum {
EShOptNoGeneration,
EShOptNone,
EShOptSimple, // Optimizations that can be done quickly
EShOptFull, // Optimizations that will take more time
LAST_ELEMENT_MARKER(EshOptLevelCount),
} EShOptimizationLevel;
//
// Texture and Sampler transformation mode.
//
typedef enum {
EShTexSampTransKeep, // keep textures and samplers as is (default)
EShTexSampTransUpgradeTextureRemoveSampler, // change texture w/o embeded sampler into sampled texture and throw away all samplers
LAST_ELEMENT_MARKER(EShTexSampTransCount),
} EShTextureSamplerTransformMode;
//
// Message choices for what errors and warnings are given.
//
enum EShMessages : unsigned {
EShMsgDefault = 0, // default is to give all required errors and extra warnings
EShMsgRelaxedErrors = (1 << 0), // be liberal in accepting input
EShMsgSuppressWarnings = (1 << 1), // suppress all warnings, except those required by the specification
EShMsgAST = (1 << 2), // print the AST intermediate representation
EShMsgSpvRules = (1 << 3), // issue messages for SPIR-V generation
EShMsgVulkanRules = (1 << 4), // issue messages for Vulkan-requirements of GLSL for SPIR-V
EShMsgOnlyPreprocessor = (1 << 5), // only print out errors produced by the preprocessor
EShMsgReadHlsl = (1 << 6), // use HLSL parsing rules and semantics
EShMsgCascadingErrors = (1 << 7), // get cascading errors; risks error-recovery issues, instead of an early exit
EShMsgKeepUncalled = (1 << 8), // for testing, don't eliminate uncalled functions
EShMsgHlslOffsets = (1 << 9), // allow block offsets to follow HLSL rules instead of GLSL rules
EShMsgDebugInfo = (1 << 10), // save debug information
EShMsgHlslEnable16BitTypes = (1 << 11), // enable use of 16-bit types in SPIR-V for HLSL
EShMsgHlslLegalization = (1 << 12), // enable HLSL Legalization messages
EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (for samplers and semantics)
EShMsgBuiltinSymbolTable = (1 << 14), // print the builtin symbol table
LAST_ELEMENT_MARKER(EShMsgCount),
};
//
// Options for building reflection
//
typedef enum {
EShReflectionDefault = 0, // default is original behaviour before options were added
EShReflectionStrictArraySuffix = (1 << 0), // reflection will follow stricter rules for array-of-structs suffixes
EShReflectionBasicArraySuffix = (1 << 1), // arrays of basic types will be appended with [0] as in GL reflection
EShReflectionIntermediateIO = (1 << 2), // reflect inputs and outputs to program, even with no vertex shader
EShReflectionSeparateBuffers = (1 << 3), // buffer variables and buffer blocks are reflected separately
EShReflectionAllBlockVariables = (1 << 4), // reflect all variables in blocks, even if they are inactive
EShReflectionUnwrapIOBlocks = (1 << 5), // unwrap input/output blocks the same as with uniform blocks
EShReflectionAllIOVariables = (1 << 6), // reflect all input/output variables, even if they are inactive
EShReflectionSharedStd140SSBO = (1 << 7), // Apply std140/shared rules for ubo to ssbo
EShReflectionSharedStd140UBO = (1 << 8), // Apply std140/shared rules for ubo to ssbo
LAST_ELEMENT_MARKER(EShReflectionCount),
} EShReflectionOptions;
//
// Build a table for bindings. This can be used for locating
// attributes, uniforms, globals, etc., as needed.
//
typedef struct {
const char* name;
int binding;
} ShBinding;
typedef struct {
int numBindings;
ShBinding* bindings; // array of bindings
} ShBindingTable;
//
// ShHandle held by but opaque to the driver. It is allocated,
// managed, and de-allocated by the compiler/linker. It's contents
// are defined by and used by the compiler and linker. For example,
// symbol table information and object code passed from the compiler
// to the linker can be stored where ShHandle points.
//
// If handle creation fails, 0 will be returned.
//
typedef void* ShHandle;
//
// Driver calls these to create and destroy compiler/linker
// objects.
//
GLSLANG_EXPORT ShHandle ShConstructCompiler(const EShLanguage, int debugOptions); // one per shader
GLSLANG_EXPORT ShHandle ShConstructLinker(const EShExecutable, int debugOptions); // one per shader pair
GLSLANG_EXPORT ShHandle ShConstructUniformMap(); // one per uniform namespace (currently entire program object)
GLSLANG_EXPORT void ShDestruct(ShHandle);
//
// The return value of ShCompile is boolean, non-zero indicating
// success.
//
// The info-log should be written by ShCompile into
// ShHandle, so it can answer future queries.
//
GLSLANG_EXPORT int ShCompile(
const ShHandle,
const char* const shaderStrings[],
const int numStrings,
const int* lengths,
const EShOptimizationLevel,
const TBuiltInResource *resources,
int debugOptions,
int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader
bool forwardCompatible = false, // give errors for use of deprecated features
EShMessages messages = EShMsgDefault // warnings and errors
);
GLSLANG_EXPORT int ShLinkExt(
const ShHandle, // linker object
const ShHandle h[], // compiler objects to link together
const int numHandles);
//
// ShSetEncrpytionMethod is a place-holder for specifying
// how source code is encrypted.
//
GLSLANG_EXPORT void ShSetEncryptionMethod(ShHandle);
//
// All the following return 0 if the information is not
// available in the object passed down, or the object is bad.
//
GLSLANG_EXPORT const char* ShGetInfoLog(const ShHandle);
GLSLANG_EXPORT const void* ShGetExecutable(const ShHandle);
GLSLANG_EXPORT int ShSetVirtualAttributeBindings(const ShHandle, const ShBindingTable*); // to detect user aliasing
GLSLANG_EXPORT int ShSetFixedAttributeBindings(const ShHandle, const ShBindingTable*); // to force any physical mappings
//
// Tell the linker to never assign a vertex attribute to this list of physical attributes
//
GLSLANG_EXPORT int ShExcludeAttributes(const ShHandle, int *attributes, int count);
//
// Returns the location ID of the named uniform.
// Returns -1 if error.
//
GLSLANG_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* name);
#ifdef __cplusplus
} // end extern "C"
#endif
////////////////////////////////////////////////////////////////////////////////////////////
//
// Deferred-Lowering C++ Interface
// -----------------------------------
//
// Below is a new alternate C++ interface, which deprecates the above
// opaque handle-based interface.
//
// The below is further designed to handle multiple compilation units per stage, where
// the intermediate results, including the parse tree, are preserved until link time,
// rather than the above interface which is designed to have each compilation unit
// lowered at compile time. In the above model, linking occurs on the lowered results,
// whereas in this model intra-stage linking can occur at the parse tree
// (treeRoot in TIntermediate) level, and then a full stage can be lowered.
//
#include <list>
#include <string>
#include <utility>
class TCompiler;
class TInfoSink;
namespace glslang {
struct Version {
int major;
int minor;
int patch;
const char* flavor;
};
GLSLANG_EXPORT Version GetVersion();
GLSLANG_EXPORT const char* GetEsslVersionString();
GLSLANG_EXPORT const char* GetGlslVersionString();
GLSLANG_EXPORT int GetKhronosToolId();
class TIntermediate;
class TProgram;
class TPoolAllocator;
// Call this exactly once per process before using anything else
GLSLANG_EXPORT bool InitializeProcess();
// Call once per process to tear down everything
GLSLANG_EXPORT void FinalizeProcess();
// Resource type for IO resolver
enum TResourceType {
EResSampler,
EResTexture,
EResImage,
EResUbo,
EResSsbo,
EResUav,
EResCount
};
// Make one TShader per shader that you will link into a program. Then
// - provide the shader through setStrings() or setStringsWithLengths()
// - optionally call setEnv*(), see below for more detail
// - optionally use setPreamble() to set a special shader string that will be
// processed before all others but won't affect the validity of #version
// - optionally call addProcesses() for each setting/transform,
// see comment for class TProcesses
// - call parse(): source language and target environment must be selected
// either by correct setting of EShMessages sent to parse(), or by
// explicitly calling setEnv*()
// - query the info logs
//
// N.B.: Does not yet support having the same TShader instance being linked into
// multiple programs.
//
// N.B.: Destruct a linked program *before* destructing the shaders linked into it.
//
class TShader {
public:
GLSLANG_EXPORT explicit TShader(EShLanguage);
GLSLANG_EXPORT virtual ~TShader();
GLSLANG_EXPORT void setStrings(const char* const* s, int n);
GLSLANG_EXPORT void setStringsWithLengths(
const char* const* s, const int* l, int n);
GLSLANG_EXPORT void setStringsWithLengthsAndNames(
const char* const* s, const int* l, const char* const* names, int n);
void setPreamble(const char* s) { preamble = s; }
GLSLANG_EXPORT void setEntryPoint(const char* entryPoint);
GLSLANG_EXPORT void setSourceEntryPoint(const char* sourceEntryPointName);
GLSLANG_EXPORT void addProcesses(const std::vector<std::string>&);
// IO resolver binding data: see comments in ShaderLang.cpp
GLSLANG_EXPORT void setShiftBinding(TResourceType res, unsigned int base);
GLSLANG_EXPORT void setShiftSamplerBinding(unsigned int base); // DEPRECATED: use setShiftBinding
GLSLANG_EXPORT void setShiftTextureBinding(unsigned int base); // DEPRECATED: use setShiftBinding
GLSLANG_EXPORT void setShiftImageBinding(unsigned int base); // DEPRECATED: use setShiftBinding
GLSLANG_EXPORT void setShiftUboBinding(unsigned int base); // DEPRECATED: use setShiftBinding
GLSLANG_EXPORT void setShiftUavBinding(unsigned int base); // DEPRECATED: use setShiftBinding
GLSLANG_EXPORT void setShiftCbufferBinding(unsigned int base); // synonym for setShiftUboBinding
GLSLANG_EXPORT void setShiftSsboBinding(unsigned int base); // DEPRECATED: use setShiftBinding
GLSLANG_EXPORT void setShiftBindingForSet(TResourceType res, unsigned int base, unsigned int set);
GLSLANG_EXPORT void setResourceSetBinding(const std::vector<std::string>& base);
GLSLANG_EXPORT void setAutoMapBindings(bool map);
GLSLANG_EXPORT void setAutoMapLocations(bool map);
GLSLANG_EXPORT void addUniformLocationOverride(const char* name, int loc);
GLSLANG_EXPORT void setUniformLocationBase(int base);
GLSLANG_EXPORT void setInvertY(bool invert);
#ifdef ENABLE_HLSL
GLSLANG_EXPORT void setHlslIoMapping(bool hlslIoMap);
GLSLANG_EXPORT void setFlattenUniformArrays(bool flatten);
#endif
GLSLANG_EXPORT void setNoStorageFormat(bool useUnknownFormat);
GLSLANG_EXPORT void setNanMinMaxClamp(bool nanMinMaxClamp);
GLSLANG_EXPORT void setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode);
// For setting up the environment (cleared to nothingness in the constructor).
// These must be called so that parsing is done for the right source language and
// target environment, either indirectly through TranslateEnvironment() based on
// EShMessages et. al., or directly by the user.
//
// setEnvInput: The input source language and stage. If generating code for a
// specific client, the input client semantics to use and the
// version of the that client's input semantics to use, otherwise
// use EShClientNone and version of 0, e.g. for validation mode.
// Note 'version' does not describe the target environment,
// just the version of the source dialect to compile under.
//
// See the definitions of TEnvironment, EShSource, EShLanguage,
// and EShClient for choices and more detail.
//
// setEnvClient: The client that will be hosting the execution, and it's version.
// Note 'version' is not the version of the languages involved, but
// the version of the client environment.
// Use EShClientNone and version of 0 if there is no client, e.g.
// for validation mode.
//
// See EShTargetClientVersion for choices.
//
// setEnvTarget: The language to translate to when generating code, and that
// language's version.
// Use EShTargetNone and version of 0 if there is no client, e.g.
// for validation mode.
//
void setEnvInput(EShSource lang, EShLanguage envStage, EShClient client, int version)
{
environment.input.languageFamily = lang;
environment.input.stage = envStage;
environment.input.dialect = client;
environment.input.dialectVersion = version;
}
void setEnvClient(EShClient client, EShTargetClientVersion version)
{
environment.client.client = client;
environment.client.version = version;
}
void setEnvTarget(EShTargetLanguage lang, EShTargetLanguageVersion version)
{
environment.target.language = lang;
environment.target.version = version;
}
void getStrings(const char* const* &s, int& n) { s = strings; n = numStrings; }
#ifdef ENABLE_HLSL
void setEnvTargetHlslFunctionality1() { environment.target.hlslFunctionality1 = true; }
bool getEnvTargetHlslFunctionality1() const { return environment.target.hlslFunctionality1; }
#else
bool getEnvTargetHlslFunctionality1() const { return false; }
#endif
// Interface to #include handlers.
//
// To support #include, a client of Glslang does the following:
// 1. Call setStringsWithNames to set the source strings and associated
// names. For example, the names could be the names of the files
// containing the shader sources.
// 2. Call parse with an Includer.
//
// When the Glslang parser encounters an #include directive, it calls
// the Includer's include method with the requested include name
// together with the current string name. The returned IncludeResult
// contains the fully resolved name of the included source, together
// with the source text that should replace the #include directive
// in the source stream. After parsing that source, Glslang will
// release the IncludeResult object.
class Includer {
public:
// An IncludeResult contains the resolved name and content of a source
// inclusion.
struct IncludeResult {
IncludeResult(const std::string& headerName, const char* const headerData, const size_t headerLength, void* userData) :
headerName(headerName), headerData(headerData), headerLength(headerLength), userData(userData) { }
// For a successful inclusion, the fully resolved name of the requested
// include. For example, in a file system-based includer, full resolution
// should convert a relative path name into an absolute path name.
// For a failed inclusion, this is an empty string.
const std::string headerName;
// The content and byte length of the requested inclusion. The
// Includer producing this IncludeResult retains ownership of the
// storage.
// For a failed inclusion, the header
// field points to a string containing error details.
const char* const headerData;
const size_t headerLength;
// Include resolver's context.
void* userData;
protected:
IncludeResult& operator=(const IncludeResult&);
IncludeResult();
};
// For both include methods below:
//
// Resolves an inclusion request by name, current source name,
// and include depth.
// On success, returns an IncludeResult containing the resolved name
// and content of the include.
// On failure, returns a nullptr, or an IncludeResult
// with an empty string for the headerName and error details in the
// header field.
// The Includer retains ownership of the contents
// of the returned IncludeResult value, and those contents must
// remain valid until the releaseInclude method is called on that
// IncludeResult object.
//
// Note "local" vs. "system" is not an "either/or": "local" is an
// extra thing to do over "system". Both might get called, as per
// the C++ specification.
// For the "system" or <>-style includes; search the "system" paths.
virtual IncludeResult* includeSystem(const char* /*headerName*/,
const char* /*includerName*/,
size_t /*inclusionDepth*/) { return nullptr; }
// For the "local"-only aspect of a "" include. Should not search in the
// "system" paths, because on returning a failure, the parser will
// call includeSystem() to look in the "system" locations.
virtual IncludeResult* includeLocal(const char* /*headerName*/,
const char* /*includerName*/,
size_t /*inclusionDepth*/) { return nullptr; }
// Signals that the parser will no longer use the contents of the
// specified IncludeResult.
virtual void releaseInclude(IncludeResult*) = 0;
virtual ~Includer() {}
};
// Fail all Includer searches
class ForbidIncluder : public Includer {
public:
virtual void releaseInclude(IncludeResult*) override { }
};
GLSLANG_EXPORT bool parse(
const TBuiltInResource*, int defaultVersion, EProfile defaultProfile,
bool forceDefaultVersionAndProfile, bool forwardCompatible,
EShMessages, Includer&);
bool parse(const TBuiltInResource* res, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
bool forwardCompatible, EShMessages messages)
{
TShader::ForbidIncluder includer;
return parse(res, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, messages, includer);
}
// Equivalent to parse() without a default profile and without forcing defaults.
bool parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages)
{
return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages);
}
bool parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages,
Includer& includer)
{
return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages, includer);
}
// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string
// is not an officially supported or fully working path.
GLSLANG_EXPORT bool preprocess(
const TBuiltInResource* builtInResources, int defaultVersion,
EProfile defaultProfile, bool forceDefaultVersionAndProfile,
bool forwardCompatible, EShMessages message, std::string* outputString,
Includer& includer);
GLSLANG_EXPORT const char* getInfoLog();
GLSLANG_EXPORT const char* getInfoDebugLog();
EShLanguage getStage() const { return stage; }
TIntermediate* getIntermediate() const { return intermediate; }
protected:
TPoolAllocator* pool;
EShLanguage stage;
TCompiler* compiler;
TIntermediate* intermediate;
TInfoSink* infoSink;
// strings and lengths follow the standard for glShaderSource:
// strings is an array of numStrings pointers to string data.
// lengths can be null, but if not it is an array of numStrings
// integers containing the length of the associated strings.
// if lengths is null or lengths[n] < 0 the associated strings[n] is
// assumed to be null-terminated.
// stringNames is the optional names for all the strings. If stringNames
// is null, then none of the strings has name. If a certain element in
// stringNames is null, then the corresponding string does not have name.
const char* const* strings; // explicit code to compile, see previous comment
const int* lengths;
const char* const* stringNames;
int numStrings; // size of the above arrays
const char* preamble; // string of implicit code to compile before the explicitly provided code
// a function in the source string can be renamed FROM this TO the name given in setEntryPoint.
std::string sourceEntryPointName;
TEnvironment environment;
friend class TProgram;
private:
TShader& operator=(TShader&);
};
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
//
// A reflection database and its interface, consistent with the OpenGL API reflection queries.
//
// Data needed for just a single object at the granularity exchanged by the reflection API
class TObjectReflection {
public:
GLSLANG_EXPORT TObjectReflection(const std::string& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex);
GLSLANG_EXPORT const TType* getType() const { return type; }
GLSLANG_EXPORT int getBinding() const;
GLSLANG_EXPORT void dump() const;
static TObjectReflection badReflection() { return TObjectReflection(); }
std::string name;
int offset;
int glDefineType;
int size; // data size in bytes for a block, array size for a (non-block) object that's an array
int index;
int counterIndex;
int numMembers;
int arrayStride; // stride of an array variable
int topLevelArraySize; // size of the top-level variable in a storage buffer member
int topLevelArrayStride; // stride of the top-level variable in a storage buffer member
EShLanguageMask stages;
protected:
TObjectReflection()
: offset(-1), glDefineType(-1), size(-1), index(-1), counterIndex(-1), numMembers(-1), arrayStride(0),
topLevelArrayStride(0), stages(EShLanguageMask(0)), type(nullptr)
{
}
const TType* type;
};
class TReflection;
class TIoMapper;
struct TVarEntryInfo;
// Allows to customize the binding layout after linking.
// All used uniform variables will invoke at least validateBinding.
// If validateBinding returned true then the other resolveBinding,
// resolveSet, and resolveLocation are invoked to resolve the binding
// and descriptor set index respectively.
//
// Invocations happen in a particular order:
// 1) all shader inputs
// 2) all shader outputs
// 3) all uniforms with binding and set already defined
// 4) all uniforms with binding but no set defined
// 5) all uniforms with set but no binding defined
// 6) all uniforms with no binding and no set defined
//
// mapIO will use this resolver in two phases. The first
// phase is a notification phase, calling the corresponging
// notifiy callbacks, this phase ends with a call to endNotifications.
// Phase two starts directly after the call to endNotifications
// and calls all other callbacks to validate and to get the
// bindings, sets, locations, component and color indices.
//
// NOTE: that still limit checks are applied to bindings and sets
// and may result in an error.
class TIoMapResolver
{
public:
virtual ~TIoMapResolver() {}
// Should return true if the resulting/current binding would be okay.
// Basic idea is to do aliasing binding checks with this.
virtual bool validateBinding(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Should return a value >= 0 if the current binding should be overridden.
// Return -1 if the current binding (including no binding) should be kept.
virtual int resolveBinding(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Should return a value >= 0 if the current set should be overridden.
// Return -1 if the current set (including no set) should be kept.
virtual int resolveSet(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Should return a value >= 0 if the current location should be overridden.
// Return -1 if the current location (including no location) should be kept.
virtual int resolveUniformLocation(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Should return true if the resulting/current setup would be okay.
// Basic idea is to do aliasing checks and reject invalid semantic names.
virtual bool validateInOut(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Should return a value >= 0 if the current location should be overridden.
// Return -1 if the current location (including no location) should be kept.
virtual int resolveInOutLocation(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Should return a value >= 0 if the current component index should be overridden.
// Return -1 if the current component index (including no index) should be kept.
virtual int resolveInOutComponent(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Should return a value >= 0 if the current color index should be overridden.
// Return -1 if the current color index (including no index) should be kept.
virtual int resolveInOutIndex(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Notification of a uniform variable
virtual void notifyBinding(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Notification of a in or out variable
virtual void notifyInOut(EShLanguage stage, TVarEntryInfo& ent) = 0;
// Called by mapIO when it starts its notify pass for the given stage
virtual void beginNotifications(EShLanguage stage) = 0;
// Called by mapIO when it has finished the notify pass
virtual void endNotifications(EShLanguage stage) = 0;
// Called by mipIO when it starts its resolve pass for the given stage
virtual void beginResolve(EShLanguage stage) = 0;
// Called by mapIO when it has finished the resolve pass
virtual void endResolve(EShLanguage stage) = 0;
// Called by mapIO when it starts its symbol collect for teh given stage
virtual void beginCollect(EShLanguage stage) = 0;
// Called by mapIO when it has finished the symbol collect
virtual void endCollect(EShLanguage stage) = 0;
// Called by TSlotCollector to resolve storage locations or bindings
virtual void reserverStorageSlot(TVarEntryInfo& ent, TInfoSink& infoSink) = 0;
// Called by TSlotCollector to resolve resource locations or bindings
virtual void reserverResourceSlot(TVarEntryInfo& ent, TInfoSink& infoSink) = 0;
// Called by mapIO.addStage to set shader stage mask to mark a stage be added to this pipeline
virtual void addStage(EShLanguage stage) = 0;
};
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
// Make one TProgram per set of shaders that will get linked together. Add all
// the shaders that are to be linked together. After calling shader.parse()
// for all shaders, call link().
//
// N.B.: Destruct a linked program *before* destructing the shaders linked into it.
//
class TProgram {
public:
GLSLANG_EXPORT TProgram();
GLSLANG_EXPORT virtual ~TProgram();
void addShader(TShader* shader) { stages[shader->stage].push_back(shader); }
std::list<TShader*>& getShaders(EShLanguage stage) { return stages[stage]; }
// Link Validation interface
GLSLANG_EXPORT bool link(EShMessages);
GLSLANG_EXPORT const char* getInfoLog();
GLSLANG_EXPORT const char* getInfoDebugLog();
TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; }
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Reflection Interface
// call first, to do liveness analysis, index mapping, etc.; returns false on failure
GLSLANG_EXPORT bool buildReflection(int opts = EShReflectionDefault);
GLSLANG_EXPORT unsigned getLocalSize(int dim) const; // return dim'th local size
GLSLANG_EXPORT int getReflectionIndex(const char *name) const;
GLSLANG_EXPORT int getReflectionPipeIOIndex(const char* name, const bool inOrOut) const;
GLSLANG_EXPORT int getNumUniformVariables() const;
GLSLANG_EXPORT const TObjectReflection& getUniform(int index) const;
GLSLANG_EXPORT int getNumUniformBlocks() const;
GLSLANG_EXPORT const TObjectReflection& getUniformBlock(int index) const;
GLSLANG_EXPORT int getNumPipeInputs() const;
GLSLANG_EXPORT const TObjectReflection& getPipeInput(int index) const;
GLSLANG_EXPORT int getNumPipeOutputs() const;
GLSLANG_EXPORT const TObjectReflection& getPipeOutput(int index) const;
GLSLANG_EXPORT int getNumBufferVariables() const;
GLSLANG_EXPORT const TObjectReflection& getBufferVariable(int index) const;
GLSLANG_EXPORT int getNumBufferBlocks() const;
GLSLANG_EXPORT const TObjectReflection& getBufferBlock(int index) const;
GLSLANG_EXPORT int getNumAtomicCounters() const;
GLSLANG_EXPORT const TObjectReflection& getAtomicCounter(int index) const;
// Legacy Reflection Interface - expressed in terms of above interface
// can be used for glGetProgramiv(GL_ACTIVE_UNIFORMS)
int getNumLiveUniformVariables() const { return getNumUniformVariables(); }
// can be used for glGetProgramiv(GL_ACTIVE_UNIFORM_BLOCKS)
int getNumLiveUniformBlocks() const { return getNumUniformBlocks(); }
// can be used for glGetProgramiv(GL_ACTIVE_ATTRIBUTES)
int getNumLiveAttributes() const { return getNumPipeInputs(); }
// can be used for glGetUniformIndices()
int getUniformIndex(const char *name) const { return getReflectionIndex(name); }
int getPipeIOIndex(const char *name, const bool inOrOut) const
{ return getReflectionPipeIOIndex(name, inOrOut); }
// can be used for "name" part of glGetActiveUniform()
const char *getUniformName(int index) const { return getUniform(index).name.c_str(); }
// returns the binding number
int getUniformBinding(int index) const { return getUniform(index).getBinding(); }
// returns Shaders Stages where a Uniform is present
EShLanguageMask getUniformStages(int index) const { return getUniform(index).stages; }
// can be used for glGetActiveUniformsiv(GL_UNIFORM_BLOCK_INDEX)
int getUniformBlockIndex(int index) const { return getUniform(index).index; }
// can be used for glGetActiveUniformsiv(GL_UNIFORM_TYPE)
int getUniformType(int index) const { return getUniform(index).glDefineType; }
// can be used for glGetActiveUniformsiv(GL_UNIFORM_OFFSET)
int getUniformBufferOffset(int index) const { return getUniform(index).offset; }
// can be used for glGetActiveUniformsiv(GL_UNIFORM_SIZE)
int getUniformArraySize(int index) const { return getUniform(index).size; }
// returns a TType*
const TType *getUniformTType(int index) const { return getUniform(index).getType(); }
// can be used for glGetActiveUniformBlockName()
const char *getUniformBlockName(int index) const { return getUniformBlock(index).name.c_str(); }
// can be used for glGetActiveUniformBlockiv(UNIFORM_BLOCK_DATA_SIZE)
int getUniformBlockSize(int index) const { return getUniformBlock(index).size; }
// returns the block binding number
int getUniformBlockBinding(int index) const { return getUniformBlock(index).getBinding(); }
// returns block index of associated counter.
int getUniformBlockCounterIndex(int index) const { return getUniformBlock(index).counterIndex; }
// returns a TType*
const TType *getUniformBlockTType(int index) const { return getUniformBlock(index).getType(); }
// can be used for glGetActiveAttrib()
const char *getAttributeName(int index) const { return getPipeInput(index).name.c_str(); }
// can be used for glGetActiveAttrib()
int getAttributeType(int index) const { return getPipeInput(index).glDefineType; }
// returns a TType*
const TType *getAttributeTType(int index) const { return getPipeInput(index).getType(); }
GLSLANG_EXPORT void dumpReflection();
// I/O mapping: apply base offsets and map live unbound variables
// If resolver is not provided it uses the previous approach
// and respects auto assignment and offsets.
GLSLANG_EXPORT bool mapIO(TIoMapResolver* pResolver = nullptr, TIoMapper* pIoMapper = nullptr);
#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
protected:
GLSLANG_EXPORT bool linkStage(EShLanguage, EShMessages);
TPoolAllocator* pool;
std::list<TShader*> stages[EShLangCount];
TIntermediate* intermediate[EShLangCount];
bool newedIntermediate[EShLangCount]; // track which intermediate were "new" versus reusing a singleton unit in a stage
TInfoSink* infoSink;
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
TReflection* reflection;
#endif
bool linked;
private:
TProgram(TProgram&);
TProgram& operator=(TProgram&);
};
} // end namespace glslang
#endif // _COMPILER_INTERFACE_INCLUDED_

@ -0,0 +1,108 @@
/*
** Copyright (c) 2014-2016 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
** to deal in the Materials without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Materials, and to permit persons to whom the
** Materials are furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Materials.
**
** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
** IN THE MATERIALS.
*/
#ifndef GLSLextAMD_H
#define GLSLextAMD_H
static const int GLSLextAMDVersion = 100;
static const int GLSLextAMDRevision = 7;
// SPV_AMD_shader_ballot
static const char* const E_SPV_AMD_shader_ballot = "SPV_AMD_shader_ballot";
enum ShaderBallotAMD {
ShaderBallotBadAMD = 0, // Don't use
SwizzleInvocationsAMD = 1,
SwizzleInvocationsMaskedAMD = 2,
WriteInvocationAMD = 3,
MbcntAMD = 4,
ShaderBallotCountAMD
};
// SPV_AMD_shader_trinary_minmax
static const char* const E_SPV_AMD_shader_trinary_minmax = "SPV_AMD_shader_trinary_minmax";
enum ShaderTrinaryMinMaxAMD {
ShaderTrinaryMinMaxBadAMD = 0, // Don't use
FMin3AMD = 1,
UMin3AMD = 2,
SMin3AMD = 3,
FMax3AMD = 4,
UMax3AMD = 5,
SMax3AMD = 6,
FMid3AMD = 7,
UMid3AMD = 8,
SMid3AMD = 9,
ShaderTrinaryMinMaxCountAMD
};
// SPV_AMD_shader_explicit_vertex_parameter
static const char* const E_SPV_AMD_shader_explicit_vertex_parameter = "SPV_AMD_shader_explicit_vertex_parameter";
enum ShaderExplicitVertexParameterAMD {
ShaderExplicitVertexParameterBadAMD = 0, // Don't use
InterpolateAtVertexAMD = 1,
ShaderExplicitVertexParameterCountAMD
};
// SPV_AMD_gcn_shader
static const char* const E_SPV_AMD_gcn_shader = "SPV_AMD_gcn_shader";
enum GcnShaderAMD {
GcnShaderBadAMD = 0, // Don't use
CubeFaceIndexAMD = 1,
CubeFaceCoordAMD = 2,
TimeAMD = 3,
GcnShaderCountAMD
};
// SPV_AMD_gpu_shader_half_float
static const char* const E_SPV_AMD_gpu_shader_half_float = "SPV_AMD_gpu_shader_half_float";
// SPV_AMD_texture_gather_bias_lod
static const char* const E_SPV_AMD_texture_gather_bias_lod = "SPV_AMD_texture_gather_bias_lod";
// SPV_AMD_gpu_shader_int16
static const char* const E_SPV_AMD_gpu_shader_int16 = "SPV_AMD_gpu_shader_int16";
// SPV_AMD_shader_image_load_store_lod
static const char* const E_SPV_AMD_shader_image_load_store_lod = "SPV_AMD_shader_image_load_store_lod";
// SPV_AMD_shader_fragment_mask
static const char* const E_SPV_AMD_shader_fragment_mask = "SPV_AMD_shader_fragment_mask";
// SPV_AMD_gpu_shader_half_float_fetch
static const char* const E_SPV_AMD_gpu_shader_half_float_fetch = "SPV_AMD_gpu_shader_half_float_fetch";
#endif // #ifndef GLSLextAMD_H

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save