[Mlir-commits] [mlir] [mlir][tosa][tosa-to-linalg] Add NaN Mode Lowering (PR #125668)

Jack Frankland llvmlistbot at llvm.org
Wed Feb 19 02:31:06 PST 2025


================
@@ -267,6 +267,26 @@ extractConvZpPair(TosaConvOp op, PatternRewriter &rewriter) {
 
   return std::make_optional<ConvZpPair>(*maybeInputZp, *maybeWeightZp);
 }
+
+// Helper function to extract the NaN propagation mode from an operation.
+// Note that the for operations which support NaN mode propagation the attribute
+// is optional and its default value is "PROPAGATE".
+//
+// If the function is called with an operator that doesn't support the NaN mode
+// attribute it will return a std::nullopt.
+inline std::optional<std::string> getNanMode(Operation *op,
+                                             PatternRewriter &rewriter) {
+  if (isa<tosa::ClampOp>(op) || isa<tosa::MaxPool2dOp>(op) ||
----------------
FranklandJack wrote:

Okay sure, but right now this is used to check the precondition of this function that is; does `op` support a NaN mode attribute.

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


More information about the Mlir-commits mailing list