[Mlir-commits] [mlir] [mlir][spirv] Add Conv operations for TOSA Extended Instruction Set (001000.1) (PR #176908)
Jakub Kuderski
llvmlistbot at llvm.org
Thu Jan 22 07:06:15 PST 2026
================
@@ -46,4 +99,82 @@ LogicalResult TosaArgMaxOp::verify() {
return success();
}
+//===----------------------------------------------------------------------===//
+// spirv.TosaConv2DOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult TosaConv2DOp::verify() {
+ Type inputETy = getInputType().getElementType();
+ Type resultETy = getResultType().getElementType();
+ TosaExtAccType accType = getAccType();
+ return verifyConvOp(this->getOperation(), inputETy, resultETy, accType);
+}
+
+//===----------------------------------------------------------------------===//
+// spirv.TosaConv3DOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult TosaConv3DOp::verify() {
+ Type inputETy = getInputType().getElementType();
+ Type resultETy = getResultType().getElementType();
+ TosaExtAccType accType = getAccType();
+ return verifyConvOp(this->getOperation(), inputETy, resultETy, accType);
+}
+
+//===----------------------------------------------------------------------===//
+// SPIRV Tosa DepthwiseConv2D Ops:
+//===----------------------------------------------------------------------===//
+
+LogicalResult TosaDepthwiseConv2DOp::verify() {
+ Type inputETy = getInputType().getElementType();
+ Type resultETy = getResultType().getElementType();
+ TosaExtAccType accType = getAccType();
+ return verifyConvOp(this->getOperation(), inputETy, resultETy, accType);
+}
+
+//===----------------------------------------------------------------------===//
+// SPIRV Tosa TransposeConv2D Ops:
+//===----------------------------------------------------------------------===//
+
+LogicalResult TosaTransposeConv2DOp::verify() {
+ Type inputETy = getInputType().getElementType();
+ Type resultETy = getResultType().getElementType();
+ TosaExtAccType accType = getAccType();
+ return verifyConvOp(this->getOperation(), inputETy, resultETy, accType);
+}
+
+//===----------------------------------------------------------------------===//
+// SPIRV Tosa Custom formatters
+//===----------------------------------------------------------------------===//
+
+ParseResult parseSPIRV_I32_1DArmTensor(OpAsmParser &parser,
+ DenseIntElementsAttr &attr) {
+ SmallVector<int32_t, 6> elements;
+ auto f = [&]() {
+ int32_t value;
+ ParseResult r = parser.parseInteger(value);
+ elements.push_back(value);
+ return r;
+ };
+ if (parser.parseCommaSeparatedList(
+ OpAsmParser::Delimiter::Square, f,
+ "parsing values in integer list attribute")) {
+ return failure();
+ }
+
+ auto i32Type = IntegerType::get(parser.getContext(), 32);
+ auto type = TensorArmType::get(
+ ArrayRef{static_cast<int64_t>(elements.size())}, i32Type);
+ attr = DenseIntElementsAttr::get(type, elements);
+ return success();
+}
+
+void printSPIRV_I32_1DArmTensor(OpAsmPrinter &printer, Operation *,
+ DenseIntElementsAttr attr) {
+
+ printer << llvm::interleaved_array(
----------------
kuhar wrote:
nit: superfluous empty line
```suggestion
DenseIntElementsAttr attr) {
printer << llvm::interleaved_array(
```
https://github.com/llvm/llvm-project/pull/176908
More information about the Mlir-commits
mailing list