MLIR  19.0.0git
ShapeMappingAnalysis.h
Go to the documentation of this file.
1 //===- ShapeMappingAnalysis.h - Preserve shape Info ------------*- 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 #ifndef MLIR_DIALECT_SHAPE_ANALYSIS_SHAPEMAPPINGANALYSIS_H_
10 #define MLIR_DIALECT_SHAPE_ANALYSIS_SHAPEMAPPINGANALYSIS_H_
11 
13 #include "mlir/IR/Value.h"
14 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/ADT/SmallVector.h"
17 
18 namespace mlir {
19 
20 namespace shape {
21 
22 /// ShapeMappingValue works as the value of ShapeMappingAnalysis table, where
23 /// `funcSymbol` is the symbol of mapping function, and `inputs` are the actual
24 /// parameters for the function.
26  ShapeMappingValue() = default;
28  : funcSymbol(symbol), inputs(inps) {}
29 
32 };
33 
34 /// ShapeMappingAnalysis is used together with OutlineShapeComputationPass to
35 /// preserve Value and corresponding shape function / arguments mapping
36 /// information
38  ShapeMappingAnalysis(Operation *op) : operation(op) { (void)operation; }
39 
40  /// Dumps the shape mapping information to the given stream.
41  void print(raw_ostream &os) const {
42  os << "// ---- Shape Mapping Information -----\n";
43  for (const auto &it : shapeMapping) {
44  const ShapeMappingValue &mappingValue = it.second;
45  os << "// Shape for " << it.first << " :: " << mappingValue.funcSymbol;
46  llvm::interleaveComma(mappingValue.inputs, os << "(");
47  os << ")\n";
48  }
49  }
50 
52 
53 private:
54  Operation *operation;
55 };
56 
57 } // namespace shape
58 } // namespace mlir
59 
60 #endif // MLIR_DIALECT_SHAPE_ANALYSIS_SHAPEMAPPINGANALYSIS_H_
A symbol reference with a reference path containing a single element.
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
Include the generated interface declarations.
ShapeMappingAnalysis is used together with OutlineShapeComputationPass to preserve Value and correspo...
llvm::DenseMap< Value, ShapeMappingValue > shapeMapping
void print(raw_ostream &os) const
Dumps the shape mapping information to the given stream.
ShapeMappingValue works as the value of ShapeMappingAnalysis table, where funcSymbol is the symbol of...
ShapeMappingValue(FlatSymbolRefAttr symbol, llvm::SmallVector< Value > &&inps)
llvm::SmallVector< Value > inputs