[Mlir-commits] [mlir] [TOSA] Change PadOp padding to tosa.shape (PR #123133)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jan 16 09:58:00 PST 2025
================
@@ -210,6 +210,27 @@ void mlir::tosa::printTypeOrAttr(OpAsmPrinter &p, Operation *op, TypeAttr type,
}
}
+//===----------------------------------------------------------------------===//
+// TOSA shape inference helper
+//===----------------------------------------------------------------------===//
+bool mlir::tosa::collectShapeValue(Operation *op,
+ llvm::SmallVector<int64_t> &newShape) {
+ if (!op) {
+ return false;
+ }
+ if (auto constOp = mlir::dyn_cast<tosa::ConstShapeOp>(op)) {
+ Attribute constOpAttr = constOp->getAttr("value");
+ DenseElementsAttr elementsAttr = cast<DenseElementsAttr>(constOpAttr);
+ for (int i = 0; i < elementsAttr.size(); i++) {
+ int64_t val = elementsAttr.getValues<int64_t>()[i];
+ newShape.push_back(val);
+ }
+ return true;
+ }
+ // for undefined op, return false.
+ return false;
----------------
Jerry-Ge wrote:
Ok, I will ignore this to make sure it's align with our internal version.
https://github.com/llvm/llvm-project/pull/123133
More information about the Mlir-commits
mailing list