File tree Expand file tree Collapse file tree
compiler/src/iree/compiler Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,6 +118,8 @@ void buildGlobalOptimizationPassPipeline(
118118 .addPass (IREE::Util::createOptimizeIntArithmeticPass)
119119 .addPass (createLinalgQuantizedConvToConvPass)
120120 .addPass (createLinalgQuantizedMatmulToMatmulPass)
121+ .addPredicatedPass (transformOptions.enableConv2DToImg2Col ,
122+ createConvertConv2DToImg2ColPass)
121123 .addPass (IREE::Flow::createCanonicalizePass)
122124 .addPass (createRemoveZeroExtentTensorsPass)
123125 .addPass (createDetachElementwiseFromNamedOpsPass)
Original file line number Diff line number Diff line change @@ -302,6 +302,11 @@ void GlobalOptimizationOptions::bindOptions(OptionsBinder &binder) {
302302 llvm::cl::desc (" Convert named matmul ops to linalg generic ops during "
303303 " global optimization to enable better fusion." ),
304304 llvm::cl::cat (category));
305+ binder.opt <bool >(
306+ " iree-global-opt-enable-conv2d-to-img2col" , enableConv2DToImg2Col,
307+ llvm::cl::desc (" Enables conversion of Conv2D operations to img2col + "
308+ " matmul form to leverage optimized matmul implementations." ),
309+ llvm::cl::cat (category));
305310}
306311
307312void SchedulingOptions::bindOptions (OptionsBinder &binder) {
Original file line number Diff line number Diff line change @@ -187,6 +187,9 @@ struct GlobalOptimizationOptions {
187187 // Converts linalg named matmul ops to linalg generic ops.
188188 bool generalizeMatmul = false ;
189189
190+ // Enables conversion of Conv2D operations to img2col + matmul form.
191+ bool enableConv2DToImg2Col = false ;
192+
190193 void bindOptions (OptionsBinder &binder);
191194 using FromFlags = OptionsFromFlags<GlobalOptimizationOptions>;
192195};
Original file line number Diff line number Diff line change @@ -212,6 +212,8 @@ void buildIREEPrecompileTransformPassPipeline(
212212 globalOptimizationOptions.stripAssertions ;
213213 globalTransformOptions.generalizeMatmul =
214214 globalOptimizationOptions.generalizeMatmul ;
215+ globalTransformOptions.enableConv2DToImg2Col =
216+ globalOptimizationOptions.enableConv2DToImg2Col ;
215217 globalTransformOptions.constExprHoisting = pipelineOptions.constExprHoisting ;
216218 globalTransformOptions.constExprMaxSizeIncreaseThreshold =
217219 pipelineOptions.constExprMaxSizeIncreaseThreshold ;
You can’t perform that action at this time.
0 commit comments