MLIR 22.0.0git
SparseTensorPipelines.cpp
Go to the documentation of this file.
1//===- SparseTensorPipelines.cpp - Pipelines for sparse tensor code -------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
21
22//===----------------------------------------------------------------------===//
23// Pipeline implementation.
24//===----------------------------------------------------------------------===//
25
28 // Rewrite named linalg ops into generic ops and apply fusion.
31
32 // Sparsification and bufferization mini-pipeline.
35 options.testBufferizationAnalysisOnly),
36 options.sparsificationOptions(), options.createSparseDeallocs,
37 options.enableRuntimeLibrary, options.enableBufferInitialization,
38 options.vectorLength,
39 /*enableVLAVectorization=*/options.armSVE,
40 /*enableSIMDIndex32=*/options.force32BitVectorIndices,
41 options.enableGPULibgen,
42 options.sparsificationOptions().sparseEmitStrategy,
43 options.sparsificationOptions().parallelizationStrategy));
44
45 // Bail-early for test setup.
46 if (options.testBufferizationAnalysisOnly)
47 return;
48
49 // Storage specifier lowering and bufferization wrap-up.
51 pm.addNestedPass<func::FuncOp>(createCanonicalizerPass());
52
53 // GPU code generation.
54 const bool gpuCodegen = options.gpuTriple.hasValue();
55 if (gpuCodegen) {
57 pm.addNestedPass<gpu::GPUModuleOp>(createStripDebugInfoPass());
58 pm.addNestedPass<gpu::GPUModuleOp>(createSCFToControlFlowPass());
59 pm.addNestedPass<gpu::GPUModuleOp>(createConvertGpuOpsToNVVMOps());
60 }
61
62 // Progressively lower to LLVM. Note that the convert-vector-to-llvm
63 // pass is repeated on purpose.
64 // TODO(springerm): Add sparse support to the BufferDeallocation pass and add
65 // it to this pipeline.
69 pm.addNestedPass<func::FuncOp>(createSCFToControlFlowPass());
72 pm.addPass(
73 createConvertVectorToLLVMPass(options.convertVectorToLLVMOptions()));
79 pm.addPass(
80 createConvertVectorToLLVMPass(options.convertVectorToLLVMOptions()));
81
82 // Finalize GPU code generation.
83 if (gpuCodegen) {
84 GpuNVVMAttachTargetOptions nvvmTargetOptions;
85 nvvmTargetOptions.triple = options.gpuTriple;
86 nvvmTargetOptions.chip = options.gpuChip;
87 nvvmTargetOptions.features = options.gpuFeatures;
88 pm.addPass(createGpuNVVMAttachTarget(nvvmTargetOptions));
90 GpuModuleToBinaryPassOptions gpuModuleToBinaryPassOptions;
91 gpuModuleToBinaryPassOptions.compilationTarget = options.gpuFormat;
92 pm.addPass(createGpuModuleToBinaryPass(gpuModuleToBinaryPassOptions));
93 }
94
95 // Convert to LLVM.
97
98 // Ensure all casts are realized.
100}
101
102//===----------------------------------------------------------------------===//
103// Pipeline registration.
104//===----------------------------------------------------------------------===//
105
108 "sparsifier",
109 "The standard pipeline for taking sparsity-agnostic IR using the"
110 " sparse-tensor type, and lowering it to LLVM IR with concrete"
111 " representations and algorithms for sparse tensors.",
113}
static llvm::ManagedStatic< PassManagerOptions > options
This class represents a pass manager that runs passes on either a specific operation type,...
Definition PassManager.h:46
void addPass(std::unique_ptr< Pass > pass)
Add the given pass to this pass manager.
Definition Pass.cpp:392
void addNestedPass(std::unique_ptr< Pass > pass)
Add the given pass to a nested pass manager for the given operation kind OpT.
std::unique_ptr<::mlir::Pass > createArithExpandOpsPass()
std::unique_ptr<::mlir::Pass > createExpandReallocPass()
std::unique_ptr<::mlir::Pass > createExpandStridedMetadataPass()
void buildSparsifier(OpPassManager &pm, const SparsifierOptions &options)
Adds the "sparsifier" pipeline to the OpPassManager.
void registerSparseTensorPipelines()
Registers all pipelines for the sparse_tensor dialect.
std::unique_ptr<::mlir::Pass > createConvertToLLVMPass()
std::unique_ptr<::mlir::Pass > createSCFToControlFlowPass()
std::unique_ptr<::mlir::Pass > createConvertMathToLLVMPass()
std::unique_ptr< Pass > createSparseGPUCodegenPass()
bufferization::OneShotBufferizationOptions getBufferizationOptionsForSparsification(bool analysisOnly)
std::unique_ptr< Pass > createStripDebugInfoPass()
Creates a pass to strip debug information from a function.
std::unique_ptr<::mlir::Pass > createReconcileUnrealizedCastsPass()
std::unique_ptr<::mlir::Pass > createConvertVectorToLLVMPass()
std::unique_ptr< Pass > createSparsificationAndBufferizationPass()
std::unique_ptr<::mlir::Pass > createConvertComplexToLibm()
std::unique_ptr<::mlir::Pass > createGpuNVVMAttachTarget()
std::unique_ptr<::mlir::Pass > createLinalgElementwiseOpFusionPass()
std::unique_ptr<::mlir::Pass > createConvertGpuOpsToNVVMOps()
std::unique_ptr<::mlir::Pass > createLowerAffinePass()
std::unique_ptr<::mlir::Pass > createConvertMathToLibmPass()
std::unique_ptr<::mlir::Pass > createLinalgGeneralizeNamedOpsPass()
std::unique_ptr< Pass > createStorageSpecifierToLLVMPass()
std::unique_ptr< Pass > createCanonicalizerPass()
Creates an instance of the Canonicalizer pass, configured with default settings (which can be overrid...
std::unique_ptr<::mlir::Pass > createGpuToLLVMConversionPass()
std::unique_ptr<::mlir::Pass > createGpuModuleToBinaryPass()
std::unique_ptr< Pass > createConvertVectorToSCFPass(const VectorTransferToSCFOptions &options=VectorTransferToSCFOptions())
Create a pass to convert a subset of vector ops to SCF.
std::unique_ptr<::mlir::Pass > createConvertLinalgToLoopsPass()
Definition Loops.cpp:247
std::unique_ptr<::mlir::Pass > createConvertComplexToStandardPass()
PassPipelineRegistration provides a global initializer that registers a Pass pipeline builder routine...
Options for the "sparsifier" pipeline.
Definition Passes.h:30