-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathpasses.td
4922 lines (3801 loc) · 158 KB
/
passes.td
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Copyright (C) 2022-2025 Intel Corporation.
// SPDX-License-Identifier: Apache 2.0
//
#ifndef VPUX_COMPILER_DIALECT_IE_PASSES
#define VPUX_COMPILER_DIALECT_IE_PASSES
include "mlir/Pass/PassBase.td"
//=================================================================================
// Precisions and Layouts
//=================================================================================
//
// Outliner
//
def Outliner : PassBase<"outliner", "vpux::ModulePass"> {
let summary = "Extracts function based on result from IR analysis";
let description = [{
This pass is used for parallel compilation. It outlines functions, it does this in
a similar way to how inlining a function works but other way around. It breaks a large
function into multiple functions which the original function calls.
Below is an example of what the outlier does on the function main:
```
func.func @main(%arg0: tensor<1x3x62x62xf32>) -> (tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32>) {
%cst = const.Declare tensor<48x3x3x3xf32> = dense<1.0> : tensor<48x3x3x3xf32>
%0 = IE.Convolution(%arg0, %cst) {
dilations = [1, 1],
pads_begin = [0, 0],
pads_end = [0, 0],
strides = [1, 1]
} : tensor<1x3x62x62xf32>, tensor<48x3x3x3xf32> -> tensor<1x48x60x60xf32>
%1 = IE.SoftMax(%0) {axisInd = 1} : tensor<1x48x60x60xf32> -> tensor<1x48x60x60xf32>
%2 = IE.Add(%0, %1) { auto_broadcast = #IE.auto_broadcast_type<NUMPY> } : tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32> -> tensor<1x48x60x60xf32>
return %0, %2: tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32>
}
```
It splits the function by the number of splits passed as a pass option `num-parts`.
In the example below the number of parts are two:
```
func.func private @main_part1(%arg0: tensor<1x3x62x62xf32>) -> (tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32>) {
%cst = const.Declare tensor<48x3x3x3xf32> = dense<1.000000e+00> : tensor<48x3x3x3xf32>
%0 = IE.Convolution(%arg0, %cst) {dilations = [1, 1], pads_begin = [0, 0], pads_end = [0, 0], strides = [1, 1]} : tensor<1x3x62x62xf32>, tensor<48x3x3x3xf32> -> tensor<1x48x60x60xf32>
%1 = IE.SoftMax(%0) {axisInd = 1 : i64} : tensor<1x48x60x60xf32> -> tensor<1x48x60x60xf32>
return %0, %1 : tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32>
}
func.func private @main_part2(%arg0: tensor<1x48x60x60xf32>, %arg1: tensor<1x48x60x60xf32>) -> tensor<1x48x60x60xf32> {
%0 = IE.Add(%arg0, %arg1) {auto_broadcast = #IE.auto_broadcast_type<NUMPY>} : tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32> -> tensor<1x48x60x60xf32>
return %0 : tensor<1x48x60x60xf32>
}
func.func @main(%arg0: tensor<1x3x62x62xf32>) -> (tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32>) {
%0:2 = call @main_part1(%arg0) : (tensor<1x3x62x62xf32>) -> (tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32>)
%1 = call @main_part2(%0#0, %0#1) : (tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32>) -> tensor<1x48x60x60xf32>
return %0#0, %1 : tensor<1x48x60x60xf32>, tensor<1x48x60x60xf32>
}
```
# Configuration
Available modes and their parameters are:
naive
num-parts - the number of parts to split the IR into
repeating-blocks
max-num-iterations - the maximum number of iterations
min-ops-in-block - the minimum number of operations allowed in a blocks
Example:
vpux-opt --outliner="function-outlining='repeating-blocks='ax-num-iterations=30 min-ops-in-block=16, naive=num-parts=2'"
}];
let constructor = "vpux::IE::createOutlinerPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"functionOutlining", "function-outlining",
"std::string", "\"naive\"",
"Define a list of outlining modes and their parameters where the next outlining mode is the fallback mode of the previous one. See pass description for more information."
>
];
}
//
// DuplicateFQAcrossFunctionCalls
//
def DuplicateFQAcrossFunctionCalls : PassBase<"duplicate-fq-across-function-calls", "vpux::ModulePass"> {
let summary = "Duplicates FakeQuantize operations across function calls";
let description = [{
Identifies cases where FakeQuantzie operations should be duplicated inside or outside functions.
For example, for the following IR:
func @function(%arg) {
%fq1 = FakeQuantize(%arg)
%0 = Op(%fq1)
return %0
}
func @main(%arg) {
%0 = Op(%arg)
%call = call @function(%0)
%fq2 = FakeQuantize(%call)
%1 = Op(%fq2)
return %1
}
The %fq1 operation will be duplicated outside the function and will be the parent operation for the call op.
Similarly, %fq2 will be duplicated inside the function and will be the parent for the return op.
}];
let constructor = "vpux::IE::createDuplicateFQAcrossFunctionCallsPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// Debatcher
//
def Debatcher : PassBase<"debatcher", "vpux::FunctionPass"> {
let summary = "Downcast input batched tensor arguments of a `main`-function to single batch tensors, which is supposed to unblock further transformations dedicated to support batched models compilation. . This is a frontend of 'Debatcher-Outliner-DeDebatcher' approach";
let description = [{
This pass is used together the Outliner pass, simplifying outlining routine
by eliminating necessity in debatching every input & output of outlined operations.
Instead, it just debatches the input tensor rather than intruding in outliner logic
}];
let constructor = "vpux::IE::createDebatcherPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"extraArgs", "extra-args",
"std::string", [{""}],
"Debatcher extra arguments"
>
];
}
//
// DeDebatcher
//
def DeDebatcher : PassBase<"de-debatcher", "vpux::FunctionPass"> {
let summary = "Rollback DeDebatcher tensors downcasting operations from N->1 by adding a body function N-respective repetitions";
let description = [{
This pass is used together with the Debatcher-Outliner pass. It finalizes batching tensors compilation routine
by adding repetitions an outlined function, which representing an IR body.
The total number of repetitions is the initial N dimension value, which was previously downcasted into N
}];
let constructor = "vpux::IE::createDeDebatcherPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"debatcherMethod", "debatching-inlining-method",
"std::string", [{"naive"}],
"Propagate relevant debatcher inlining method"
>
];
}
//
// OverrideTileExecutorNum
//
def OverrideTileExecutorNum : PassBase<"override-tile-executor-num", "vpux::ModulePass"> {
let summary = "Overrides the tile executor count to optimize memory resource allocation.";
let description = [{
This pass is used together with or after the DeDebatcher pass, to simplify the process of
managing memory resources by avoiding complex recalculations of shapes, offsets, and other attributes.
Currently supports two modes:
- `apply`: Adjusts the tile count to match the number of tiles per batch.
- `revert`: Reverts the tile count to the value before overriding.
Note:
- This pass does not allow multiple overrides without a revert to ensure consistency.
- This pass relies on DebatchedCallOpAttributeView information to track and manage the tile count.
}];
let constructor = "vpux::IE::createOverrideTileExecutorNumPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"overrideToTilesPerBatchMode", "override-to-tiles-per-batch-mode",
"std::string", [{"apply"}],
"Selects the overriding mode: `apply` or `revert`"
>
];
}
//
// UseUserPrecision
//
def UseUserPrecision : PassBase<"use-user-precision", "vpux::ModulePass"> {
let summary = "Use user precisions for entry point function prototype";
let description = [{
The pass is a part of `IECommon` pipeline.
This pass updates the CNNNetwork entry point function prototype and use user-provided precisions for its operands and results.
The pass inserts Convert operations from/to topology precisions.
}];
let constructor = "vpux::IE::createUseUserPrecisionPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// AdjustLayouts
//
def AdjustLayouts : PassBase<"adjust-layouts", "vpux::FunctionPass"> {
let summary = "Adjust required layouts for all layers";
let description = [{
The pass is a part of `IECommon` pipeline.
This pass adds the required layouts instead of the default one
depending on the layer specification from underlying Dialect.
}];
let constructor = "vpux::IE::createAdjustLayoutsPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"seOpsEnabled", "se-ops-enabled",
"bool", "false",
"Flag to identify whether operations that can be executed using the Storage Element hardware feature are enabled"
>,
Option<
"seExperimentalOpsEnabled", "se-experimental-ops-enabled",
"bool", "false",
"This flag identifies operations that are still a work in progress and can be executed using the Storage Element hardware feature."
>
];
}
//
// FuseReshapeMvnPass
//
def FuseReshapeMvn : PassBase<"fuse-reshape-mvn", "vpux::FunctionPass"> {
let summary = "Fuse Reshape->MVN->Reshape (back to initial shape) into MVN with internal-reshape";
let description = [{
The pass is a part of `IECommon` pipeline.
Can only succeed in NHWC layout, for large tensors that require MVN-decomposition.
}];
let constructor = "vpux::IE::createFuseReshapeMvnPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// FuseRMSNorm
//
def FuseRMSNorm : PassBase<"fuse-rmsnorm", "vpux::FunctionPass"> {
let summary = "Fuse Power-ReduceMean-Add-Sqrt-Divide-Multiply-Multiply to RMSNorm";
let description = [{
fuse a sequence of ops to one RMSNorm.
}];
let constructor = "vpux::IE::createFuseRMSNormPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// FuseRoPE
//
def FuseRoPE : PassBase<"fuse-rope", "vpux::FunctionPass"> {
let summary = "Fuse Multiply-StridedSlice-Multiply-StridedSlice-Concat-Multiply-Add to RoPE";
let description = [{
fuse a sequence of ops to one RoPE.
}];
let constructor = "vpux::IE::createFuseRoPEPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// OptimizeReorders
//
def OptimizeReorders : PassBase<"optimize-reorders", "vpux::FunctionPass"> {
let summary = "Optimize extra Reorder operations";
let description = [{
The pass is a part of `IECommon` pipeline.
This pass tries to optimize out Reorder operations for common cases
by propagating them from inputs to outputs and merging into layers.
}];
let constructor = "vpux::IE::createOptimizeReordersPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"seOpsEnabled", "se-ops-enabled",
"bool", "false",
"Flag to identify whether operations that can be executed using the Storage Element hardware feature are enabled"
>,
Option<
"seExperimentalOpsEnabled", "se-experimental-ops-enabled",
"bool", "false",
"This flag identifies operations that are still a work in progress and can be executed using the Storage Element hardware feature."
>
];
}
//
// OptimizeTileOp
//
def OptimizeTileOp : PassBase<"optimize-tile-op", "vpux::FunctionPass"> {
let summary = "Optimize tile ops";
let description = [{
The pass removes the useless tile op if the user is sw which supports broadcast
}];
let constructor = "vpux::IE::createOptimizeTileOpPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// OptimizePrecisionAcrossFunctionCalls
//
def OptimizePrecisionAcrossFunctionCalls : PassBase<"optimize-precision-across-function-calls", "vpux::ModulePass"> {
let summary = "Optimizes conversion / quantization operations across function calls";
let description = [{
Tries to optimize out Convert->Convert / Dequantize->Quantize operations that are found at the boundaries of functions,
if these pairs of operations end up producing the same element type.
}];
let constructor = "vpux::IE::createOptimizePrecisionAcrossFunctionCallsPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// OptimizeReordersAcrossFunctionCalls
//
def OptimizeReordersAcrossFunctionCalls : PassBase<"optimize-reorders-across-function-calls", "vpux::ModulePass"> {
let summary = "Optimizes Reorder operations across function calls";
let description = [{
Tries to optimize out Reorder operations that are found at the boundaries of functions, when possible.
The Reorders found at the boundaries of a function (i.e. the users of the block arguments or the producers
of the returned values) are indirectly connected with other operations outside the function, via the call
operations of the function. If these Reorders are found to be optimizable due to these connections, they
will be removed and the function signature updated.
}];
let constructor = "vpux::IE::createOptimizeReordersAcrossFunctionCallsPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"seOpsEnabled", "se-ops-enabled",
"bool", "false",
"Flag to identify whether operations that can be executed using the Storage Element hardware feature are enabled"
>,
Option<
"seExperimentalOpsEnabled", "se-experimental-ops-enabled",
"bool", "false",
"This flag identifies operations that are still a work in progress and can be executed using the Storage Element hardware feature."
>
];
}
//
// ConvertSplitConcatToTranspose
//
def ConvertSplitConcatToTranspose : PassBase<"convert-split-concat-to-transpose", "vpux::FunctionPass"> {
let summary = "Convert the pattern {Split -> AffineReshape -> Concat} to Transpose";
let description = [{
This pass replaces the pattern {Split -> AffineReshape -> Concat} with Transpose operation.
}];
let constructor = "vpux::IE::createConvertSplitConcatToTransposePass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//=================================================================================
// AdjustForVPU
//=================================================================================
//
// ConvertAssignReadValueToReturnsAndInputs
//
def ConvertAssignReadValueToReturnsAndInputs : PassBase<"convert-assign-read-value", "vpux::FunctionPass"> {
let summary = "Convert assign to returns and read value to inputs";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass replaces `Assign` operations with main function returns and
`ReadValue` operations with main function inputs.
}];
let constructor = "vpux::IE::createConvertAssignReadValueToReturnsAndInputs()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertToSpatialOp
//
def ConvertToSpatialOp : PassBase<"convert-to-spatial-op", "vpux::FunctionPass"> {
let summary = "Insert Transpose around operations in case that they have non-spatial axes";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass inserts `Transpose` operations around dedicated operations to get spatial axes.
`Interpolate` and `Roll` are supported so far.
}];
let constructor = "vpux::IE::createConvertToSpatialOpPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"m2iEnabled", "m2i-enabled",
"bool", "false",
"Flag which identifies whether M2I is enabled. If no, the conversion can be applied to Interpolate"
>,
Option<
"seExperimentalOpsEnabled", "se-experimental-ops-enabled",
"bool", "false",
"This flag identifies whether SE Roll is enabled. If yes, the conversion can be applied to Roll"
>
];
}
//
// ConvertNearestToStridedConcat
//
def ConvertNearestToStridedConcat : PassBase<"convert-nearest-to-broadcast-or-strided-concat", "vpux::FunctionPass"> {
let summary = "Convert nearest interpolate op to broadcast or strided concat ops";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass replaces `Nearest Interpolate` operations with `Broadcast` or `Concat` operations with strides.
In case the `interpolateAsSEOp` option is set to true, only cases that cannot be executed
using the Storage Element hardware feature will be converted to `Broadcast` or `Concat`.
}];
let constructor = "vpux::IE::createConvertNearestToBroadCastOrStridedConcatPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"interpolateAsSEOp", "interpolate-as-se-op",
"bool", "false",
"Flag which identifies whether an Interpolate operation can be executed using the Storage Element hardware feature"
>
];
}
//
// SplitBilinerIntoHAndW
//
def SplitBilinerIntoHAndW : PassBase<"split-bilinear-into-H-and-W", "vpux::FunctionPass"> {
let summary = "Convert bilinear interpolate on H and W to slice, concat, convolution and interpolate on H";
let description = [{
This pass convert `Bilinear Interpolate` operations to interpolate on H and interpolate on W, and
the interpolate on W will convert to slice, concat and convolution.
This pass is enabled when both `interpolateAsSEOp` and `SplitBilinerIntoHAndW` options are set to true.
}];
let constructor = "vpux::IE::createSplitBilinerIntoHAndWPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertBilinearToStridedConcatAndConv
//
def ConvertBilinearToStridedConcatAndConv : PassBase<"convert-bilinear-to-strided-concat-and-conv", "vpux::FunctionPass"> {
let summary = "Convert bilinear interpolate op to strided concat, MaxPool and some depthwise convolution Ops";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass replaces `Bilinear Interpolate` operations with `Concat` operations with strides,
MaxPool and some `depthwise` convolutions.
In case the `interpolateAsSEOp` option is set to true, only cases that cannot be executed
using the Storage Element hardware feature will be converted to concats & NCE ops.
}];
let constructor = "vpux::IE::createConvertBilinearToStridedConcatAndConvPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"interpolateAsSEOp", "interpolate-as-se-op",
"bool", "false",
"Flag which identifies whether an Interpolate operation can be executed using the Storage Element hardware feature"
>
];
}
//
// ConvertScatterNDUpdateToStridedConcat
//
def ConvertScatterNDUpdateToStridedConcat : PassBase<"convert-scatterndupdate-to-strided-concat", "vpux::FunctionPass"> {
let summary = "Convert ScatterNDUpdate op to strided concat ops";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass replaces `ScatterNDUpdate` operations with `Concat` operations with strides.
}];
let constructor = "vpux::IE::createConvertScatterNDUpdateToStridedConcatPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertPrecisionToFP16
//
def ConvertPrecisionToFP16 : PassBase<"convert-precision-to-fp16", "vpux::ModulePass"> {
let summary = "Convert tensors precision from FP32 to FP16";
let description = [{
The pass is a part of `AdjustPrecision` pipeline.
This pass replaces all FP32 tensors with FP16.
It updates both function bodies as well as Function signatures.
}];
let constructor = "vpux::IE::createConvertPrecisionToFP16Pass()";
let options = [
Option<
"computeLayersWithHigherPrecision", "compute-layers-with-higher-precision",
"std::string", [{""}],
"Keep the specified FP32 layer(s) unchanged during the conversion to FP16"
>
];
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertPrecisionToI32
//
def ConvertPrecisionToI32 : PassBase<"convert-precision-to-i32", "vpux::ModulePass"> {
let summary = "Convert tensors precision from I64 to I32";
let description = [{
The pass is a part of `AdjustPrecision` pipeline.
This pass replaces all I64 tensors with I32.
It updates both function bodies as well as Function signatures.
}];
let constructor = "vpux::IE::createConvertPrecisionToI32Pass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// AdjustSoftwareOpsPrecision
//
def AdjustSoftwareOpsPrecision : PassBase<"adjust-software-ops-precision", "vpux::ModulePass"> {
let summary = "Adjust precision of software ops to satisfy kernel implementation";
let description = [{
The pass is a part of `AdjustPrecision` pipeline.
Some kernel implementations only support specific precisions. To satisfy this requirement,
such ops are surrounded by conversion layers.
}];
let constructor = "vpux::IE::createAdjustSoftwareOpsPrecisionPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// AdjustNCEOpsWithI32Inputs
//
def AdjustNCEOpsWithI32Inputs : PassBase<"adjust-nce-ops-with-i32-inputs", "vpux::ModulePass"> {
let summary = "Adjust precision for some NCE ops with i32 inputs";
let description = [{
The pass is a part of `AdjustPrecision` pipeline.
Currently NCE ops only support f16 or quantized inputs. In some cases, such ops with i32 inputs need conversion layers.
}];
let constructor = "vpux::IE::createAdjustNCEOpsWithI32InputsPass()";
let options = [
Option<
"enableConvertFCToConv", "convert-fc-to-conv",
"bool", "true",
"Specifies whether IE.FullyConnected will be converted to Conv and thus will need their inputs adjusted"
>
];
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertDepth2SpaceToTransposedConv
//
def ConvertDepth2SpaceToTransposedConv : PassBase<"convert-d2s-to-transposed-conv", "vpux::FunctionPass"> {
let summary = "Convert D2S layers to transposed convolution";
let description = [{
Convert D2S layers to a transposed convolution so we can execute them on DPU
rather than using a DMA.
}];
let constructor = "vpux::IE::createConvertDepth2SpaceToTransposedConvPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertDepth2SpaceLayer
//
def ConvertDepth2SpaceLayer : PassBase<"convert-depthToSpace", "vpux::FunctionPass"> {
let summary = "Convert DepthToSpace layer to {reshape -> transpose -> reshape} subgraph";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass replaces all `DepthToSpace` operations with {reshape -> transpose -> reshape} subgraph.
}];
let constructor = "vpux::IE::createConvertDepth2SpaceLayerPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertSpace2DepthLayer
//
def ConvertSpace2DepthLayer : PassBase<"convert-spaceToDepth", "vpux::FunctionPass"> {
let summary = "Convert SpaceToDepth layer to {reshape -> transpose -> reshape} pattern";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass replaces all `SpaceToDepth` operations with {reshape -> transpose -> reshape} pattern.
}];
let constructor = "vpux::IE::createConvertSpace2DepthLayerPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertGatherToSlice
//
def ConvertGatherToSlice : PassBase<"convert-gather-to-slice", "vpux::FunctionPass"> {
let summary = "Convert Gather operation to Slice operation";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass replaces legal `Gather` operations with `Slice` operations.
}];
let constructor = "vpux::IE::createConvertGatherToSlicePass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertScalarToTensor
//
def ConvertScalarToTensor : PassBase<"convert-scalar-to-tensor", "vpux::FunctionPass"> {
let summary = "Convert a scalar input to tensor";
let description = [{
This pass checks the operands/results rank for any operation and if it is a scalar(its rank is 0), it will be converted into a tensor with one element.
}];
let constructor = "vpux::IE::createConvertScalarToTensorPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertMinMaxToClamp
//
def ConvertMinMaxToClamp : PassBase<"convert-min-max-to-clamp", "vpux::FunctionPass"> {
let summary = "Convert Min and Max to Clamp";
let description = [{
This pass replaces MinimumOp and MaximumOp, having one input as tensor(2D,3D,4D) and the other one as scalar, with ClampOp.
}];
let constructor = "vpux::IE::createConvertMinMaxToClampPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertShapeTo4D
//
def ConvertShapeTo4D : PassBase<"convert-shape-to-4d", "vpux::FunctionPass"> {
let summary = "Convert tensors shapes to 4D";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass replaces ND tensor with 4D analogues for layers, which has such limitations on VPUIP level.
Also this pass replaces ND network inputs and outputs with 4D analogues to overcome runtime limitations.
}];
let constructor = "vpux::IE::createConvertShapeTo4DPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertPaddingsToFloorMode
//
def ConvertPaddingsToFloorMode : PassBase<"convert-paddings-to-floor-mode", "vpux::FunctionPass"> {
let summary = "Convert Convolution and Pooling layers paddings to FLOOR rouding mode";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass updates padding attributes for Convolution and Pooling layers.
It switches layer rounding mode to FLOOR and updates paddings to satisfy output shape.
}];
let constructor = "vpux::IE::createConvertPaddingsToFloorModePass()";
}
//
// ConvertFCToConv
//
def ConvertFCToConv : PassBase<"convert-fc-to-conv", "vpux::FunctionPass"> {
let summary = "Convert FullyConnected op to Convolution operation";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
This pass replaces all `FullyConnected` operations with `Convolution` operation.
It inserts extra `Reshape` operations to satisfy `Convolution` specification.
}];
let constructor = "vpux::IE::createConvertFCToConvPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// ConvertShuffleChannels
//
def ConvertShuffleChannels : PassBase<"convert-shuffle-channels", "vpux::FunctionPass"> {
let summary = "Convert ShuffleChannels to Reshape->Transpose->Reshape";
let description = [{
The pass is a part of `AdjustForVPU` pipeline.
Converts ShuffleChannels to Reshape->Transpose->Reshape.
}];
let constructor = "vpux::IE::createConvertShuffleChannelsPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
//
// MatMulInputsTo2d
//
def MatMulInputsTo2d : PassBase<"matmul-inputs-to-2d", "vpux::FunctionPass"> {
let summary = "Convert MatMul inputs to 2d";
let description = [{
This pass converts `MatMul` inputs to 2d.
For example, `MatMul` input with 4x1x64 geometry will be split to four inputs with 1x64 dimensions.
Resulting inputs with filters go to `MatMul` operations and the outputs are concatenated.
}];
let constructor = "vpux::IE::createMatMulInputsTo2dPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"enableGroupedMatMul", "enable-grouped-matmul",
"bool", "false",
"Flag to enable or disable grouped MatMul execution"
>
];
}
//
// ConvertNonConstantPadToSliceAndConcat
//
def ConvertNonConstantPadToSliceAndConcat : PassBase<"convert-non-constant-pad-to-slice-and-concat", "vpux::FunctionPass"> {
let summary = "Convert non constant pad to slice and concat";
let description = [{
// FIXME: #-108139
In Pad Operation, when pad_mode is not "constant", the padding operation will create a non constant padding according
to padding mode.
The Pad Operation can be transformed into multiple slice and concat operations.
}];
let constructor = "vpux::IE::createConvertNonConstantPadToSliceAndConcatPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
let options = [
Option<
"enableSEPPad", "enable-sep-pad",
"bool", "false",
"Flag which identifies whether an Pad operation can be executed using the Storage Element hardware feature"
>
];
}
//
// ConvertBatchedLayerTo1N
//
def ConvertBatchedLayerTo1N : PassBase<"convert-batched-layer-to-1n", "vpux::FunctionPass"> {
let summary = "Convert layer with batched input to new one with batch equal to 1";
let description = [{
This pass inserts Transpose to convert batched input to new one with batch equal to 1
Original operation:
Activation: 4x16x1x1 ->
Conv -> 4x5x1x1
Weights: 5x16x1x1 ->
New subgraph:
Activation:4x16x1x1 Weights:5x16x1x1
| |
Transpose:1x16x4x1 |
| |
| |
Conv:1x5x4x1
|
Transpose:4x5x1x1
}];
let constructor = "vpux::IE::createConvertBatchedLayerTo1NPass()";
let dependentDialects = [
"vpux::IE::IEDialect"
];
}
def ConvertDivideToMultiply : PassBase<"convert-divide-to-multiply", "vpux::FunctionPass"> {
let summary = "Converts IE.Divide to IE.Multiply";
let description = [{
Converts suitable IE.Divide with a constant to IE.Multiply with a
reciprocal(constant). Indirectly, this reduces the amount of complex
patterns as one does not need to differentiate between division and
multiplication after this pass.
See also ConvertSubtractToAdd for similar idea concerning IE.Subtract ->