[Mlir-commits] [mlir] [mlir][spirv] Split codegen for float min/max reductions and others (NFC) (PR #69023)
Jakub Kuderski
llvmlistbot at llvm.org
Sat Oct 14 16:04:35 PDT 2023
================
@@ -381,9 +393,26 @@ struct VectorReductionPattern final
if (Value acc = adaptor.getAcc())
values.push_back(acc);
- // Reduce them.
- Value result = values.front();
- for (Value next : llvm::ArrayRef(values).drop_front()) {
+ return values;
+ }
+};
+
+#define VECTOR_REDUCTION_BASE \
+ VectorReductionPatternBase<VectorReductionPattern<SPIRVUMaxOp, SPIRVUMinOp, \
+ SPIRVSMaxOp, SPIRVSMinOp>>
----------------
kuhar wrote:
How about something like this:
```c++
template <typename... Args>
struct VectorReductionPattern;
typename <typename... Args>
using CrtpBase = VectorReductionPatternBase<VectorReductionPattern, Args...>;
template <typename... Args>
struct VectorReductionPattern final : CrtpBase<Args...> {
using Base = CrtpBase<Args...>;
using Base::Base;
// define SPIRVUMaxOp et al. in VectorReductionPatternBase
...
};
```
just an idea, I haven't tried to compile this
https://github.com/llvm/llvm-project/pull/69023
More information about the Mlir-commits
mailing list