Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 7 additions & 4 deletions src/target/target.cc
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,8 @@ ObjectPtr<Object> TargetInternal::FromConfig(Map<String, ObjectRef> config) {
// parse "keys"
{
std::vector<String> keys;
if (config.count(kKeys)) {
bool has_user_keys = config.count(kKeys);
if (has_user_keys) {
// user provided keys
if (const auto* cfg_keys = config[kKeys].as<ArrayNode>()) {
for (const ObjectRef& e : *cfg_keys) {
Expand All @@ -909,9 +910,11 @@ ObjectPtr<Object> TargetInternal::FromConfig(Map<String, ObjectRef> config) {
keys.push_back(GetRef<String>(device));
}
}
// add default keys
for (const auto& key : target->kind->default_keys) {
keys.push_back(key);
if (!has_user_keys) {
// add default keys
for (const auto& key : target->kind->default_keys) {
keys.push_back(key);
}
}
// de-duplicate keys
target->keys = DeduplicateKeys(keys);
Expand Down
3 changes: 1 addition & 2 deletions tests/cpp/target_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,8 @@ TEST(TargetCreationFail, TargetKindNotFound) {
TEST(TargetCreation, TargetParser) {
Target test_target("TestTargetParser -mcpu=woof");
ASSERT_EQ(test_target->GetAttr<String>("mcpu").value(), "super_woof");
ASSERT_EQ(test_target->keys.size(), 2);
ASSERT_EQ(test_target->keys.size(), 1);
ASSERT_EQ(test_target->keys[0], "super");
ASSERT_EQ(test_target->keys[1], "cpu");
}

TEST(TargetCreation, TargetFeatures) {
Expand Down