MLIR  19.0.0git
Utils.cpp
Go to the documentation of this file.
1 //===- Utils.cpp - GPU transforms utils -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implements GPU dialect transforms utils.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/Support/ErrorHandling.h"
15 
16 namespace mlir::gpu {
17 
18 vector::CombiningKind convertReductionKind(gpu::AllReduceOperation mode) {
19  switch (mode) {
20 #define MAP_CASE(X) \
21  case gpu::AllReduceOperation::X: \
22  return vector::CombiningKind::X
23 
24  MAP_CASE(ADD);
25  MAP_CASE(MUL);
26  MAP_CASE(MINUI);
27  MAP_CASE(MINSI);
28  MAP_CASE(MINNUMF);
29  MAP_CASE(MAXSI);
30  MAP_CASE(MAXUI);
31  MAP_CASE(MAXNUMF);
32  MAP_CASE(AND);
33  MAP_CASE(OR);
34  MAP_CASE(XOR);
35  MAP_CASE(MINIMUMF);
36  MAP_CASE(MAXIMUMF);
37 
38 #undef MAP_CASE
39  }
40 
41  llvm_unreachable("Vector and GPU reduction kinds should match 1:1");
42 }
43 
44 } // namespace mlir::gpu
#define MAP_CASE(X)
#define MINUI(lhs, rhs)
vector::CombiningKind convertReductionKind(gpu::AllReduceOperation mode)
Returns the matching vector combining kind.
Definition: Utils.cpp:18