MLIR  16.0.0git
Passes.h
Go to the documentation of this file.
1 //===- Passes.h - Sparse tensor pipeline entry points -----------*- C++ -*-===//
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 //
9 // This header file defines prototypes of all sparse tensor pipelines.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_SPARSETENSOR_PIPELINES_PASSES_H_
14 #define MLIR_DIALECT_SPARSETENSOR_PIPELINES_PASSES_H_
15 
18 #include "mlir/Pass/PassOptions.h"
19 
20 using namespace mlir::detail;
21 using namespace llvm::cl;
22 
23 namespace mlir {
24 namespace sparse_tensor {
25 
26 /// Options for the "sparse-compiler" pipeline. So far this only contains
27 /// a subset of the options that can be set for the underlying passes,
28 /// because it must be manually kept in sync with the tablegen files
29 /// for those passes.
31  : public PassPipelineOptions<SparseCompilerOptions> {
32  // These options must be kept in sync with `SparsificationBase`.
34  *this, "parallelization-strategy",
35  desc("Set the parallelization strategy"), init(0)};
37  *this, "vectorization-strategy", desc("Set the vectorization strategy"),
38  init(0)};
40  *this, "vl", desc("Set the vector length"), init(1)};
41  PassOptions::Option<bool> enableSIMDIndex32{
42  *this, "enable-simd-index32",
43  desc("Enable i32 indexing into vectors (for efficiency)"), init(false)};
44  PassOptions::Option<bool> enableVLAVectorization{
45  *this, "enable-vla-vectorization",
46  desc("Enable vector length agnostic vectorization"), init(false)};
47  PassOptions::Option<bool> testBufferizationAnalysisOnly{
48  *this, "test-bufferization-analysis-only",
49  desc("Run only the inplacability analysis"), init(false)};
50 
51  /// Projects out the options for `createSparsificationPass`.
54  sparseVectorizationStrategy(vectorization),
55  vectorLength, enableSIMDIndex32,
56  enableVLAVectorization);
57  }
58 
59  // These options must be kept in sync with `SparseTensorConversionBase`.
61  *this, "s2s-strategy",
62  desc("Set the strategy for sparse-to-sparse conversion"), init(0)};
63 
64  /// Projects out the options for `createSparsificationPass`.
67  sparseToSparseConversionStrategy(sparseToSparse));
68  }
69 
70  // These options must be kept in sync with `ConvertVectorToLLVMBase`.
71  // TODO(wrengr): does `indexOptimizations` differ from `enableSIMDIndex32`?
72  PassOptions::Option<bool> reassociateFPReductions{
73  *this, "reassociate-fp-reductions",
74  desc("Allows llvm to reassociate floating-point reductions for speed"),
75  init(false)};
76  PassOptions::Option<bool> indexOptimizations{
77  *this, "enable-index-optimizations",
78  desc("Allows compiler to assume indices fit in 32-bit if that yields "
79  "faster code"),
80  init(true)};
82  *this, "enable-amx",
83  desc("Enables the use of AMX dialect while lowering the vector dialect."),
84  init(false)};
85  PassOptions::Option<bool> armNeon{*this, "enable-arm-neon",
86  desc("Enables the use of ArmNeon dialect "
87  "while lowering the vector dialect."),
88  init(false)};
89  PassOptions::Option<bool> armSVE{*this, "enable-arm-sve",
90  desc("Enables the use of ArmSVE dialect "
91  "while lowering the vector dialect."),
92  init(false)};
94  *this, "enable-x86vector",
95  desc("Enables the use of X86Vector dialect while lowering the vector "
96  "dialect."),
97  init(false)};
98 
99  /// Projects out the options for `createConvertVectorToLLVMPass`.
102  opts.enableReassociateFPReductions(reassociateFPReductions);
103  opts.enableIndexOptimizations(indexOptimizations);
104  opts.enableArmNeon(armNeon);
105  opts.enableArmSVE(armSVE);
106  opts.enableAMX(amx);
107  opts.enableX86Vector(x86Vector);
108  return opts;
109  }
110 };
111 
112 //===----------------------------------------------------------------------===//
113 // Building and Registering.
114 //===----------------------------------------------------------------------===//
115 
116 /// Adds the "sparse-compiler" pipeline to the `OpPassManager`. This
117 /// is the standard pipeline for taking sparsity-agnostic IR using
118 /// the sparse-tensor type and lowering it to LLVM IR with concrete
119 /// representations and algorithms for sparse tensors.
122 
123 /// Registers all pipelines for the `sparse_tensor` dialect. At present,
124 /// this includes only "sparse-compiler".
126 
127 } // namespace sparse_tensor
128 } // namespace mlir
129 
130 #endif // MLIR_DIALECT_SPARSETENSOR_PIPELINES_PASSES_H_
Include the generated interface declarations.
LowerVectorToLLVMOptions & enableAMX(bool b=true)
LowerVectorToLLVMOptions & enableArmNeon(bool b=true)
LowerVectorToLLVMOptions & enableIndexOptimizations(bool b=true)
void buildSparseCompiler(OpPassManager &pm, const SparseCompilerOptions &options)
Adds the "sparse-compiler" pipeline to the OpPassManager.
SparseToSparseConversionStrategy sparseToSparseConversionStrategy(int32_t flag)
Converts command-line sparse2sparse flag to the strategy enum.
SparseTensorConversionOptions sparseTensorConversionOptions() const
Projects out the options for createSparsificationPass.
Definition: Passes.h:65
SparseTensorConversion options.
Definition: Passes.h:122
void registerSparseTensorPipelines()
Registers all pipelines for the sparse_tensor dialect.
Options to control Vector to LLVM lowering.
LowerVectorToLLVMOptions & enableX86Vector(bool b=true)
LowerVectorToLLVMOptions & enableReassociateFPReductions(bool b=true)
static llvm::ManagedStatic< PassManagerOptions > options
Options for the "sparse-compiler" pipeline.
Definition: Passes.h:30
Subclasses of PassPipelineOptions provide a set of options that can be used to initialize a pass pipe...
Definition: PassOptions.h:325
SparsificationOptions sparsificationOptions() const
Projects out the options for createSparsificationPass.
Definition: Passes.h:52
Options for the Sparsification pass.
Definition: Passes.h:68
SparseParallelizationStrategy sparseParallelizationStrategy(int32_t flag)
Converts command-line parallelization flag to the strategy enum.
LowerVectorToLLVMOptions & enableArmSVE(bool b=true)
SparseVectorizationStrategy sparseVectorizationStrategy(int32_t flag)
Converts command-line vectorization flag to the strategy enum.
LowerVectorToLLVMOptions lowerVectorToLLVMOptions() const
Projects out the options for createConvertVectorToLLVMPass.
Definition: Passes.h:100
This class represents a pass manager that runs passes on either a specific operation type...
Definition: PassManager.h:52