Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/target/parsers/cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ namespace parsers {
namespace cpu {

Optional<String> DetectSystemTriple() {
#ifdef TVM_LLVM_VERSION
auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
if (pf->defined()) {
return (*pf)();
}
ICHECK(pf != nullptr) << "The target llvm_get_system_triple was not found, "
"please compile with USE_LLVM = ON";
return (*pf)();
#endif
return {};
}

Expand Down
35 changes: 20 additions & 15 deletions tests/cpp/target_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ TEST(TargetCreation, ProcessStrings) {
ASSERT_EQ(array7[1][1][0], "fred");
}

#ifdef TVM_LLVM_VERSION
// Checks that malformed options cause an assertion.
TEST(TargetCreation, LLVMCommandLineParseFatalDashDashDash) {
tvm::codegen::LLVMInstance inst;
Expand Down Expand Up @@ -448,6 +449,25 @@ TEST(TargetCreation, LLVMCommandLineSaveRestore) {
ASSERT_FALSE(info.MatchesGlobalState());
}

TEST(TargetCreation, DetectSystemTriple) {
Map<String, ObjectRef> config = {
{"kind", String("llvm")},
};

Target target = Target(config);
ICHECK_EQ(target->kind, TargetKind::Get("llvm").value());

auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
if (pf == nullptr) {
GTEST_SKIP() << "LLVM is not available, skipping test";
}

Optional<String> mtriple = target->GetAttr<String>("mtriple");
ASSERT_TRUE(mtriple.value() == String((*pf)()));
}

#endif

TVM_REGISTER_TARGET_KIND("test_external_codegen_0", kDLCUDA)
.set_attr<Bool>(tvm::attr::kIsExternalCodegen, Bool(true));

Expand Down Expand Up @@ -498,21 +518,6 @@ TEST(TargetCreation, DeduplicateKeys) {
ICHECK_EQ(target->GetAttr<String>("device"), "arm_cpu");
}

TEST(TargetCreation, DetectSystemTriple) {
Map<String, ObjectRef> config = {
{"kind", String("llvm")},
};

Target target = Target(config);
ICHECK_EQ(target->kind, TargetKind::Get("llvm").value());

Optional<String> mtriple = target->GetAttr<String>("mtriple");
auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
if (!pf->defined()) {
GTEST_SKIP() << "LLVM is not available, skipping test";
}
}

TEST(TargetKindRegistry, ListTargetKinds) {
Array<String> names = TargetKindRegEntry::ListTargetKinds();
ICHECK_EQ(names.empty(), false);
Expand Down
5 changes: 4 additions & 1 deletion tests/cpp/tir_scalable_datatype.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <llvm/IR/Intrinsics.h>
#include <tvm/runtime/data_type.h>
#include <tvm/tir/builtin.h>
#include <tvm/tir/expr.h>

#ifdef TVM_LLVM_VERSION
#include <llvm/IR/Intrinsics.h>
#endif

#include "../../src/script/printer/utils.h"

using ::testing::HasSubstr;
Expand Down