Skip to content

Commit

Permalink
[Vulkan][Codegen] Read vulkan device capabilities/limits from Target
Browse files Browse the repository at this point in the history
- Previously, the codegen assumed that all device features were
  present.  Now, the codegen reads device capabilities from the
  Target, and throws an error if codegen would require use of an
  unsupported feature.
  • Loading branch information
Lunderberg committed May 25, 2021
1 parent eb8142b commit 421add5
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions src/target/spirv/spirv_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,45 @@ SPIRVSupport::SPIRVSupport(tvm::Target target) {
ICHECK_EQ(target->kind->device_type, kDLVulkan)
<< "SPIRVSupport can only be checked for vulkan device type";

// Currently, this codifies the assumptions that were present and
// implicit in previous implementations. In the future, this will
// pull information from the specified `Target`.

supports_storage_buffer_storage_class = (SPV_VERSION >= 0x10300);
supports_storage_buffer_8bit_access = true;
supports_storage_buffer_16bit_access = true;
supports_float16 = true;
supports_int8 = true;
supports_int16 = true;
supports_int64 = true;
if (target->GetAttr<Integer>("supported_subgroup_operations")) {
supported_subgroup_operations =
target->GetAttr<Integer>("supported_subgroup_operations").value();
}
if (target->GetAttr<Integer>("max_push_constants_size")) {
max_push_constants_size = target->GetAttr<Integer>("max_push_constants_size").value();
}
if (target->GetAttr<Integer>("max_uniform_buffer_range")) {
max_uniform_buffer_range = target->GetAttr<Integer>("max_uniform_buffer_range").value();
}
if (target->GetAttr<Integer>("max_storage_buffer_range")) {
max_storage_buffer_range = target->GetAttr<Integer>("max_storage_buffer_range").value();
}
if (target->GetAttr<Integer>("max_per_stage_descriptor_storage_buffer")) {
max_per_stage_descriptor_storage_buffers =
target->GetAttr<Integer>("max_per_stage_descriptor_storage_buffer").value();
}
if (target->GetAttr<Bool>("supports_storage_buffer_storage_class")) {
supports_storage_buffer_storage_class =
target->GetAttr<Bool>("supports_storage_buffer_storage_class").value();
}
if (target->GetAttr<Bool>("supports_8bit_buffer")) {
supports_storage_buffer_8bit_access = target->GetAttr<Bool>("supports_8bit_buffer").value();
}
if (target->GetAttr<Bool>("supports_16bit_buffer")) {
supports_storage_buffer_16bit_access = target->GetAttr<Bool>("supports_16bit_buffer").value();
}
if (target->GetAttr<Bool>("supports_float16")) {
supports_float16 = target->GetAttr<Bool>("supports_float16").value();
}
if (target->GetAttr<Bool>("supports_int8")) {
supports_int8 = target->GetAttr<Bool>("supports_int8").value();
}
if (target->GetAttr<Bool>("supports_int16")) {
supports_int16 = target->GetAttr<Bool>("supports_int16").value();
}
if (target->GetAttr<Bool>("supports_int64")) {
supports_int64 = target->GetAttr<Bool>("supports_int64").value();
}
}

} // namespace codegen
Expand Down

0 comments on commit 421add5

Please sign in to comment.