1 /* Copyright 2022 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 XLA_MLIR_UTILS_RUNTIME_C_RUNNER_UTILS_H_ 17 #define XLA_MLIR_UTILS_RUNTIME_C_RUNNER_UTILS_H_ 18 19 #include "llvm/ExecutionEngine/Orc/Core.h" 20 #include "llvm/ExecutionEngine/Orc/Mangling.h" 21 #include "mlir/ExecutionEngine/CRunnerUtils.h" // from @llvm-project 22 23 namespace xla { 24 namespace runtime { 25 CRunnerUtilsSymbolMap(llvm::orc::MangleAndInterner mangle)26inline llvm::orc::SymbolMap CRunnerUtilsSymbolMap( 27 llvm::orc::MangleAndInterner mangle) { 28 llvm::orc::SymbolMap symbol_map; 29 30 auto bind = [&](llvm::StringRef name, auto symbol_ptr) { 31 symbol_map[mangle(name)] = llvm::JITEvaluatedSymbol( 32 llvm::pointerToJITTargetAddress(symbol_ptr), llvm::JITSymbolFlags()); 33 }; 34 35 bind("memrefCopy", &memrefCopy); 36 37 return symbol_map; 38 } 39 40 } // namespace runtime 41 } // namespace xla 42 43 #endif // XLA_MLIR_UTILS_RUNTIME_C_RUNNER_UTILS_H_ 44