• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 // This file defines the operations used in the LMHLO GPU dialect.
17 
18 #include "mlir-hlo/Dialect/mhlo/IR/lhlo_gpu_ops.h"
19 
20 #include <assert.h>
21 #include <stddef.h>
22 #include <stdint.h>
23 
24 #include "llvm/ADT/APFloat.h"
25 #include "llvm/ADT/APInt.h"
26 #include "llvm/ADT/ArrayRef.h"
27 #include "llvm/ADT/STLExtras.h"
28 #include "llvm/ADT/SmallVector.h"
29 #include "llvm/ADT/StringRef.h"
30 #include "llvm/Support/FormatVariadic.h"
31 #include "mlir-hlo/Dialect/mhlo/IR/hlo_ops.h"
32 #include "mlir-hlo/Dialect/mhlo/IR/hlo_ops_common.h"
33 #include "mlir-hlo/utils/lhlo_utils.h"
34 #include "mlir/Dialect/StandardOps/IR/Ops.h"
35 #include "mlir/IR/Attributes.h"
36 #include "mlir/IR/Builders.h"
37 #include "mlir/IR/BuiltinTypes.h"
38 #include "mlir/IR/Dialect.h"
39 #include "mlir/IR/Location.h"
40 #include "mlir/IR/MLIRContext.h"
41 #include "mlir/IR/OpDefinition.h"
42 #include "mlir/IR/OpImplementation.h"
43 #include "mlir/IR/Operation.h"
44 #include "mlir/IR/OperationSupport.h"
45 #include "mlir/IR/PatternMatch.h"
46 #include "mlir/IR/TypeUtilities.h"
47 #include "mlir/IR/Types.h"
48 #include "mlir/IR/Value.h"
49 
50 namespace mlir {
51 namespace lmhlo_gpu {
52 
53 using mhlo::TokenType;
54 
LmhloGpuDialect(MLIRContext * context)55 LmhloGpuDialect::LmhloGpuDialect(MLIRContext *context)
56     : Dialect(getDialectNamespace(), context, TypeID::get<LmhloGpuDialect>()) {
57   addOperations<
58 #define GET_OP_LIST
59 #include "mlir-hlo/Dialect/mhlo/IR/lhlo_gpu_ops.cc.inc"
60       >();
61 }
62 
63 // TODO(jurahul): Add verification for operand shapes and ranks.
64 
65 using mlir::hlo::parseWindowAttributes;
66 using mlir::hlo::printWindowAttributes;
67 
68 //===----------------------------------------------------------------------===//
69 // AllReduceStartOp
70 //===----------------------------------------------------------------------===//
71 
Verify(AllReduceStartOp op)72 static LogicalResult Verify(AllReduceStartOp op) {
73   return lmhlo::VerifyAllReduce(op);
74 }
75 
76 }  // namespace lmhlo_gpu
77 }  // namespace mlir
78 
79 #define GET_OP_CLASSES
80 #include "mlir-hlo/Dialect/mhlo/IR/lhlo_gpu_ops.cc.inc"
81