1 #ifndef MLIR_HLO_UTILS_CODEGEN_UTILS_H 2 #define MLIR_HLO_UTILS_CODEGEN_UTILS_H 3 4 /* Copyright 2021 The TensorFlow Authors. All Rights Reserved. 5 6 Licensed under the Apache License, Version 2.0 (the "License"); 7 you may not use this file except in compliance with the License. 8 You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 See the License for the specific language governing permissions and 16 limitations under the License. 17 ==============================================================================*/ 18 19 #include "llvm/ADT/SmallVector.h" 20 #include "llvm/ADT/StringRef.h" 21 #include "mlir/Dialect/LLVMIR/LLVMDialect.h" 22 #include "mlir/IR/MLIRContext.h" // TF:llvm-project 23 24 #ifndef TENSORFLOW_COMPILER_MLIR_HLO_INCLUDE_MLIR_HLO_UTILS_CODEGEN_UTILS_H_ 25 #define TENSORFLOW_COMPILER_MLIR_HLO_INCLUDE_MLIR_HLO_UTILS_CODEGEN_UTILS_H_ 26 27 namespace mlir { 28 class Value; 29 class ValueRange; 30 class OpBuilder; 31 class Location; 32 class Operation; 33 namespace codegen_utils { 34 35 Value emitNumElementsComputation(OpBuilder& b, Location loc, Operation* op); 36 Value emitNumElementsComputation(OpBuilder& b, Location loc, Value memref); 37 38 llvm::SmallVector<Value> calcMultiDimIndex(OpBuilder& b, Location loc, 39 Value linearIndex, Value memref); 40 41 llvm::SmallVector<Value> calcMultiDimIndex(OpBuilder& b, Location loc, 42 Value linearIndex, 43 llvm::ArrayRef<Value> shape); 44 45 } // namespace codegen_utils 46 } // namespace mlir 47 48 #endif // TENSORFLOW_COMPILER_MLIR_HLO_INCLUDE_MLIR_HLO_UTILS_CODEGEN_UTILS_H_ 49 50 #endif 51