You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by tq...@apache.org on 2020/04/24 15:57:05 UTC
[incubator-tvm] branch master updated: misc fixes for ROCm (pointer
lifetime, runtime::String refactor) (#5431)
This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git
The following commit(s) were added to refs/heads/master by this push:
new 9a989e5 misc fixes for ROCm (pointer lifetime, runtime::String refactor) (#5431)
9a989e5 is described below
commit 9a989e57e12d38b4fe58ab22e89506f27ad5d76c
Author: Thomas Viehmann <tv...@beamnet.de>
AuthorDate: Fri Apr 24 17:56:52 2020 +0200
misc fixes for ROCm (pointer lifetime, runtime::String refactor) (#5431)
---
src/target/llvm/codegen_amdgpu.cc | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/target/llvm/codegen_amdgpu.cc b/src/target/llvm/codegen_amdgpu.cc
index 61121f6..8935809 100644
--- a/src/target/llvm/codegen_amdgpu.cc
+++ b/src/target/llvm/codegen_amdgpu.cc
@@ -219,8 +219,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) {
<< " -mattr=-code-object-v3 "
<< target.substr(4, target.length() - 4);
std::unique_ptr<llvm::TargetMachine> tm = GetLLVMTargetMachine(config.str());
- std::unique_ptr<CodeGenAMDGPU> cg(new CodeGenAMDGPU());
std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext());
+ // careful: cg will hold a naked pointer reference to ctx, so it should
+ // have a shorter lifetime than the ctx.
+ std::unique_ptr<CodeGenAMDGPU> cg(new CodeGenAMDGPU());
cg->Init("TVMAMDGPUModule", tm.get(), ctx.get(), false, false);
@@ -233,10 +235,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) {
const auto *find_rocm_bitcodes =
tvm::runtime::Registry::Get("tvm_callback_rocm_bitcode_path");
- Array<PrimExpr> bitcode_files = (*find_rocm_bitcodes)();
+ Array<runtime::String> bitcode_files = (*find_rocm_bitcodes)();
- for (auto &bitcode : bitcode_files) {
- std::string path = bitcode.as<StringImmNode>()->value;
+ for (auto &bitcode_path : bitcode_files) {
+ std::string path = bitcode_path;
llvm::SMDiagnostic err;
std::unique_ptr<llvm::Module> mlib = llvm::parseIRFile(path, err, *ctx);
if (mlib.get() == nullptr) {