MLIR: include/mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_ONESHOTANALYSIS_H

10#define MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_ONESHOTANALYSIS_H

11

13#include "llvm/ADT/EquivalenceClasses.h"

14#include

15

16namespace mlir {

18

20

24

25

33

35

36

37

39

40

42

43

44

46

47

48

50

51

52

53

55};

56

57

58

59

60

61

63public:

66

68

70

74

75

78 AnalysisState::getOptions());

79 }

80

81

83

84

86

87

89

90

92

93

95

96

98

99

100

102

103

105

106

107

109

110

111

113

116

117

119

120

122

123

124

126

127

129

130

131

133

134

136

137

139

140

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

170

172

173 public:

174

175

176

178

179 protected:

180

182

183

185

186 private:

187

189 };

190

191

192

193

194

195

196

197 template <typename Ty, typename... Args>

199 static_assert(

200 std::is_base_of<Extension, Ty>::value,

201 "only a class derived from OneShotAnalysisState::Extension is allowed");

202 auto ptr = std::make_unique(*this, std::forward(args)...);

204 assert(result.second && "extension already added");

205 return *static_cast<Ty *>(result.first->second.get());

206 }

207

208

209 template

211 static_assert(

212 std::is_base_of<Extension, Ty>::value,

213 "only a class derived from OneShotAnalysisState::Extension is allowed");

215 if (iter == extensions.end())

216 return nullptr;

217 return static_cast<Ty *>(iter->second.get());

218 }

219

220

221 template

225

226private:

227 using EquivalenceClassRangeType =

229

230 EquivalenceClassRangeType getAliases(Value v) const;

231

232

234

235

237

238

239

240

241

242

243 llvm::EquivalenceClasses aliasInfo;

244

245

246

247

248

249

250

251 llvm::EquivalenceClasses equivalentInfo;

252

253

254 int64_t statNumTensorOutOfPlace = 0;

255 int64_t statNumTensorInPlace = 0;

256

257

259

260

261

263};

264

265

266

268 BufferizationStatistics *statistics = nullptr);

269

270

271LogicalResult

273 BufferizationState &state,

274 BufferizationStatistics *statistics = nullptr);

275

276}

277}

278

280

281#endif

static llvm::ManagedStatic< PassManagerOptions > options

#define MLIR_DECLARE_EXPLICIT_TYPE_ID(CLASS_NAME)

AnalysisState(LatticeAnchor anchor)

Create the analysis state on the given lattice anchor.

A class for computing basic dominance information.

This class represents an operand of an operation.

Operation is the basic unit of execution within MLIR.

static TypeID get()

Construct a type info object for the given type T.

This class represents an instance of an SSA value in the MLIR system, representing a computable value...

virtual ~Extension()

Base virtual destructor.

friend class OneShotAnalysisState

Definition OneShotAnalysis.h:171

Extension(OneShotAnalysisState &state)

Constructs an extension of the given state object.

Definition OneShotAnalysis.h:181

const OneShotAnalysisState & getAnalysisState() const

Provides read-only access to the parent OneShotAnalysisState object.

Definition OneShotAnalysis.h:184

State for analysis-enabled bufferization.

Definition OneShotAnalysis.h:62

void bufferizeOutOfPlace(OpOperand &operand)

Mark the given OpOperand as out-of-place.

bool isWritable(Value value) const

Return true if the buffer of the given tensor value is writable.

~OneShotAnalysisState() override=default

const SetVector< Value > & findDefinitionsCached(OpOperand *opOperand)

Find the definitions of the given operand's value or retrieve them from the cache.

bool isInPlace(OpOperand &opOperand) const override

Return true if the given OpResult has been decided to bufferize inplace.

LogicalResult analyzeOp(Operation *op, const DominanceInfo &domInfo)

Analyze the given op and its nested ops.

bool isValueWritten(Value value) const

Return true if the buffer of the given tensor value is written to.

void unionEquivalenceClasses(Value v1, Value v2)

Union the equivalence classes of v1 and v2.

OneShotAnalysisState(const OneShotAnalysisState &)=delete

