[Mlir-commits] [mlir] [mlir][tosa] Enhance the conv2d verifier (PR #128693)
Georgios Pinitas
llvmlistbot at llvm.org
Tue Feb 25 03:28:42 PST 2025
================
@@ -2012,6 +2015,98 @@ LogicalResult Conv2DOp::inferReturnTypeComponents(
LogicalResult Conv2DOp::verify() {
if (verifyConvOp(*this).failed() || verifyConvOpModes(*this).failed())
return failure();
+
+ llvm::ArrayRef<int64_t> padding = getPad();
+ if (llvm::any_of(padding, [](int64_t p) { return p < 0; }))
+ return emitOpError("expect all padding values to be >= 0, got ") << padding;
+
+ llvm::ArrayRef<int64_t> strides = getStride();
+ if (llvm::any_of(strides, [](int64_t s) { return s < 1; }))
+ return emitOpError("expect all stride values to be >= 1, got ") << strides;
+
+ llvm::ArrayRef<int64_t> dilations = getDilation();
+ if (llvm::any_of(dilations, [](int64_t d) { return d < 1; }))
+ return emitOpError("expect all dilation values to be >= 1, got ")
+ << dilations;
+
+ const RankedTensorType outputType =
+ llvm::dyn_cast<RankedTensorType>(getOutput().getType());
+ if (!outputType)
+ // Skip following checks if output is not ranked
+ return success();
+
+ const RankedTensorType inputType =
+ llvm::dyn_cast<RankedTensorType>(getInput().getType());
+ const RankedTensorType weightType =
+ llvm::dyn_cast<RankedTensorType>(getWeight().getType());
+
+ if (inputType && weightType) {
+ const int64_t ih = inputType.getDimSize(1);
----------------
GeorgeARM wrote:
This logic is replicated for W,H. Should we refactor to a common function?
I presume in conv3d verifier this shall be used across 3 dimensions as well?
https://github.com/llvm/llvm-project/pull/128693
More information about the Mlir-commits
mailing list