• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2021 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 #ifndef TENSORFLOW_COMPILER_MLIR_HLO_INCLUDE_MLIR_HLO_DIALECT_MHLO_TRANSFORMS_LHLO_ELEMENTAL_UTILS_H_
17 #define TENSORFLOW_COMPILER_MLIR_HLO_INCLUDE_MLIR_HLO_DIALECT_MHLO_TRANSFORMS_LHLO_ELEMENTAL_UTILS_H_
18 
19 #include "mlir/IR/Builders.h"
20 
21 namespace mlir {
22 
23 class Value;
24 class Location;
25 class Operation;
26 class ValueRange;
27 class Region;
28 class FuncOp;
29 enum class AtomicRMWKind : uint64_t;
30 
31 namespace scf {
32 class ForOp;
33 class ParallelOp;
34 }  // namespace scf
35 
36 namespace memref {
37 class LoadOp;
38 }
39 
40 namespace lmhlo {
41 
42 Value createLoadOrUseCachedValue(Location loc, OpBuilder* b, Value memref,
43                                  ValueRange indices,
44                                  OpBuilder::InsertPoint insert_point);
45 
46 DenseSet<Operation*> NoLoaderUser(SmallVectorImpl<Operation*>& ops);
47 void cleanUnusedLhloOps(Block* parent);
48 
49 template <typename LHLO_OpTy>
50 Value elementalLower(OpBuilder* b, Location loc, LHLO_OpTy op,
51                      ValueRange output_index, bool check_cache = false);
52 
53 scf::ForOp createLoopAndSetInsPt(OpBuilder& b, Location loc, Value& var,
54                                  Value lb, Value ub, Value step,
55                                  ArrayRef<Value> init_values = {});
56 
57 scf::ParallelOp createParallelAndSetInsPt(OpBuilder& b, Location loc,
58                                           SmallVectorImpl<Value>& vars,
59                                           ArrayRef<Value> lbs,
60                                           ArrayRef<Value> ubs,
61                                           ArrayRef<Value> steps,
62                                           ArrayRef<Value> init_values);
63 
64 void createOffsetStore(OpBuilder& b, Location loc, Value res, Value memref,
65                        Value offset);
66 
67 memref::LoadOp createOffsetLoad(OpBuilder& b, Location loc, Value memref,
68                                 Value offset);
69 
70 }  // namespace lmhlo
71 }  // namespace mlir
72 
73 #endif  // TENSORFLOW_COMPILER_MLIR_HLO_INCLUDE_MLIR_HLO_DIALECT_MHLO_TRANSFORMS_LHLO_ELEMENTAL_UTILS_H_
74