void gatherUndefinedTensorUses(Operation *op)

Find all tensor values in the given operation that have undefined contents and store them in undefine...

void resetCache() override

Reset cached data structures.

Ty & addExtension(Args &&...args)

Adds a new Extension of the type specified as template parameter, constructing it with the arguments ...

Definition OneShotAnalysis.h:198

const OneShotBufferizationOptions & getOptions() const

Return a reference to the BufferizationOptions.

Definition OneShotAnalysis.h:76

Ty * getExtension()

Returns the extension of the specified type.

Definition OneShotAnalysis.h:210

LogicalResult analyzeSingleOp(Operation *op, const DominanceInfo &domInfo)

Analyze a single op (without nested ops).

const Ty * getExtension() const

Returns the extension of the specified type.

Definition OneShotAnalysis.h:222

void applyOnEquivalenceClass(Value v, function_ref< void(Value)> fun) const

Apply fun to all the members of the equivalence class of v.

int64_t getStatNumTensorOutOfPlace() const

Definition OneShotAnalysis.h:114

bool hasUndefinedContents(OpOperand *opOperand) const override

Return true if the given tensor has undefined contents.

static bool classof(const AnalysisState *base)

Definition OneShotAnalysis.h:71

void bufferizeInPlace(OpOperand &operand)

Mark the given OpOperand as in-place and merge the results' and operand's aliasing sets.

void applyOnAliases(Value v, function_ref< void(Value)> fun) const

Apply fun to all aliases of v.

bool areEquivalentBufferizedValues(Value v1, Value v2) const override

Return true if v1 and v2 bufferize to equivalent buffers.

OneShotAnalysisState(Operation *op, const OneShotBufferizationOptions &options)

bool areAliasingBufferizedValues(Value v1, Value v2) const override

Return true if v1 and v2 may bufferize to aliasing buffers.

void unionAliasSets(Value v1, Value v2)

Union the alias sets of v1 and v2.

void createAliasInfoEntry(Value v)

Add a new entry for v in the aliasInfo and equivalentInfo.

int64_t getStatNumTensorInPlace() const

Definition OneShotAnalysis.h:115

LogicalResult analyzeOp(Operation *op, OneShotAnalysisState &state, BufferizationStatistics *statistics=nullptr)

Analyze op and its nested ops.

LogicalResult runOneShotBufferize(Operation *op, const OneShotBufferizationOptions &options, BufferizationState &state, BufferizationStatistics *statistics=nullptr)

Run One-Shot Bufferize on the given op: Analysis + Bufferization.

Include the generated interface declarations.

llvm::DenseSet< ValueT, ValueInfoT > DenseSet

llvm::SetVector< T, Vector, Set, N > SetVector

llvm::DenseMap< KeyT, ValueT, KeyInfoT, BucketT > DenseMap

llvm::function_ref< Fn > function_ref

Bufferization statistics for debugging.

Options for analysis-enabled bufferization.

Definition OneShotAnalysis.h:26

unsigned analysisFuzzerSeed

Seed for the analysis fuzzer.

Definition OneShotAnalysis.h:54

bool dumpAliasSets

Specifies whether the tensor IR should be annotated with alias sets.

Definition OneShotAnalysis.h:41

OneShotBufferizationOptions()=default

bool allowReturnAllocsFromLoops

Specifies whether returning newly allocated memrefs from loops should be allowed.

Definition OneShotAnalysis.h:38

AnalysisHeuristic analysisHeuristic

The heuristic controls the order in which ops are traversed during the analysis.

Definition OneShotAnalysis.h:45

AnalysisHeuristic

Definition OneShotAnalysis.h:27

@ Fuzzer

Definition OneShotAnalysis.h:31

@ BottomUpFromTerminators

Definition OneShotAnalysis.h:30

@ TopDown

Definition OneShotAnalysis.h:29

@ BottomUp

Definition OneShotAnalysis.h:28

llvm::ArrayRef< std::string > noAnalysisFuncFilter

Specify the functions that should not be analyzed.

Definition OneShotAnalysis.h:49