MLIR 22.0.0git
Utils.cpp File Reference
#include "mlir/Dialect/Func/Utils/Utils.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/PatternMatch.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/DebugLog.h"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "func-utils"

Functions

static llvm::SmallVector< llvm::SmallVector< int > > getInverseMapping (ArrayRef< int > oldIdxToNewIdx)
 This method creates an inverse mapping of the provided map oldToNew.
template<typename Element>
static SmallVector< Element > getMappedElements (ArrayRef< Element > origElements, const llvm::SmallVector< llvm::SmallVector< int > > &newIdxToOldIdxs)
 This method returns a new vector of elements that are mapped from the origElements based on the newIdxToOldIdxs mapping.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "func-utils"

Definition at line 21 of file Utils.cpp.

Function Documentation

◆ getInverseMapping()

llvm::SmallVector< llvm::SmallVector< int > > getInverseMapping ( ArrayRef< int > oldIdxToNewIdx)
static

This method creates an inverse mapping of the provided map oldToNew.

Given an array where oldIdxToNewIdx[i] = j means old index i maps to new index j, This method returns a vector where result[j] contains all old indices that map to new index j.

Example:

oldIdxToNewIdx = [0, 1, 2, 2, 3]
getInverseMapping(oldIdxToNewIdx) = [[0], [1], [2, 3], [4]]
static llvm::SmallVector< llvm::SmallVector< int > > getInverseMapping(ArrayRef< int > oldIdxToNewIdx)
This method creates an inverse mapping of the provided map oldToNew.
Definition Utils.cpp:38

Definition at line 38 of file Utils.cpp.

◆ getMappedElements()

template<typename Element>
SmallVector< Element > getMappedElements ( ArrayRef< Element > origElements,
const llvm::SmallVector< llvm::SmallVector< int > > & newIdxToOldIdxs )
static

This method returns a new vector of elements that are mapped from the origElements based on the newIdxToOldIdxs mapping.

This function assumes that the newIdxToOldIdxs mapping is valid, i.e. for each new index, there is at least one old index that maps to it. Also, It assumes that mapping to the same old index has the same element in the origElements vector.

Definition at line 54 of file Utils.cpp.