Files
clang-p2996/mlir/test/lib/Dialect/Shape/TestShapeMappingAnalysis.cpp
Yuanqiang Liu 9f77909a5e [mlir][shape] add outline-shape-computation pass
Add outline-shape-computation pass. This pass his pass outlines the
shape computation part in high level IR by adding shape.func and
populate corresponding mapping information into ShapeMappingAnalysis.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D131810
2022-10-02 20:24:49 -07:00

44 lines
1.4 KiB
C++

//===- TestShapeMappingInfo.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Shape/Analysis/ShapeMappingAnalysis.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/Pass/Pass.h"
using namespace mlir;
namespace {
struct TestShapeMappingPass
: public PassWrapper<TestShapeMappingPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestShapeMappingPass)
StringRef getArgument() const final { return "test-print-shape-mapping"; }
StringRef getDescription() const final {
return "Print the contents of a constructed shape mapping information.";
}
void runOnOperation() override {
llvm::Optional<std::reference_wrapper<shape::ShapeMappingAnalysis>>
maybeAnalysis = getCachedAnalysis<shape::ShapeMappingAnalysis>();
if (maybeAnalysis.has_value())
maybeAnalysis.value().get().print(llvm::errs());
else
llvm::errs() << "No cached ShapeMappingAnalysis existed.";
}
};
} // namespace
namespace mlir {
namespace test {
void registerTestShapeMappingPass() {
PassRegistration<TestShapeMappingPass>();
}
} // namespace test
} // namespace mlir