[Mlir-commits] [mlir] [TOSA] Add StatefulOps to TOSA Dialect (PR #66843)

Mehdi Amini llvmlistbot at llvm.org
Tue Sep 19 22:43:40 PDT 2023


================
@@ -427,6 +437,83 @@ LogicalResult TosaValidation::applyLevelCheck(Operation *op) {
   return success();
 }
 
+inline bool CompatibleTypes(const mlir::Type &type,
+                            const mlir::Type &declared_type) {
+  // for now, simply use type equality comparison
+  return type == declared_type;
+}
+
+bool TosaValidation::CheckVariable(Operation *op) {
+  if (isa<mlir::tosa::VariableOp>(op)) {
+    auto name_attr = dyn_cast<mlir::StringAttr>(op->getAttr("name"));
+    if (!name_attr) {
+      op->emitOpError() << "Name attribute is not StringAttr";
+      return false;
+    }
+    std::string name = name_attr.getValue().str();
+
+    if (variables_map.count(name)) {
+      op->emitOpError() << "name has already been declared";
+      return false;
+    }
+
+    auto type_attr = dyn_cast<mlir::TypeAttr>(op->getAttr("type"));
+    if (!type_attr) {
+      op->emitOpError() << "type attribute is not TypeAttr";
+      return false;
+    }
----------------
joker-eph wrote:

Same as above: this should be dead code (maybe I missed something, in which case: can you add a test please?)

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


More information about the Mlir-commits mailing list