[Mlir-commits] [mlir] 236aab0 - [MLIR] Delete unused functions getCollapsedInitTensor and getExpandedInitTensor
Geoffrey Martin-Noble
llvmlistbot at llvm.org
Fri Feb 19 09:24:05 PST 2021
Author: Geoffrey Martin-Noble
Date: 2021-02-19T09:23:54-08:00
New Revision: 236aab0b0c9c0c98bec7175072721fc15e247231
URL: https://github.com/llvm/llvm-project/commit/236aab0b0c9c0c98bec7175072721fc15e247231
DIFF: https://github.com/llvm/llvm-project/commit/236aab0b0c9c0c98bec7175072721fc15e247231.diff
LOG: [MLIR] Delete unused functions getCollapsedInitTensor and getExpandedInitTensor
These are unused since
https://reviews.llvm.org/rG81264dfbe80df08668a325a61613b64243b99c01
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D97014
Added:
Modified:
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index b176f584f921..a5a9c76ff0f6 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -605,95 +605,6 @@ Type InitTensorOp::inferResultType(ArrayRef<int64_t> staticSizes,
return RankedTensorType::get(staticSizes, elementType);
}
-static Value getCollapsedInitTensor(OpBuilder &builder,
- TensorReshapeOp reshapeOp) {
- Location loc = reshapeOp.getLoc();
- SmallVector<Value, 4> dynamicShapes;
- SmallVector<int64_t, 4> staticShapes;
- auto reassociation = reshapeOp.getReassociationMaps();
- Value src = reshapeOp.src();
- RankedTensorType srcType = reshapeOp.getSrcType();
- ArrayRef<int64_t> srcShape = srcType.getShape();
- for (auto map : reassociation) {
- Value linearizedDynamicDim = nullptr;
- int64_t linearizedStaticDim = 1;
- for (unsigned i : llvm::map_range(map.getResults(), [](AffineExpr e) {
- return e.cast<AffineDimExpr>().getPosition();
- })) {
- if (ShapedType::isDynamic(srcShape[i])) {
- Value shapeVal = builder.create<DimOp>(loc, src, i);
- if (linearizedDynamicDim) {
- linearizedDynamicDim =
- builder.create<MulIOp>(loc, linearizedDynamicDim, shapeVal);
- } else {
- linearizedDynamicDim = shapeVal;
- }
- } else {
- linearizedStaticDim *= srcShape[i];
- }
- }
- if (linearizedDynamicDim) {
- if (linearizedStaticDim != 1) {
- linearizedDynamicDim = builder.create<MulIOp>(
- loc, linearizedDynamicDim,
- builder.create<ConstantIndexOp>(loc, linearizedStaticDim));
- }
- dynamicShapes.push_back(linearizedDynamicDim);
- staticShapes.push_back(ShapedType::kDynamicSize);
- } else {
- staticShapes.push_back(linearizedStaticDim);
- }
- }
- return builder.create<InitTensorOp>(loc, dynamicShapes, staticShapes,
- srcType.getElementType());
-}
-
-static Value getExpandedInitTensor(OpBuilder &builder,
- TensorReshapeOp reshapeOp) {
- SmallVector<Value, 4> dynamicShapes;
- SmallVector<int64_t, 4> staticShapes;
- auto reassociation = reshapeOp.getReassociationMaps();
- Value src = reshapeOp.src();
- RankedTensorType srcType = reshapeOp.getSrcType();
- ArrayRef<int64_t> srcShape = srcType.getShape();
- ArrayRef<int64_t> dstShape = reshapeOp.getResultType().getShape();
- Location loc = reshapeOp.getLoc();
- for (auto map : enumerate(reassociation)) {
- int64_t linearizedStaticDim = 1;
- bool hasDynamic = false;
- for (unsigned i :
- llvm::map_range(map.value().getResults(), [](AffineExpr e) {
- return e.cast<AffineDimExpr>().getPosition();
- })) {
- if (ShapedType::isDynamic(dstShape[i])) {
- // Only one of the dimensions of the expanded shape should be dynamic.
- if (hasDynamic)
- return nullptr;
- hasDynamic = true;
- staticShapes.push_back(ShapedType::kDynamicSize);
- continue;
- }
- staticShapes.push_back(dstShape[i]);
- linearizedStaticDim *= dstShape[i];
- }
- if (hasDynamic) {
- // If the expanded dimensions has a dynamic shape, the src shape must be
- // dynamic as well.
- if (!ShapedType::isDynamic(srcShape[map.index()]))
- return nullptr;
- Value dynamicDim = builder.create<DimOp>(loc, src, map.index());
- if (linearizedStaticDim != 1) {
- dynamicDim = builder.create<UnsignedDivIOp>(
- loc, dynamicDim,
- builder.create<ConstantIndexOp>(loc, linearizedStaticDim));
- }
- dynamicShapes.push_back(dynamicDim);
- }
- }
- return builder.create<InitTensorOp>(loc, dynamicShapes, staticShapes,
- srcType.getElementType());
-}
-
namespace {
/// Change the type of the result of a `linalg.init_tensor` by making the result
/// type statically sized along dimension that in the original operation where
More information about the Mlir-commits
mailing list