[llvm] [mlir] [TOSA] Add Tosa_Shape type and ConstShapeOp (PR #122547)

Georgios Pinitas via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 05:23:27 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");
----------------
GeorgeARM wrote:

Just to avoid forgetting comments/request can we address them in their relevant patches so that there is also consistency in case something needs to be changed/reverted?

https://github.com/llvm/llvm-project/pull/122547


More information about the llvm-commits mailing list