[llvm] [mlir] [TOSA] Add Tosa_Shape type and ConstShapeOp (PR #122547)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 08:15:28 PST 2025
================
@@ -2146,13 +2179,104 @@ void WhileOp::print(OpAsmPrinter &parser) {
parser.printOptionalAttrDictWithKeyword((*this)->getAttrs());
}
+//===----------------------------------------------------------------------===//
+// TOSA Shape and Shape Operators Helper functions.
+//===----------------------------------------------------------------------===//
+
+bool mlir::tosa::isa_tosa_shape_type(mlir::Type t) {
+ return mlir::isa<tosa::shapeType>(t);
+}
+
+LogicalResult
+mlir::tosa::shapeType::verify(function_ref<InFlightDiagnostic()> emitError,
+ int rank) {
+ if (rank < 0)
+ return emitError() << "invalid rank (must be >= 0): " << rank;
+ return success();
+}
+
+LogicalResult OpTrait::tosa::verifyTosaResolvableShapeOperands(Operation *op) {
+ for (auto v : op->getOperands()) {
+ if (mlir::isa<::mlir::tosa::shapeType>(v.getType())) {
+ Operation *definingOp = v.getDefiningOp();
+ if (!definingOp || !definingOp->hasTrait<TosaShapeOperator>()) {
+ return op->emitOpError("shape operand is not compile time resolvable");
----------------
Jerry-Ge wrote:
same reason, I will update this in following patches.
https://github.com/llvm/llvm-project/pull/122547
More information about the llvm-commits
mailing list